xsl-list
[Top] [All Lists]

RE: Grouping - starting with certain element and ending before certain elements

2005-10-05 05:34:35
So I want to keep the order of all elements but group each <IDM>
element followed by a number of siblings up to another <IDM>, a <LV2>
or a <LV3> element and wrap this sequence in a <phrase> section. 


The XSLT 2.0 solution that comes to mind is:

<xsl:for-each-group group-starting-with="IDM|LV2|LV3">
  <xsl:choose>
  <xsl:when test="self::IDM">
    <phrase>
      <xsl:copy-of select="current-group()"/>
    </phrase>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="current-group()"/>
  </xsl:otherwise>
  </xsl:choose>
</xsl:for-each-group>

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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--