Re: [xsl] help in xslt2 grouping

Subject: Re: [xsl] help in xslt2 grouping
From: "alex v." <alex.vett@xxxxxxxxx>
Date: Fri, 6 Jul 2007 15:49:27 +0200
So what happened to row6?
sorry, a copy/paste mistake.

<root>
<elem>
<title>row1</title>
<content>row2</content>
</elem>
<elem>
<title>row3</title>
<content>row4</content>
<content>row5</content>
<content>row6</content>
</elem>
</root>


2007/7/6, Michael Kay <mike@xxxxxxxxxxxx>:
So what happened to row6?

I imagine what you probably want is

<xsl:template match="root">
  <xsl:for-each-group select="*" group-starting-with="elem[title]">
    <xsl:copy-of select="title"/>
    <xsl:for-each select="current-group()[position() gt 1]">
      <content><xsl:value-of select="."/></content>
    </
  </
</


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

> -----Original Message-----
> From: alex v. [mailto:alex.vett@xxxxxxxxx]
> Sent: 06 July 2007 13:20
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] help in xslt2 grouping
>
> hi all,
> I need to group in XSLT2 'elem' that have a child 'title'.
> The XML is:
>
> <root>
>  <elem><title>row1</title></elem>
>  <elem>row2</elem>
>  <elem><title>row3</title></elem>
>  <elem><title>row4</title></elem>
>  <elem>row5</elem>
>  <elem>row6</elem>
> </root>
>
>
> and the result:
>
> <root>
> <elem>
>   <title>row1</title>
>   <content>row2</content>
> </elem>
> <elem>
>   <title>row3</title>
>   <content>row4</content>
>   <content>row5</content>
> </elem>
> </root>
>
> I use Saxon and XSLT2.
>
> Regards,
> alex.
> ~alex




--

~alex

Current Thread