xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Finding another element with the same name as the current node


Subject: [xsl] Finding another element with the same name as the current node
From: Jo Bourne <venus@xxxxxxxxx>
Date: Thu, 01 Feb 2001 23:39:05 +1100

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



Current Thread
Keywords
xml
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor