|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping based on child value
On 05/06/2025 20:49, rick@xxxxxxxxxxxxxx wrote: > > Here is my XML: > > <?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> > > 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








