<!--
  Naver2RSS 만평 목록 XSLT
  누가: 신재호 <netj@sparcs.kaist.ac.kr>
  언제: 2004-08-08
  $Id$
-->
<xsl:stylesheet version="1.0"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="naver2rss.xsl"/>
    <xsl:template match="xhtml:td[@height=145]/xhtml:table">
        <xsl:variable name="link" select=".//xhtml:a/@href"/>
	<xsl:variable name="full_link">
	    <xsl:call-template name="polish-url">
		<xsl:with-param name="url" select="$link"/>
	    </xsl:call-template>
	</xsl:variable>
	<!-- 해당 페이지에만 있는 정보를 추출하기 위해 받아온다.
	     받아온 조각에서 너비 100%인 표에 대부분의 정보가 있다. -->
	<xsl:variable name="target" select="document(concat($TidyURL, '?', $full_link))//xhtml:table[@width='100%']"/>
        <!-- @href가 같은 a들 중에서 두번째에 나온 것에 제목이 들어있다. -->
	<xsl:variable name="title">
	    <xsl:for-each select="//xhtml:a[@href=$link]">
		<xsl:if test="not(.//xhtml:img)">
		    <xsl:value-of select="."/>
		</xsl:if>
	    </xsl:for-each>
	</xsl:variable>
        <item>
            <title><xsl:value-of select="$title"/></title>
            <link><xsl:value-of select="$full_link"/></link>
	    <xsl:call-template name="who-when">
		<xsl:with-param name="data" select="$target/xhtml:tr[4]"/>
	    </xsl:call-template>
            <description>
		<xsl:text>&lt;a href="</xsl:text>
		<xsl:call-template name="polish-url">
		    <xsl:with-param name="url" select="$link"/>
		</xsl:call-template>
		<xsl:text>"&gt;</xsl:text>

		<xsl:text>&lt;img src="</xsl:text>
		<!--
		작은 그림 대신에 큰 그림을 빼온다.
		<xsl:variable name="imgurl" select=".//xhtml:img/@src"/>
		큰 그림의 주소는 해당 페이지에만 있기 때문에 그 페이지에서
		그림을 찾아내야한다.  5번째 행 속에 그림이 들어있다.
		-->
		<xsl:variable name="imgurl"
		    select="$target/xhtml:tr[5]//xhtml:img/@src"/>
		<xsl:call-template name="polish-url">
		    <xsl:with-param name="url" select="$imgurl"/>
		</xsl:call-template>
		<xsl:text>"&gt;</xsl:text>
            </description>
        </item>
    </xsl:template>
</xsl:stylesheet>

