[Home] [By Thread] [By Date] [Recent Entries]
At 2013-05-13 20:29 -0700, Dimitre Novatchev wrote:
So here is the complete solution to this problem, using XSLT 3.0: Thank you, Dimitre, for taking the time to polish up the data ... I didn't have the time. I implemented the untested code from yesterday and found that Ihe's use of the descendent:: axis was insufficient to detect differences between two siblings. That was easily corrected in the XSLT 2.0 solution below that produces the identical serialized result as yours. I hope this helps readers of the archive. . . . . . . . . . Ken
T:\ftemp>call xslt2 ihe.xml ihe.xsl
<group>
<B>
<C/>
<D/>
</B>
<B>
<C/>
<D/>
</B>
</group>
<group>
<B/>
</group>
<group>
<C/>
</group>
<group>
<D>
<E/>
<E>
<F/>
</E>
</D>
<D>
<E/>
<E>
<F/>
</E>
</D>
</group>
<group>
<B>
<C/>
<D/>
</B>
<B>
<C/>
<D/>
</B>
</group>T:\ftemp>type ihe.xsl <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/*"> <xsl:for-each-group select="*"
group-adjacent="string-join(descendant-or-self::*/
concat(local-name(),'$',count(ancestor::*)),' ')">
<group>
<xsl:sequence select="current-group()"/>
</group>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>T:\ftemp>rem Done!
|

Cart



