[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: nested grouping problem using group-adjacent
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="objects" name="objects"> <xsl:param name="o" select="object"/> <xsl:param name="d" select="1"/> <xsl:for-each-group group-adjacent="@depth>$d" select="$o"> <xsl:choose> <xsl:when test="current-grouping-key()"> <xsl:element name="group-{$d}"> <xsl:call-template name="objects"> <xsl:with-param name="o" select="current-group()"/> <xsl:with-param name="d" select="$d+1"/> </xsl:call-template> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> $ saxon8 ob.xml ob.xsl \!indent=yes <?xml version="1.0" encoding="UTF-8"?> <object depth="1">data</object> <object depth="1">data</object> <group-1> <object depth="2">data</object> <object depth="2">data</object> <group-2> <object depth="3">data</object> <object depth="3">data</object> <object depth="3">data</object> </group-2> <object depth="2">data</object> <object depth="2">data</object> </group-1> <object depth="1">data</object> <group-1> <object depth="2">data</object> </group-1> <object depth="1">data</object>
|
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
|