[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"> 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 ________________________________________________________________________
|
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
|