Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Examples
This example imports the schema for namespace
http://ns.megacorp.com/hr
from the location
http://schema.megacorp.com/hr/schema.xsd
:
namespace = “http://ns.megacorp.com/hr”
schema-location = “http://schema.megacorp.com/hr/schema.xsd”/>
The following example imports a no-namespace schema from the file
schema.xsd
in the same directory as the stylesheet:
schema-location = “schema.xsd”/>
The following example imports the schema that defines the structure of XSLT stylesheets. (This import would be useful only in a stylesheet that is designed to process XSLT stylesheets as its input and/or result documents.).
namespace = “http://www.w3.org/1999/XSL/Transform”
schema-location=“http://www.w3.org/2007/schema-for-xslt20.xsd”/>
The following example defines a union type for use locally within the stylesheet. This type allows either an
xs:date
, an
xs:time
, or an
xs:dateTime
:
This type might be used in the signature of a function that applies default formatting to the value, as follows:
The full stylesheet is in file
inline.xsl
. Unfortunately it's not possible to use the union type directly as a parameter to the function (
as=“local:dateOrTime”
) — although the meaning is intuitive, union types cannot appear directly in a
SequenceType
, only as a type annotation on element or attribute nodes.
xsl:include
import precedence
as those in the including module, so the effect is as if these definitions were textually included at the point in the including module where the
Changes in 2.0
There are no changes to the syntax of this instruction in XSLT 2.0. The rules for the
href
attribute have been reformulated to reflect current practice with XSLT 1.0: In effect, the way in which the URI is dereferenced to obtain a stylesheet module is now largely implementation defined. This allows for options such as catalogs or user-specified URI resolvers, as well as implementations that cache or precompile stylesheet modules.
Format
href = uri-reference />
Position
Attributes
Name | Value | Meaning |
href mandatory | URI | The URI of the stylesheet to be included |
Like all other XSLT elements, the
use-when
attribute. This is described in Chapter 3 (see page 127). This can be used in the same way as on