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

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

In a previous version of the stylesheet some of these parameters were declared using the syntax.

1

It's good to see that this has been fixed. Placing the value in the content of the element means that the value is not a simple number or string, but rather a temporary tree, which however much the XSLT processor optimizes it is likely to be a much more heavyweight data structure. The use of
0
and
1
as parameter values, rather than the more obvious
true()
and
false()
, can be justified by the fact that with many XSLT processors, there is no way of supplying boolean parameter values from the command line.

There are two ways these parameters can be set. Either the values can be supplied from the calling application (typically, from the command line) or the parameters can be overridden in an overlay stylesheet. An overlay stylesheet (we'll see examples later) is a stylesheet that imports the main
xmlspec.xsl
stylesheet and makes modifications or extensions to it. If the parameters were designed to be set in this way only, they could have been defined using

rather than

, but using

is more versatile because it allows either mechanism to be used.



The stylesheet uses two key definitions. These are designed to make hyperlinks within the document easier to follow. The first key matches any attribute named
id
, on any element, making it easy to find an element with a given
id
attribute. The DTD allows an
id
attribute on any element whatsoever. In fact, it defines the type of the attribute to be
ID
, so these elements could also be located using the
id()
function. (Sorry for the overloading of this term!) In fact, the stylesheet avoids the use of the
id()
function altogether, probably because
id()
isn't guaranteed to work correctly unless the document is processed using a validating parser.

The second key definition is a little surprising. A

is a cross-reference: it is used wherever the text says something like “See section 8.2.” I wouldn't expect to see any code that needs to locate all the cross-references; a more natural usage would be to index the elements that act as the target of a cross-reference. But on examination, it turns out that this key definition is not used. No doubt it is the result of another experiment, and someone forgot to delete it. Again, it does no harm—the chances are that an XSLT processor will completely ignore a key definition if the key is never used.

Other books

Vixen by Jane Feather
Fevered Hearts by Em Petrova
Comeback by Richard Stark
Scepters by L. E. Modesitt
Undying Hunger by Jessica Lee
Storm: Book 3 by Evelyn Rosado
What He Wants by Hannah Ford
Avalanche of Daisies by Beryl Kingston