Name
[2.0] type-available()
Given the name of a datatype, returns true
if that datatype is known to the
XSLT processor.
Syntax
xs:booleantype-available(
$typeName as xs:string
)
Input
An xs:string
containing
the name of a datatype.
Output
The xs:boolean
value
true
if the datatype is known
to the XSLT processor; false
otherwise.
Defined in
XSLT 2.0 section 18.1.4, “Testing Availability of Types.”
Example
Here’s a short stylesheet that checks the availability of two datatypes. The first datatype is defined to all XSLT 2.0 processors, while the second datatype is defined in a schema and therefore requires a schema-aware processor.
<?xml version="1.0"?> <!-- type-available.xsl --> <xsl:stylesheet version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:age="http://www.oreilly.com/xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
A test of the type-available() function:
</xsl:text> <xsl:text>
 xs:integer is available: </xsl:text> <xsl:value-of select="type-available('xs:integer')"/> <xsl:text>
 age:age-type is available: </xsl:text> <xsl:value-of select="type-available('age:age-type')"/> </xsl:template> </xsl:stylesheet>
Notice that we have to declare the namespace prefixes for
the datatypes. Because there is no <xsl:import-schema>
element, only
the first datatype is available:
A test of the type-available() function: xs:integer is available: true age:age-type is available: false
If we import a schema into ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.