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

Re: two-level grouping xslt 2.0

Subject: Re: two-level grouping xslt 2.0
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 29 Feb 2008 14:28:51 +0100
Re:  two-level grouping xslt 2.0
Terry Ofner wrote:
Your two template rules work well. However, I think I have managed to misrepresent the problem--one of the main pitfalls of submitting queries, it seems.

The problem is this: The <story-title> element is the opening element of a "story" (as opposed the <story> element which is courtesy of the xhtml export from InDesign). At any rate, each "story" is composed of multiple elements such as <story>, <page>, and <imggroup>. That is why I am trying to execute a two-level grouping rule. The outer for-each-group should structure the <level1 class="unit"> hierarchy; the inner for-each-group should structure the <level2 class="selection">.

This stylesheet should do:


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">

<xsl:output method="xml" indent="yes"/>

<xsl:strip-space elements="*"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

<xsl:template match="bodymatter">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each-group
select="*"
group-starting-with="story[cluster_num]">
<level1 class="unit" unitnum="{position()}">
<xsl:for-each-group
select="current-group()"
group-starting-with="story[story-title]">
<xsl:choose>
<xsl:when test="current-group()[1][self::story[story-title]]">
<level2 class="selection">
<xsl:apply-templates select="current-group()"/>
</level2>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</level1>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

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-2011 All Rights Reserved.