Re: [xsl] Is there any benefit to creating a variable and specifying as="xs:string"?

Subject: Re: [xsl] Is there any benefit to creating a variable and specifying as="xs:string"?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 9 Jun 2024 15:51:52 -0000
On 09/06/2024 17:38, Roger L Costello costello@xxxxxxxxx wrote:
> What is the right way to get a parameter validated against an XSD type?


See below (use the as attribute with the simple type name, make sure if
it is in a namespace that you declare a prefix and qualify the type name
with the prefix):


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 B  version="3.0"
 B  xmlns:xs="http://www.w3.org/2001/XMLSchema";
 B  exclude-result-prefixes="#all"
 B  expand-text="yes">

 B  <xsl:import-schema>
 B B  <xs:schema>
 B B B B  <xs:simpleType name="ICAOtype">
 B B B B B B B  <xs:restriction base="xs:string">
 B B B B B B B B B B B  <xs:length value="4"/>
 B B B B B B B B B B B  <xs:pattern value="[A-Z]+"/>
 B B B B B B B  </xs:restriction>
 B B B  </xs:simpleType>
 B B  </xs:schema>
 B  </xsl:import-schema>


 B  <xsl:param name="ICAO" as="ICAOtype"/>

 B  <xsl:template match="/" name="xsl:initial-template">
 B B B  <test>{$ICAO}</test>
 B  </xsl:template>

</xsl:stylesheet>

Current Thread