[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Removing hierarchy
rowan@xxxxxxxxxxxxxxxxxxxxx wrote:
I've got an input file like this: <items> <item> <a>abc</a> <b>def</b> <item> <a>ghi</a> <b>jkl</b> </item> <item> <a>mno</a> <b>pqr</b> <item> <a>stu</a> <b>vwx</b> </item> </item> </item </items Here is an XSLT 1.0 way: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:template match="items"> <xsl:copy> <xsl:apply-templates select="descendant::item"/> </xsl:copy> </xsl:template> <xsl:template match="item"> <xsl:copy> <level><xsl:value-of select="count(ancestor::item)"/></level> <xsl:copy-of select="*[not(self::item)]"/> </xsl:copy> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|