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

Re: for-each-group for multiple nodes

Subject: Re: for-each-group for multiple nodes
From: "C. M. Sperberg-McQueen" <cmsmcq@xxxxxxxxxxxxxxxxx>
Date: Mon, 20 Jul 2009 13:50:11 -0600
Re:  for-each-group for multiple nodes
On 17 Jul 2009, at 03:36 , Ramkumar wrote:

...
I am not able to achieve my expected output through for-each-group for
multiple nodes in a single template match. Please look into my detailed
inputs and find mistakes in my below code.
...
xslt
=====
...


<xsl:template match="book">
<book>
 <xsl:for-each-group select="*"
group-starting-with="para[contains(@aid:pstyle,'Level')]">

If the sample input you showed is typical, this is equivalent to

<xsl:for-each-group select="*" group-starting-with="para"/>

I think that since you want each LevelF para to generate a
distinct qandaset element in the output, you might think
about whether you really want a distinct group for every
para, or just a distinct group for every sequence of elements
beginning with para aid:pstyle="LevelF".



  <xsl:choose>
	    <xsl:when test="self::para/@aid:pstyle[contains(.,'LevelF')]">
	     <qandaset>
	      <xsl:call-template name="g">
	       <xsl:with-param name="e" select="current-group()"/>
	      </xsl:call-template>
	     </qandaset>
	    </xsl:when>

The code above seems to expect that the current-group() will contain the following LevelM and LevelM_sub para elements. It won't: each time the input contains a new para element with contains(@aid:pstyle,'Level'), a new group will be started. So your Level M paragraphs and their subordinate parts will be in the next group, not this one.

As a first step, try to get the outermost grouping to work;
don't worry about the inner groupings.  Since you want
each LevelF paragraph to produce an element containing its
following siblings up to but not including the next level
F paragraph, you want a grouping based on the LevelF value,
not on the string 'Level'.

Within those groups, you may want to make use of recursive
groupings for Level M.

I hope this helps; if it does not help sufficiently, please ask
again.

Michael Sperberg-McQueen

--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************

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.