Book list example

The XML file books.xml is used for a number of demonstrations. This file, along with its DTD books.dtd, is found in the samples/data directory.

Transform

The stylesheet books.xsl can be used to display the data, and is designed to illustrate several Saxon extensions. Run this as follows, with the samples directory as the current directory:

For SaxonJ:

java net.sf.saxon.Transform -s:data/books.xml -xsl:styles/books.xsl -o:output.html

For SaxonCS:

dotnet SaxonCS transform -s:data/books.xml -xsl:styles/books.xsl -o:output.html

This produces an HTML page showing the data.

The stylesheet takes a parameter named "top-author". This is the name of the "author of the week", and the default value is "Jasper Fforde". To run the stylesheet with a different top author, try adding to the end of the command line:

..... top-author='Thomas Hardy'

Query

A query that runs with this data is also supplied.

The command to use on the Java platform is:

java net.sf.saxon.Query -s:data/books.xml -q:query/books.xq -o:output.html

The equivalent on .NET is:

dotnet SaxonCS query -s:data/books.xml -q:query/books.xq -o:output.html

Other demonstrations

Several other related XML resources are supplied. The schema for data/books.xml is data/books.xsd. Also supplied in the samples resources is the file data/books-invalid.xml, which (as the name suggests) is a version of the books file which is invalid against the schema, and data/more-books.xml which lists some different books.

These resources may be used for instance with the sample applications QuickValidator.java, SchemaValidatorExample.java, and SchemaValidatorHandlerExample.java.

There is another stylesheet, styles/books-csv.xsl, which converts the data in the file data/books.xml into a comma-separated-values file.

The stylesheet styles/total.xsl is used by the JDOM2 example application.

The sample program XPathExampleSA.java illustrates the use of the JAXP XPath API, extended by Saxon to allow schema-aware XPath 2.0 processing. The program is designed to run against the sample file books.xml. It produces a list of all books over 2cm thick that were published during the 6 years since the start of 2000.

Also see the SQL extension instructions example for details on the sample stylesheet styles/books-sql.xsl which uses Saxon SQL extension instructions to load the contents of books.xml into a database table.