[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: number collapsing

Subject: Re: number collapsing
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 14 Dec 2004 14:28:52 GMT
cast number
  <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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.