saxon:as
This attribute may be set on most XSLT elements that have an as
attribute
(xsl:variable, xsl:param, xsl:with-param, xsl:function,
xsl:template: but not currently
xsl:accumulator
) to declare an additional
more specific type for a value.
For example:
<xsl:param name="options" as="map(xs:string, xs:anyAtomicType*)" saxon:as="tuple(validate as xs:boolean, duplicates as xs:boolean, limit as xs:integer, codes as xs:string*)" xmlns:saxon="http://saxon.sf.net/" select="map{'validate': true(), 'duplicates': false(), 'limit': 17, 'codes': ('USD', 'GBP', 'EUR')}"/><xsl:variable name="sqlConnection" saxon:as="javatype:java.sql.Connection" xmlns:saxon="http://saxon.sf.net/" xmlns:javatype="http://saxon.sf.net/java-type" select="..."/><xsl:param name="when" required="yes" as="xs:anyAtomicType" saxon:as="union(xs:date, xs:time, xs:dateTime)" xmlns:saxon="http://saxon.sf.net/">If both the as
and saxon:as
attributes are present, then the type given in the
saxon:as
attribute must be a subtype of the type given in the as
attribute.
The saxon:as
attribute will be ignored by a conformant XSLT processor that does not recognize
the Saxon namespace. The attribute therefore allows type information to be specified for use by Saxon, which
will be ignored by other XSLT processors (this applies to XSLT 1.0 and 2.0 processors as well as XSLT 3.0 processors).
It therefore allows stylesheets to take advantage of Saxon extensions to the sequence type syntax (notably,
tuple types, union types, and type aliases; see Syntax extensions) without sacrificing stylesheet portability.
The saxon:as
attribute can also be defined on the xsl:mode element. Used here, it
provides a default for the as
or saxon:as
attribute of all template rules defined in this
mode.