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
R RSubject: Comparing two nodes
Author: R R
Date: 23 Jun 2006 11:30 AM
Hello,

I am trying to comparing two nodes to get the position() in the main node list.
The code is as
<xsl:template name="Node-Num">
<xsl:param name="node-list"/>
<xsl:for-each select="books/book-item">
<xsl:if test=".= $node-list[1]" >
<xsl:value-of select="position()"/>
</xsl:if>
</xsl:for-each>
</xsl:template>

Basically the node values are compared.
But there is problem that if two or more nodes have the same value (like two nodes <book-item>some</book-item> and <book-item>some</book-item>)then it returns two or more values as the node values some and some are same.
Can any body advice me if I can use any other id in this case?

Thanks.

Postnext
Ivan PedruzziSubject: Comparing two nodes
Author: Ivan Pedruzzi
Date: 23 Jun 2006 12:13 PM
Try the following

<xsl:template name="Node-Num">
<xsl:param name="node-list"/>
<xsl:variable name="m" select="books/book-item[. = $node-list[1]]"/>
<xsl:for-each select="$m[1]">
<xsl:value-of select="position()"/>
</xsl:for-each>
</xsl:template>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
R RSubject: Comparing two nodes
Author: R R
Date: 23 Jun 2006 04:26 PM
Thanks for the advice.
Some how it did not work and I have the same problem.

Posttop
Ivan PedruzziSubject: Comparing two nodes
Author: Ivan Pedruzzi
Date: 23 Jun 2006 04:32 PM

Rather then by tentative, you should provide a full example (XML + XSLT) explain what you expect as output and describe which XSLT processor you have to use.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
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.