position() of the parent

Subject: position() of the parent
From: "Alexandru-Ionut Albu" <albu@xxxxxxxxxxxx>
Date: Wed, 19 Jan 2000 16:59:47 -0500

I am new to XML and I am trying to write an XSL sheet that "flattens" the source XML tree, but preserves information about child-parent relationships. For example:

<mynode name="xxx">
    <mynode name="yyy">
        <mynode name="zzz">

should become

<mynode name="xxx" id="1" parentid=""/>
<mynode name="yyy" id="2" parentid="1"/>
<mynode name="zzz" id="3" parentid="2"/>

I don't really care what the data type of the id's is.

I've tried something like:

<xsl:template match="mynode">
    <mynode name="{@name}">
    <xsl:attribute name="id">
         <xsl:value-of select="position()"/>

but I don't know how to apply the position() function to the parent node.

Thank you,

LYCOShop. Thousands of products!  One location!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread