Subject: RE: [xsl] number collapsing From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 14 Dec 2004 15:07:10 -0000 |
> >> <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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] number collapsing, Michael Kay | Thread | [xsl] Free XSL editors, Marcelo |
[xsl] design ideas? exploiting vari, Bruce D'Arcus | Date | RE: [xsl] number collapsing, Michael Kay |
Month |