Subject: Re: [xsl] number collapsing From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 14 Dec 2004 14:28:52 GMT |
<xsl:when test="$begin castable as 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, not quite, you are saying "if it looks like an integer" then.... Unkfortnately Xpath2 does not automatically cast between types anything like as often as Xpath1 does, so if you have the string "123" then the test is true as the string is _castable_ to an integer, xs:integer("123") is the integer 123, not an error, but that cast doesn't happen automatically: "123" + 1 is an error (in Xpath 1 it would be 124) you need to do xs:integer("123") + 1 to get 124 similarly given <xsl:when test="$begin castable as xs:integer"> all you know is that xs:integer($begin) will give an integer not an error, but you don't know that you can use $begin in integer operations: $begin + 1 is an error if $begin is "123" That's why Mike suggested adding an explict cast. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] number collapsing, Bruce D'Arcus | Thread | Re: [xsl] number collapsing, Bruce D'Arcus |
Re: [xsl] number collapsing, Bruce D'Arcus | Date | [xsl] Problem Running Dave Pawson's, cfisher |
Month |