Datasheet

Williams c01.tex V3 - 07/31/2009 2:53pm Page 13
Chapter 1: First Steps with XSLT
Listing 1-4
<?xml version
=
"1.0" encoding
=
"UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>xsl:stylesheet</title>
</head>
<body>
<h1>xsl:stylesheet</h1>
<h2>Purpose</h2>
<p>The root element of a stylesheet.</p>
<h2>Usage</h2>
<p>The <code>stylesheet</code> is always the root element, even if a
stylesheet is included in, or imported into, another. It must have a <code>
version</code> attribute, indicating the version of XSLT that
the stylesheet requires.</p>
<p>For this version of XSLT, the value should normally be <code>"2.0"</code>.
For a stylesheet designed to execute under either
XSLT 1.0 or XSLT 2.0, create a core module for each version number;
then use <code>xsl:include</code> or <code>xsl:import</code> to
incorporate common code, which should specify <code>version
=
"2.0"</code> if it uses
XSLT 2.0 features, or <code>version
=
"1.0"</code> otherwise.</p>
<p>The <code>xsl:transform</code> element is allowed as a synonym.</p>
<p>The namespace declaration <code>xmlns:xsl
=
"http//www.w3.org/1999/XSL
/Transform</code> by convention uses the prefix <code>xsl</code>.</p>
<p>An element occurring as a child of the <code>stylesheet</code> element is
called a declaration. These top-level elements are all optional, and may occur
zero or more times.</p>
</body>
</html>
Using the Command Line
Another way to invoke a stylesheet processor is to use a command-line interface. The specifics of the
interface will vary according to which processor you use.
The next example uses the Saxon CLI for the open-source version on the
local.xsl
. If you intend to use
the CLI frequently, you may prefer to run it from an open-source tool like jEdit (
www.jedit.org
), rather
than from the file system console.
If you are using the Oxygen IDE and just want to experiment with the CLI, you will find the
.jar
file
in the
lib
directory. If you are not using a bundled version of Saxon, you can download the Java ver-
sion of the Saxon processor from SourceForge (
http://sourceforge.net/project/showfiles.php?
group
id
=
29872)
.
Unzip the download to a convenient directory. Add the
saxon9.jar
file to the classpath so that the
command in the following Try It Out will locate the main program
net.sf.saxon
. The schema-aware
version is
com.saxonica
.
Full documentation is available on the Saxonica site, which you should consult for installation and con-
figuration instructions (
www.saxonica.com/documentation/contents.html)
.
13