XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 10:23 AM
I need to be able Count text as well as numbers and I can't seem to get either to work.

Also, is it possible to count against the content of another element?

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 10:25 AM
Can you provide a practical example of what you are trying to do?

Thanks,
Minollo

Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 10:30 AM
Idealy I would like to something along the lines of

<xsl:value-of select="count(/Nodes/Node[text()=someword])" />

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 10:58 AM
That will return you the number of Node elements whose text matches "someword" (provided that "someword" is enclosed in single quotes in that instruction)... what's wrong with it?

Minollo

Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 11:13 AM
Ah the single quotes was the issue. Thanks

I also need to do a second type of count.
eg

count the amount of items between two node values.

Is this possible? If it isn't, is it possible to count against on node value?

Thanks

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 11:25 AM
>count the amount of items between two node values.
>
>Is this possible? If it isn't, is it possible to count against on
>node value?

These all seem to imply different kind of filters that you would have to specify in the XPath expression...

count(/Nodes/Node[. > 10 and . < 20]) (assuming the value of "Node" is numeric)
count(/Nodes/Node[. = 'some value'])
...

Minollo

Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 11:41 AM
thats fine but it doesn't work when i want to use values that are dynamic. By that i mean the 10 and 20 are node values and not knwon values i manually enter in

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 11:53 AM
It will work as long as you provide the proper XPath to reach the elements that contain the "dynamic" values you are looking for... something like:

count(/Nodes/Node[../NodeThreshold1 > 10 and /Nodes/MyTopNode < 20])

Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 12:07 PM
Sorry, maybe I am not explaining this correctly

I need to do this

count(/Nodes/Node[. > NodeThreshold1 and . < NodeThreshold2])

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 12:30 PM
...same concept... you will need to use the proper XPath to reach the dynamic thresholds.

Minollo

Postnext
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 21 Mar 2006 12:54 PM
unfortunately I get the following error when i do the above :

The character '<' cannot be used in an attribute value.

Postnext
Minollo I.Subject: Count funciton
Author: Minollo I.
Date: 21 Mar 2006 03:24 PM
Originally Posted: 21 Mar 2006 03:25 PM
You need to escape it and use &lt;

Posttop
Mark MaltbySubject: Count funciton
Author: Mark Maltby
Date: 22 Mar 2006 07:52 AM
Thanks for ur help. All working now

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.