xsl:package

Defines a set of stylesheet modules that can be compiled as a unit, independently of other packages.

Content: ( ( xsl:expose | declarations )* )
Permitted parent elements: None

Attributes

id?

id

Optional identifier, not used by the XSLT processor; may be used to identify a package within a larger XML document.

name?

uri

The name of the package, as an absolute URI, to be used by xsl:use-package declarations.

package-version?

string

Version identifier, used to distinguish between different versions of a package.

version

decimal

Indicates the version of XSLT to which the package manifest conforms.

input-type-annotations?

"preserve" | "strip" | "unspecified"

Used to request stripping of type annotations. The default is unspecified.

declared-modes?

boolean

Determines whether of not modes that are referenced within the package must be explicitly declared. The default is yes.

default-mode?

eqname | "#unnamed"

Standard attribute that may appear on any XSLT element. Defines the default value for the mode attribute of all xsl:template and xsl:apply-templates elements within its scope.

default-validation?

"preserve" | "strip"

Standard attribute that may appear on any XSLT element. Defines the default value for the validation attribute of all relevant instructions appearing within its scope. The default is strip.

default-collation?

uris

Standard attribute that may appear on any XSLT element. Specifies the default collation used by all XPath expressions appearing in attributes or text value templates within its scope (unless overridden by another default-collation attribute on a descendant); and used by certain XSLT constructs within its scope. If present it must be a whitespace-separated list of collation URIs, that use the scheme and path http://www.w3.org/2013/collation/UCA (to request use of the Unicode Collation Algorithm), or collations otherwise recognized by Saxon (see Collations).

extension-element-prefixes?

prefixes

Standard attribute that may appear on any XSLT element. Used to declare the use of extension instructions in a particular namespace.

exclude-result-prefixes?

prefixes

Standard attribute that may appear on any XSLT element. Used to designate namespaces as excluded.

expand-text?

boolean

Standard attribute that may appear on any XSLT element. New in XSLT 3.0. If set to yes, enables the use of text value templates - expressions enclosed in curly braces within text nodes, behaving the same way as attribute value templates in attribute nodes - for descendant text nodes (unless overridden by another expand-text attribute on a descendant). The default is no.

use-when?

expression

Standard attribute that may appear on any XSLT element. Used to conditionally include or exclude elements. The value is an XPath expression that can be evaluated statically. If the effective boolean value is false, then the element and all its descendants are effectively excluded from the stylesheet module.

xpath-default-namespace?

uri

Standard attribute that may appear on any XSLT element. Determines the namespace used for any unprefixed element name or type name within an XPath expression. The value may be overridden by another xpath-default-namespace attribute on a descendant. The default is a zero-length string, for names in no namespace.

Notes on the Saxon implementation

Packages are new in XSLT 3.0, and first fully implemented in Saxon 9.7.

Saxon 9.8 introduces new capabilities for defining packages in the configuration file. The configuration file acts as a catalog, mapping package names and versions to the actual locations of source XSLT code for the package, or exported SEF files containing the compiled package.

Alternatively, it is possible to resolve package names and versions programmatically by setting up a PackageLibrary.

Packages are available in all Saxon editions. However, only Saxon-EE can be used to export a package in compiled (SEF) form to filestore, and only Saxon-PE or -EE can be used to load a compiled package from filestore. With Saxon-HE, packages must be compiled from source code every time they are used.

Links to W3C specifications

XSLT 3.0 Specification

See also

xsl:expose

xsl:use-package