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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14622)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Replacing commas with a blank (6)
-> + Grouping very urgent . (2)
-> - xsl node number (3)
-> ->xsl node number
-> ->xsl node number
-> + Wordml intelligence (6)
-> + Preview and backmapping for wo... (5)
-> + XSLT - find line numbers of di... (2)
-> + The last five bytes of a varia... (7)
-> + simple problem but i'm a bit t... (3)
-> + H plz help me (2)
-> + XSLT : Very Urgent Requirement (7)
-> + comparing two xml files (3)
-> + Support for xsl created from w... (4)
-> + Wildcard Param (3)
-> + XSLT OutOfMemoryError (3)
-> + How can I output the filename ... (7)
-> + How do I strip out a comma ast... (8)
-> + xslt current-dateTime() not re... (2)
-> + Exceed the maximum recursion d... (8)
-> + Saxon9 "java.net.ConnectExcept... (2)
-> - Help Required (1)
-- Previous [601-620] [621-640] [641-660] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
jason gohSubject: xsl node number
Author: jason goh
Date: 27 May 2008 07:26 AM
Hi All,

I am a bit of a noob to Xpath & XSL and was wondering whether any of you could help me with a problem I've got. My xml structure looks like:

<nodeList>
<node id="c6"/>
<node id="c8"/>
<node id="c14"/>
</nodeList>
<linkList>
<link id="1" source="c6" target="c8">
<link id="2" source="c8" target="c14">
</linkList>

What I'd like to do is replace linkList/link/@source with the corresponding node position (e.g. 1,2,3) from nodeList.

i.e. something like
<xsl:for-each select="linkList/link">
<link id="1">
<xsl:attribute name="source">
<xsl:value-of select="../../linkList/link[@id=@source]"/>
</xsl:attribute>
</link>
</xsl:for-each)

The above value-of gets me to the node I require but to get the node number e.g. c6 -> 1, c8 -> 2 etc.
Also @source seems to need to have the full path which then ignores the for-each (always picks the first element).

Any help would be much appreciated!
Thanks,
Jason

Postnext
jason gohSubject: xsl node number
Author: jason goh
Date: 27 May 2008 08:54 AM
Found a couple of posts that pointed me in the right direction and managed to solve the problem:

to solve the 'losing' the current value of @source, stored it in a variable.
and to get the current node number, counted the preceding siblings + 1...

<xsl:variable name="sauce"><xsl:value-of select="@source"/></xsl:variable> <xsl:attribute name="From">
<xsl:value-of select="count(../../nodeList/node[@id=$sauce]/preceding- sibling::*)+1"/>
</xsl:attribute>

Posttop
Tony LavinioSubject: xsl node number
Author: Tony Lavinio
Date: 27 May 2008 08:54 AM
If you are a Stylus Studio user, could you please let us know your
product version number, so we may better help you?

If not, or for general XSLT questions not related to Stylus Studio
products, please see the xsllist run by Mulberry Technologies.

   
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.