Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Format
id? =
id
default-collation? =
uri-list
default-validation? = “preserve” | “strip”
exclude-result-prefixes? =
tokens
extension-element-prefixes? =
tokens
input-type-annotations? = “preserve” | “strip” | “unspecified”
use-when? =
expression
version =
number
xpath-default-namespace? =
uri
Position
simplified–stylesheet
syntax described on page 125, in Chapter 3. It is used both on a principal stylesheet module and on one that is imported or included into another module.
As described in Chapter 3, a stylesheet can be embedded in another XML document. In this case the
Namespace Declarations
There will always be at least one namespace declaration on the
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”
This defines the
XSLT Namespace
, which is necessary to identify the document as an XSLT stylesheet. The URI part must be written exactly as shown. The prefix
xsl
is conventional and is used in all XSLT documentation, including this book and the standard itself, but you could choose a different prefix if you wanted; for example,
XSLT
. You would then have to name the element
You can also make this the default namespace by using the following declaration:
xmlns=“http://www.w3.org/1999/XSL/Transform”
In this case the element name will simply be
rather than
You may come across a stylesheet that uses the namespace declaration:
xmlns:xsl=“http://www.w3.org/TR/WD-xsl”
This is not an XSLT stylesheet at all, but one written in WD-xsl, the working-draft dialect of XSL that Microsoft shipped in 1998 with Internet Explorer 5. This is a very different language, and is not described in this book.
Many stylesheets also need to declare the XML Schema namespace, typically as:
xmlns:xs=“http://www.w3.org/2001/XMLSchema”
This is needed to declare the types of variables or parameters, or to use conversions to types such as
xs:integer
and
xs:date
.
Attributes
Name | Value | Meaning |
id optional | XML Name | An identifier used to identify the |
default-collation optional | Whitespace-separated list of URIs | Defines the default collation to be used for XPath functions and operators. |
default-validation optional | preserve or strip | Defines the validation applied to new element and attribute nodes when the instruction that creates them does not have an [xsl:]validation or [xsl:]type attribute. The detault is strip . |
exclude-result-prefixes optional | Whitespace-separated list of NCNames or #default, indicating the default namespace, or #all, indicating all namespaces | Defines any namespaces used in this stylesheet that should not be copied to the output destination, unless they are actually used in the result document. |
extension-element-prefixes optional | Whitespace-separated list of NCNames or #default, indicating the default namespace. | Defines any namespaces used in this stylesheet to identify extension elements. |
input-type-annotations optional | preserve , strip , or unspecified | Defines how type annotations on input documents should be handled. |
use-when optional | XPath expression, restricted to use information available at compile time | Defines a condition that must be true if the contents of this stylesheet module are to be included in the stylesheet. It must be possible to evaluate the condition statically, which means it will often consist of a test on the value of the system-property() function. |
version mandatory | Number | Defines the version of XSLT required by this stylesheet. Use 2.0 for a stylesheet that requires XSLT 2.0 features, or 1.0 if you want the stylesheet to be portable between XSLT 1.0 and XSLT 2.0 processors. |