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

Re: Grouping based on child value

Subject: Re: Grouping based on child value
From: "Terry Badger terry_badger@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Jun 2025 19:29:44 -0000
Re:  Grouping based on child value
Slight change
B <xsl:template match="root">
B  B  B  B  <xsl:copy>
B  B  B  B  B  B  <xsl:for-each-group group-starting-with="record[col1[. =
'PG']]" select="record">
B  B  B  B  B  B  B  B  <group>
B  B  B  B  B  B  B  B  B  B  <xsl:copy-of select="current-group()"/>
B  B  B  B  B  B  B  B  </group>
B  B  B  B  B  B  </xsl:for-each-group>
B  B  B  B  </xsl:copy>
B  B  </xsl:template>

Terry Badger






On Thursday, June 5, 2025 at 02:56:28 PM EDT, Martin Honnen
martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:









On 05/06/2025 20:49, rick@xxxxxxxxxxxxxx wrote:


>B B 
> Here is my XML:
>
>B B B 
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <root>
>
> B B B  <record>
>
> B B B B B B B  <col1>PG</col1>
>
> B B B  </record>
>
> B B B  <record>
>
> B B B B B B B  <col1>1</col1>
>
> B B B  </record>
>
> B B B  <record>
>
> B B B B B B B  <col1>2</col1>
>
> B B B  </record>
>
> B B B  <record>
>
> B B B B B B B  <col1>PG</col1>
>
> B B B  </record>
>
> B B B  <record>
>
> B B B B B B B  <col1>3</col1>
>
> B B B  </record>
>
> B B B  <record>
>
> B B B B B B B  <col1>4</col1>
>
> B B B  </record>
>
> </root>
>
>B B B 
>
> I want to group all of the <record> elements, starting with
col1[starts-with(.,bPGb)]. I am expecting 2 groups of 3 record elements
each.
>




A variant of your code with e.g.

B B B  <xsl:template match="root">

B B B B B B B  <xsl:copy>


B B B B B B B B B B B  <xsl:for-each-group select="record"
group-starting-with="record[col1[.='PG']]">

B B B B B B B B B B B B B B B  <group></group>

B B B B B B B B B B B  </xsl:for-each-group>

B B B B B B B  </xsl:copy>

B B B  </xsl:template>

would do that. Remember, the group-starting-with is a pattern the element to
start a group has to match.




B B XSL-List info and archive
EasyUnsubscribe (by email)

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.