|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: number collapsing
> >> <xsl:when test="$begin castable as xs:integer"> > >> <xsl:variable name="begin2" select="$begin" > as="xs:integer"/> > > > > This may fail if $begin is a string. The string "123" is castable to > > xs:integer, but not assignable to xs:integer. > > I'm not following here. Aren't I saying in the function "if > $begin is > an integer, then apply this logic to determine how to shorten > $end; if > not, then just print $end as is"? No, you are saying "if $begin is capable of being cast to an integer, then assign it to an integer, and then...". But the fact that $beging is capable of being cast to an integer does not mean it is capable of being assigned to an integer; having established that the cast is possible you must then do the cast. The logic for "castable" is always if (A castable as B) then f(A cast as B) else ... Specifically, if $begin is a string in the form "123" then the "castable as" test will succeed, but the assignment will fail. Assignment does not do an implicit cast. (However, if $begin is untypedAtomic, then your logic works correctly, because untypedAtomic is a "weak" type that is automatically converted to the required type when necessary). Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








