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

RE: grouping problem

Subject: RE: grouping problem
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 16 Apr 2010 00:04:03 +0100
RE:  grouping problem
> Here is the basic grouping 2.0 template (xsl:attribute 
> elements have been removed) in which I am trying to group the 
> @class='bodytext- question and @class=bodytext-choice elements:
> 
>   <xsl:template match="testbody">
>            <testbody>
>                 <xsl:for-each-group select="*" 
> group-starting-with="p 
> [@class=('bodytext-question','bodytext-questionfirst')]">
> 
> This template works for bodytext-questions that are followed 
> by other bodytext-questions. But it also groups everything 
> from the start of <testbody> to the first bodytext-question 
> as well as everything that follows the last of a series of 
> bodytext-questions.

Every node selected by select="*" will end up in exactly one group. 

For the nodes preceding the first "matching" node, the usual strategy is to
ungroup them again (or to do some other special processing on them)
typically by testing within xsl:for-each-group whether the first item in the
group does indeed match the group-starting-with pattern. As for "everything
that follows the last of a series of bodytext-questions", it's not clear to
me from your example what this means, but the last group is going to take in
everything from the last bodytext-question to the end, and you're going to
have to include logic to break it up if necessary.

I don't know whether this works in your case, but one technique of course is
to replace select="*" by a more specific select that only contains the nodes
you want in the output.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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.