Reputation: 4034
I'm using XSL's convenience functions for comparisons, gt, lt, ge, le, eq
.
I understand these functions won't promote a string to a numerical value when performing comparisons, however I need that cast to be made, and I don't want to clutter my code with lines like
<xsl:when test="xs:integer($variable) lt 250" >
I'd rather make that cast like this (hypothetical of course)
<xsl:variable name="variable" type="xs:integer">
So, is there a means of explicitly casting variable
as an numerical type when it is declared/created ?
Upvotes: 3
Views: 9269
Reputation: 243479
<xsl:when test="xs:integer($variable) lt 250" >
I'd rather make that cast like this (hypothetical of course)
<xsl:variable name="variable" type="xs:integer">
Use the as
attribute -- its purpose is exactly to specify the type of a variable, parameter, template or a function:
<xsl:variable name="variable" as="xs:integer"
select="some-integer-type-expression">
Upvotes: 3