Let's say you define a custom function. When declaring a parameter, I could use the "as" flag to define the valid data type on the input parameter of that function. I normally would rely on the XML Schema datatypes (in the xs: namespace) to restrict the input parameter type. But what if I wanted to have a pattern restriction or custom datatype on that parameter?
For example, I want a function that takes a string with the enumeration of "X" and "Y" only. If any other string is passed as an input to that function, the function would 'fail'.
I know you can define a custom type in XML Schema and import that custom data type into your XSLT for use. But can it be done with regular expressions or perhaps some other mechanism?
Code:
<xsl:function name="fns:doSoemthing" as="xs:string">
<xsl:param name="p1" as="xs:string" />
<!-- Only 'X' and 'Y' are valid for p1 -->
<xsl:value-of select="$p1" />
</xsl:function>