[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Costello, Roger L. wrote:
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.
Re: [xsl] [XSLT 2.0] Checking that an element's value has the desired datatype?
Subject: Re: [xsl] [XSLT 2.0] Checking that an element's value has the desired datatype? From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Mon, 16 Oct 2006 19:22:04 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [XSLT 2.0] Checking that , Dimitre Novatchev | Thread | Re: [xsl] Rename Some Node and attr, Abel Braaksma |
Re: [xsl] [XSLT 2.0] Checking that , Dimitre Novatchev | Date | Re: [xsl] XSL and XML Help, Florent Georges |
Month |
Keywords