[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Encompassing Element extraction
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|