This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: how to walk nodes
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] how to walk nodes
- From: Jörg Heinicke <joerg dot heinicke at gmx dot de>
- Date: Thu, 13 Sep 2001 21:02:11 +0200
- References: <07D07AD1C8CAD4119B0900D0B7E7E8E0649A9E@UHURA>
- Reply-To: xsl-list at lists dot mulberrytech dot com
<xsl:template match="some_node">
<xsl:for-each select="ancestor::*">
<xsl:value-of select="name()"/>
<xsl:if test="position()!=last()">
<xsl:text>/</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
or if you only want all components and the @name of them:
...
<xsl:for-each select="ancestor::component">
<xsl:value-of select="@name"/>
...
Regards,
Joerg
----- Original Message -----
From: "Dmitri Ilyin" <dmitri.ilyin@memIQ.com>
To: "XSL-List@lists. mulberrytech. com (E-mail)"
<XSL-List@lists.mulberrytech.com>
Sent: Thursday, September 13, 2001 5:32 PM
Subject: [xsl] how to walk nodes
> Hi *,
>
> I'd like to build a template that gives me "path" of parent nodes
> for example:
>
> XML
> <components>
> <component name="comp1">
> <some_node1>
> <component name="comp2">
> </component>
> </some_node1>
> <some_node2>
> <some_node3>
> <component name="comp3">
> <some_node>
> </component>
> </some_node3>
> </some_node2>
> </component>
> </components>
>
> XSL
> <xsl:template match="some_node">
> hier walk through parent nodes
> </xsl:template>
>
> output:
>
> "comp1/comp3"
>
> all parent nodes are named "component" and can not be children of each
other
>
> thanks for advise
>
> Dmitri
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list