homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

How do I use a variable within a path?
xsl path variable

5+ Year Member

Msg#: 4006937 posted 4:13 pm on Oct 14, 2009 (gmt 0)

Hello, I am still new to xml and have ran into a slump with the following code.

<xsl:template name="compare">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:for-each select="../../client">
<xsl:value-of select="roam[$count]/@timing"/>
THIS STILL WORKS- <xsl:value-of select="$count"/>

<xsl:template match="/">
<table border="0" width="800px">
<xsl:for-each select="test/run/security/testCase/client[1]/roam">
<xsl:call-template name="compare">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="count"><xsl:number/></xsl:with-param>

A sample of my xml is:

<?xml version="1.0" encoding="iso-8859-1"?>
<testCase id="Roam Test" len="20" num="10">

<client id="0">
<roam timing="11"></roam>
<roam timing="12"></roam>
<roam timing="13"></roam>
<roam timing="14"></roam>
<roam timing="15"></roam>

<client id="1">
<roam timing="21"></roam>
<roam timing="22"></roam>
<roam timing="23"></roam>
<roam timing="24"></roam>
<roam timing="25"></roam>


What I am looking for is it to create a column for client 1 and 2 with each row being a new roam. however even though count can be properly show with...

<xsl:value-of select="$count"/>


<xsl:value-of select="roam[2]/@timing"/>

will select the second roam for each client...

<xsl:value-of select="roam[$count]/@timing"/>

will always display the first roams for both clients. Is there an easy syntax fix or a work around for this? Thanks in advanced!



5+ Year Member

Msg#: 4006937 posted 5:05 pm on Oct 14, 2009 (gmt 0)

Of course after spending half a day looking for this, then swallowing my pride and asking for help if just figured it out...

<xsl:value-of select="roam[position()=$count]/@timing"/>

was what I was looking for


WebmasterWorld Administrator httpwebwitch us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4006937 posted 1:12 pm on Oct 15, 2009 (gmt 0)

Right on sdcDan, that's how it's done. Thanks for posting the solution too, it will help others with the same problem who find this post.

Welcome to WebmasterWorld!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved