Datasheet
Williams c01.tex V3 - 07/31/2009 2:53pm Page 14
Chapter 1: First Steps with XSLT
Try It Out The Saxon CLI
Enter the following code on the command line and execute it:
java net.sf.saxon.Transform -s:xsl_stylesheet.xml -xsl:local.xsl
-o:xsl_stylesheet.html
The options in the example have the following meanings:
-s:filename
: The source XML file
-xsl:filename
: The XSL stylesheet to use
-o:filename
: The output filename
The remaining Saxon CLI options are extensive and quite powerful. If you are interested in pursuing the
CLI approach, you should review the Saxon documentation at your leisure before using them.
Transforming XML Data to XML
The next example illustrates how simple it can be to transform content from one XML format to another.
A common transform problem is that two similar schemas will use different names for identical content
values. Another problem is that in one case an attribute is used for a value, while another uses an element
for the same purpose.
The next stylesheet uses two common metadata vocabularies that express information in roughly the
same manner. One is the Atom 1.0 format, increasingly used for blogs and news feeds; the other is RSS
1.0, which uses a combination of the Dublin Core Metadata Initiative vocabulary and RDF/XML.
There is also a version 2.0 ‘‘branch’’ of RSS. Although it is often assumed that RSS 2.0 supersedes
RSS 1.0, it doesn’t; and the versions are incompatible in several ways. RSS 2.0 is also in widespread
use, but we won’t be using it in this chapter. If you want to explore the structure of RSS 2.0, go to
http://cyber.law.harvard.edu/rss/rss.html
.
Of course, you wouldn’t bother serializing either of these feeds to XML if the data were in a SQL database
or an RDF triple store. However, if you are aggregating the data from feed URLs, or you have been
provided with source data in XML, you won’t have much choice.
Atom and RSS Elements
The next two tables compare the feed elements and entry elements in the Atom 1.0 schema with the
equivalents in RDF Site Summary (RSS) 1.0. The pros and cons of the different ways to describe metadata
can be a contentious issue, but just now we need not be concerned with the details.
The following table lists the top-level elements that define the properties of the Atom feed in the
<feed>
and RSS 1.0
<channel>
elements. The matches are quite weak at this level, perhaps reflecting the history
14