Brian Schroeder <> writes:
> I've got the following situation:
>
> === a.xml ===
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <n categorie="A">
> <n categorie="B">
> <n categorie="C"/>
> </n>
> <n categorie="D"/>
> </n>
> ===
>
> I want to transform this via xslt to the following
>
> A
> A->B
> A->B->C
> A->D
Further to your other replies, rather than use the ancestor axis this
kind of thing is generally done more naturally in XSLT with recursion.
This stylesheet (I know it doesn't look more elegant at first sight,
but recursion is much nicer, honestly) produces the output you desire:
<xsl:stylesheet version="1.0" xmlns

sl="http://www.w3.org/1999/XSL/Transform">
<xsl

utput method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="n"/>
</xsl:template>
<xsl:template match="n">
<xsl

aram name="prefix"/>
<!-- update the prefix -->
<xsl:variable name="current">
<xsl:choose>
<xsl:when test="$prefix">
<xsl:value-of select="concat($prefix,'->',@categorie)"/>
</xsl:when>
<xsl

therwise>
<xsl:value-of select="@categorie"/>
</xsl

therwise>
</xsl:choose>
</xsl:variable>
<!-- output the new prefix -->
<xsl:value-of disable-output-escaping="yes" select="$current"/>
<xsl:text>
</xsl:text> <!-- a newline -->
<!-- recursively treat my child-nodes -->
<xsl:apply-templates select="n">
<xsl:with-param name="prefix">
<xsl:value-of select="$current"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/