Subject: Re: [xsl] Grouping based on child value From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 5 Jun 2025 18:56:00 -0000 |
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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Grouping based on child value, rick@xxxxxxxxxxxxxx | Thread | Re: [xsl] Grouping based on child v, rick@xxxxxxxxxxxxxx |
[xsl] Grouping based on child value, rick@xxxxxxxxxxxxxx | Date | Re: [xsl] Grouping based on child v, rick@xxxxxxxxxxxxxx |
Month |