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

Re: redundancy in string(number(current())) = 'NaN' ??

Subject: Re: redundancy in string(number(current())) = 'NaN' ??
From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx>
Date: Wed, 11 Jun 2003 17:44:30 -0400 (EDT)
turn string to number
On Wed, 11 Jun 2003, David Carlisle wrote:

>   //sales[string(number(current()))='NaN']
> 
>   just to make sure, i'm assuming the "current()" part is 
>   redundant, 
> 
> 
> Not its not redundant. current() returns the node current when this
> expression is evaluated (ie typically the node matched by the template
> that contains this expression) number() or number(.) would use the
> contect node at that part of the expression which would be each of the
> sales nodes in turn.
> 
> having said that its a strange expression as the predicate doesn't
> depend on the sales node to which it applies so either the above is
> equivalent to
> //sales
> or to the empty node set, depending on whether the current node
> is a number or not. Sometimes you have to do this though as xpath
> doesn't have an if statement.

just to put this in context, i'm looking at kay, p. 251:

<xsl:variable name="bad-sales" 
              select="//sales[string(number(current()))='NaN']"/>


this is immediately followed by a loop construct:

<xsl:template match="/">
  <xsl:for-each select="$bad-sales">
    <xsl:message>Sales value <xsl:value-of select="."/>
      is not numeric
    </xsl:message>
  </xsl:for-each>	... etc etc ...


so it's pretty clear that the "bad-sales" variable is being
assigned the node-set of bad sales nodes (those with a NaN
value).

so, while i'm getting closer to understanding this, i'm still
puzzled about the use of current() here if, as you say, it matches
the node that's current when the expression is evaluated.

i'd better read the section on current() more closely.

rday



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.