Datasheet
Williams c01.tex V3 - 07/31/2009 2:53pm Page 17
Chapter 1: First Steps with XSLT
<summary>Can we define a family of markup languages that used the Unicode
properties and which could accept a fair imitation of XML and produce
a SAX-like event stream?</summary>
<author>
<name>Rick Jelliffe</name>
</author>
<category term
=
"xml" label
=
"xml"
scheme
=
"http://www.sixapart.com/ns/types#tag"/>
<content type
=
"html" xml:lang
=
"en" xml:base
=
"http://broadcast.oreilly.com/">
Can we define a family of markup languages that used the Unicode
properties and which could accept a
fair imitation of XML and produce a SAX-like event stream?
<img src
=
"http://feeds.oreilly.com/
∼
r/oreilly/xml/
∼
4/487372046"
height
=
"1" width
=
"1"/></content>
</entry>
...
</feed>
This feed will be well out of date when you read this. To get a current version, go to
http://feeds.oreilly.com/oreilly/xml
, copy the source, and save it as a replacement.
Alternatively, you can load the data directly from the feed site using the URL containing the feed source.
Developing the Stylesheet
As with the XML to HTML transform, we’ll take the development one step at a time. The approach is
essentially the same, with XML as the target rather than HTML. The vocabularies are, of course, different,
but the matching process will work similarly. It is not too important at present to absorb the details of
the Atom and RSS 1.0 formats, but if you would like to do so here are the relevant URLs:
Atom 1.0
www.atomenabled.org/developers/syndication/atom-format-spec.php
RSS 1.0
http://web.resource.org/rss/1.0/spec
I’ll call the top-level elements ‘‘feed elements,’’ and the individual entries ‘‘entry elements,’’ using the
Atom terminology.
Preliminaries
Let’s start with the basics of the stylesheet
rss_feed.xsl
.Thistimeyou’llset
"2.0"
as the value of the
stylesheet’s
version
attribute. Inside the
<xsl:stylesheet>
element are two namespaces to declare
using the
rdf
and
dc
prefixes.
Always check the source file for a default namespace declaration: In this case it is
"http://www.w3.org/2005/Atom"
. You need to set the
xpath-default-namespace
attribute on the
<xsl:stylesheet>
element to this value; otherwise, nothing from
the source file will be output.
17