[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: nested grouping problem using group-adjacent

Subject: Re: nested grouping problem using group-adjacent
From: Jeff Hatch <hatchjk@xxxxxxxxxxxxx>
Date: Wed, 18 Apr 2007 10:33:20 -0600
Re:  nested grouping problem using group-adjacent
Thanks, David. This works well and provides a framework for similar tasks to come.

Jeff Hatch
Electronic Media Group
Curriculum Department
Church of Jesus Christ of Latter-day Saints
hatchjk@xxxxxxxxxxxxx



On Apr 18, 2007, at 10:22 AM, David Carlisle wrote:


<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&gt;$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>



----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.