Datasheet

Williams c01.tex V3 - 07/31/2009 2:53pm Page 21
Chapter 1: First Steps with XSLT
<dc:description>
<xsl:value-of select
=
"summary"/>
</dc:description>
<dc:format>
<xsl:value-of select
=
"content/@type"/>
</dc:format>
<xsl:for-each select
=
"category">
<dcsubject>
<xsl:value-of select
=
"./@label"/>
</dc:subject>
</xsl:for-each>
</item>
</xsl:template>
The full stylesheet is shown in Listing 1-6.
Listing 1-6
<?xml version
=
"1.0" encoding
=
"UTF-8"?>
<xsl:stylesheet version
=
"2.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#"
xpath-default-namespace
=
"http://www.w3.org/2005/Atom">
<xsl:output method
=
"xml"/>
<xsl:variable name
=
"site">testurl</xsl:variable>
<xsl:template match
=
"/">
<rdf:RDF xmlns:rdf
=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc
=
"http://purl.org/dc/elements/1.1/">
<channel>
<xsl:variable name
=
"feedurl" select
=
"feed/link[@rel
=
’self’]/@href"/>
<xsl:attribute name
=
"rdf:about">
<xsl:value-of select
=
"$feedurl"/>
</xsl:attribute>
<title>
<xsl:value-of select
=
"feed/title"/>
</title>
<link>
<xsl:value-of select
=
"$feedurl"/>
</link>
<items>
<rdf:Seq>
<xsl:for-each select
=
"feed//entry">
<rdf:li>
<xsl:attribute name
=
"rdf:resource">
<xsl:value-of select
=
"id"/>
</xsl:attribute>
</rdf:li>
</xsl:for-each>
</rdf:Seq>
</items>
<xsl:for-each select
=
"//entry">
<xsl:apply-templates select
=
"."/>
</xsl:for-each>
</channel>
Continued
21