Subject: RE: testing for string and number in XSLT 2.0 was Re: Test For Numeric Values?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 8 Apr 2005 22:11:40 +0100
|
> take for example xsl:sort
>
> <xsl:sort select="." data-type="number"/>
>
> what does 'number' mean here?
It's retained for backwards compatibility with XSLT 1.0; the "native" way of
doing this in 2.0 would be
<xsl:sort select="xs:double(.)"/>
if they are doubles, or more likely
<xsl:sort select="xs:integer(.)"/>
if they are integers.
>
> and if we are comfortable with this type of ambiguity of identifying
> something purely as a 'number'....then why not have some fairly useful
> functions such as is-number() and is-string() that exist in
> this no mans land.
You're welcome to write your own function is-string($x) that has the same
effect as the expression ($x instance of xs:string), but the WG wants to
avoid bloating the language with redundant ways of doing the same thing.
Michael Kay
http://www.saxonica.com/
|