xsltサンプル:apply-template
Last-modified: 2013-08-24 (土) 02:14:21 (3753d)
Top / xsltサンプル:apply-template
xsltサンプル:apply-template †
apply-templateのサンプルです。
以下に、apply-templateしていないものとしているものを載せます。結果は一緒です。
ちなみに、xsltにかける対象はこのサイトのrssです。
■apply-templateしてないxsltサンプル
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:rss="http://purl.org/rss/1.0/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <xsl:template match="/"> <html> <p>xsltサンプル</p> <lu> <xsl:for-each select="/rdf:RDF/rss:item"> <li><xsl:value-of select="rss:title/text()" /></li> </xsl:for-each> </lu> </html> </xsl:template> </xsl:stylesheet>
■apply-templateしているxsltサンプル
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:rss="http://purl.org/rss/1.0/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <xsl:template match="/"> <html> <p>xsltサンプル</p> <lu> <xsl:apply-templates select="/rdf:RDF/rss:item" /> </lu> </html> </xsl:template> <xsl:template match="/rdf:RDF/rss:item"> <li><xsl:value-of select="rss:title/text()" /></li> </xsl:template> </xsl:stylesheet>