<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="node()/node()[not(name() = '')]">
<xsl:text>'</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>'</xsl:text>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:for-each select="node()/node()/node()[not(name() = '')]"> <xsl:text>'</xsl:text> <xsl:value-of select="name()"/> <xsl:text>'</xsl:text> <xsl:text>
</xsl:text> </xsl:for-each> <xsl:text>
</xsl:text>
<xsl:for-each select="node()/node()/node()/node()[not(name() = '')]"> <xsl:text>'</xsl:text> <xsl:value-of select="name()"/> <xsl:text>'</xsl:text> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
The output is:
'b' 'e'
'c' 'f'
'd' 'g'
Please note: 1) Predicate "[not(name() = '')]" is required to skip text nodes. 2) Retrieving names of nodes of a 'certain' depth could be achieved by using a recursively called template (parameter: depth)
Regards,
Johannes
Joseph Kesselman wrote:
"Siblings" was my first reaction too (the sibling axes and/or children-of-same-parent). However, if one takes a deeper "slice", nodes at the same depth may not actually be siblings. For example, see C and E in:
<a> <b> <C/> </b> <d FOO="bar"> <E/> </d> </a>
If that's what's intended, I'm not sure what the best XPath expression would be. One approach is "nodes with same number of ancestors as this one", but you'd need to think about whether the attribute FOO is considered part of the same slice as C and E.
______________________________________ Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. "The world changed profoundly and unpredictably the day Tim Berners Lee got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk