xsl-list
[Top] [All Lists]

Re: [xsl] [XSLT 2.0] Checking that an element's value has the desired datatype?

2006-10-16 10:22:45
Costello, Roger L. wrote:
Excellent! With this: matches(flt:Aircraft/flt:Altitude, '[0-9]+')
I can do datatype checking, without using XML Schemas.

Not really (as Florent pointed out already). And be aware, it does not check for an xs:integer, it only checks for the existence of one or more digits inside an item. Matching are: '123ABC', 'ABC123', 'ABC1ZYX' etc. To match only digits, you must supply it with start/end matches, like so:

matches(flt:Aircraft/flt:Altitude, '^[0-9]+$')

Furthermore, it does not do the same as 'castable as'. Because a string like '1E10' is an xs:double which is castable as xs:integer. To make matters worse, the xs:string containing '1E10' cannot be cast to xs:integer directly (meaning 'castable as' would return false), it must first be converted to xs:double. Since you can only use matches() on strings, stuff like this cannot be mimicked with it.

-- Abel Braaksma
  http://www.nuntia.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>