XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (804 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
8.45Mb size Format: txt, pdf, ePub
ads

If a schema can be found for the document, then the document is validated against it, but if no schema can be found, or if the document is not valid against the schema, then the call succeeds anyway and returns an untyped document. However, if no document can be found, or if the document is not well formed, then a fatal error is reported. As far as I can tell, the only reliable way of ensuring that a schema is found when validating input documents is to include a reference to the schema within the document itself, using an
xsi:schemaLocation
or
xsi:noNamespaceSchemaLocation
attribute. Importing a schema into the stylesheet isn't enough. The same rules appear to apply to the principal input document to the transformation. (You might note the tentative prose in this paragraph—this area of the product is not well documented, and I had to do quite a few experiments to work out what it was doing.)

This means that if you want to force the input to be valid, you can use the instruction:


In this case, it seems that the schema must be imported into the stylesheet; identifying it within an
xsi:schemaLocation
attribute in the document that you are validating doesn't work.

The
collection()
function in the 2008 release has been enhanced to provide facilities similar to the two ways of defining a collection in Saxon. The collection URI can either identify an XML file used as a catalog to contain a list of the files in the collection, or you can specify a filename with wildcards; for example,
collection(‘c:/data/*.xml’)
to process all the XML files in a directory. The default collection (the one you get when you call
collection()
with no arguments) is always empty.

AltovaXML only supports a single collating sequence, namely Unicode codepoint collation.

The Command Line Interface

The command line interface to AltovaXML is very uncluttered.

The product installs by default into the directory
c:\Program Files\Altova\Altova\AltovaXML2008
. It doesn't add this directory to the PATH environment variable, so I will assume you have either done this by hand, or that you have made it your current directory. The command to transform a document is then:

AltovaXML -xslt2 style.xsl -in source.xml [-out output.html] [options]

Apart from one option,
-xslstack
, which is used to control the amount of space allocated to variables on the stack, the options are used to provide parameters to the transformation (values for

declarations). The format is:

-param name=expression

where the
-param
keyword is repeated before each parameter. The value of the parameter is given in the form of an XPath expression, so for a boolean parameter you might write
-param debug=true()
. Unfortunately, this means you need to understand the way that the command line interpreter handles spaces and quotes. To supply a string value for a parameter, write it between single quotes; for example,
-param city=‘Paris’
. These quotes are the XPath quotes that surround a string literal. If the value contains a space, surround it with double quotes, for example
-param value=“2 + 2”
. These are directed at the command line interpreter. To supply a string value that contains a space, you need both sets of quotes, thus:
-param city=“ ‘Los Angeles’ ”
.

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
8.45Mb size Format: txt, pdf, ePub
ads

Other books

The House of Happiness by Barbara Cartland
Hardass (Bad Bitch) by Christina Saunders
Loud in the House of Myself by Stacy Pershall
Cartboy Goes to Camp by L. A. Campbell
The Christmas Candle by Max Lucado
A Wild and Lonely Place by Marcia Muller
Fire Over Atlanta by Gilbert L. Morris
Kingdom of Heroes by Phillips, Jay