XML 스타일 시트 적용 내용
DB&XML 2007. 9. 19. 01:31 |본 내용은 클라이언트 xsl 적용 방법 입니다.
[categories.xml]
<?xml version='1.0' ?>
<?xml-stylesheet type='text/xsl' href='categories.xsl'?>
<categorylist xmlns:sql='urn:schemas-microsoft-com:xml-sql'>
<sql:query>
SELECT categoryid, categoryname
FROM categories
FOR XML AUTO, ELEMENTS
</sql:query>
</categorylist>
[categories.xsl]
<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:template match='/'>
<BODY>
<TABLE>
<TR>
<TD><B>Click a Product Category</B></TD>
</TR>
<xsl:for-each select='categorylist/categories'>
<TR>
<TD>
<A>
<xsl:attribute name='HREF'>
Products.xml?categoryid=<xsl:value-of select='categoryid'/>
&contenttype=text/html
</xsl:attribute>
<xsl:value-of select='categoryname'/>
</A>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</xsl:template>
</xsl:stylesheet>
[categories.xml]
<?xml version='1.0' ?>
<?xml-stylesheet type='text/xsl' href='categories.xsl'?>
<categorylist xmlns:sql='urn:schemas-microsoft-com:xml-sql'>
<sql:query>
SELECT categoryid, categoryname
FROM categories
FOR XML AUTO, ELEMENTS
</sql:query>
</categorylist>
[categories.xsl]
<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:template match='/'>
<BODY>
<TABLE>
<TR>
<TD><B>Click a Product Category</B></TD>
</TR>
<xsl:for-each select='categorylist/categories'>
<TR>
<TD>
<A>
<xsl:attribute name='HREF'>
Products.xml?categoryid=<xsl:value-of select='categoryid'/>
&contenttype=text/html
</xsl:attribute>
<xsl:value-of select='categoryname'/>
</A>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</xsl:template>
</xsl:stylesheet>