Subject: Re: [xsl] redundancy in string(number(current())) = 'NaN' ?? From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx> Date: Wed, 11 Jun 2003 17:44:30 -0400 (EDT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] redundancy in string(numb, David Carlisle | Thread | RE: [xsl] redundancy in string(numb, Michael Kay |
[xsl] Re: contains any child nodes , Dimitre Novatchev | Date | RE: [xsl] redundancy in string(numb, Michael Kay |
Month |