Subject: Re: [xsl] Encompassing Element extraction From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 16 Oct 2006 17:38:13 +0100 |
If you can use xslt2 then it's just <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/*"> <xsl:for-each-group select=".//*" group-by="string-join(ancestor-or-self::*/name(),'/')"> <xsl:value-of select="' (',count(current-group()),') ',current-grouping-key()" separator=""/> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> which (if you put <x>...</x> around your posted input to make it well formed) produces: $ saxon8 depth.xml depth.xsl <?xml version="1.0" encoding="UTF-8"?> (2) x/a1 (2) x/a1/b1 (2) x/a1/b1/c1 (1) x/a1/b1/c2 (1) x/a1/b1/c3 (2) x/a1/b2 (1) x/a1/b2/c2 (1) x/a1/b2/c3 (2) x/a1/b3 (1) x/a1/b3/c1 (1) x/a1/b3/c4 David
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Encompassing Element extracti, mhbush | Thread | [xsl] Where did my tabs go? Trying , Abel Braaksma |
Re: [xsl] Rename Some Node and attr, Mukul Gandhi | Date | Re: [xsl] Rename Some Node and attr, Abel Braaksma |
Month |