This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Finding another element with the same name as the current node
- To: xsl list <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] Finding another element with the same name as the current node
- From: Jo Bourne <venus at va dot com dot au>
- Date: Thu, 01 Feb 2001 23:39:05 +1100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello,
My xml document has two main "branches" and while processing elements in one
branch I need to find an element in the other branch with the same name and
extract the value of one of its attributes. Is there a way of finding the
name of the element currently being processed in a for-each loop and
inserting it as a variable within the loop?
Thanks
Jo
Sample page:
<page>
<branch1>
<child1>blah</child1>
<child2>blah</child2>
<child3>blah</child3>
</branch1>
<branch2>
<child1 att="x">blah</child1>
<child2 att="x">blah</child2>
<child3 att="x">blah</child3>
</branch2>
</page>
Sample for-each loop ("NAME_OF_CURRENT_ELEMEN" indicates where I think I
need to put the name of the current element as a variable):
<xsl:for-each select="child::*">
<tr>
<td><font face="Arial, Helvetica,
sans-serif"><xsl:apply-templates
select="//branch1/NAME_OF_CURRENT_ELEMENT"><xsl:value-of
select="@att"></xsl:apply-templates></font></td>
<td><font face="Arial, Helvetica,
sans-serif"><xsl:copy-of select="./*|./text()"/></font></td>
</tr>
</xsl:for-each>
--
Jo Bourne
Virtual Artists Pty Ltd
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list