Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refer to attrib of current node for-each called from

Status
Not open for further replies.

codestorm

Programmer
Apr 11, 2001
504
AU
Ran a search on forum & FAQs here for 'for-each' - would you believe actually NO results!

Anyway, my problem is this:

(example XML)
<root>
<node id=&quot;1&quot; nodeid=&quot;100&quot;>
<node id=&quot;2&quot; nodeid=&quot;103&quot;>
</node>
</node>
<text name=&quot;Rating1&quot;>Poor</text>
<text name=&quot;Rating2&quot;>Unsatisfactory</text>
<text name=&quot;Rating3&quot;>Average</text>
<text name=&quot;Rating4&quot;>Good</text>
<text name=&quot;Rating5&quot;>Excellent</text>
</root>

Now say I'm within a template for <node> within an XSL document, and I run something like:

<xsl:for-each select=&quot;/root/text[substring(@name, 1, 6) = 'Rating']&quot;>
...

I need to be able to from within the for-each, refer to the @nodeid of the <node> I was in when I called for-each. I tried and as expected could not feed the for-each a parameter. How to solve?


codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
Never mind, I figured it out.

Instead of using for-each I simply made another template to handle <text> nodes, and fed @nodeid into it as a param.

codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top