| Subject: [xsl] xsl:for-each-group: start groups depending on number of  group members? From: Yves Forkl <Y.Forkl@xxxxxx> Date: Fri, 27 Apr 2007 19:18:26 +0200 | 
<root> <A/> <sub>a1</sub> <B/> <sub>b1</sub> <sub>b2</sub> <sub>b3</sub> <C/> <sub>c1</sub> <sub>c2</sub> </root>
<B_new> <sub_new>b1</sub_new> <sub_new>b2</sub_new> <sub_new>b3</sub_new> </B_new>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:template match="/">
    <xsl:for-each-group
      select="root/*"
      group-starting-with="A|B|C">
      <xsl:apply-templates
        select="current-group()[1]"
        mode="groups_at_root_level"/>
    </xsl:for-each-group>
  </xsl:template><!-- don't care for them now --> <xsl:template match="A|C" mode="groups_at_root_level"/>
  <xsl:template match="B" mode="groups_at_root_level">
    <B_new>
      <xsl:variable name="items_total" select="count(current-group())"/>
      <xsl:for-each-group
        select="current-group()"
        group-starting-with="
          B|
          sub[not(
            preceding-sibling::*[position() lt $items_total][A])]">
        <xsl:apply-templates select="current-group()"/>
      </xsl:for-each-group>
    </B_new>
  </xsl:template>  <xsl:template match="sub">
    <sub_new>
      <xsl:apply-templates/>
    </sub_new>
  </xsl:template>| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] XSL to ODF/OOXML, David Carlisle | Thread | Re: [xsl] xsl:for-each-group: start, Wendell Piez | 
| [xsl] XSL to ODF/OOXML, Steve | Date | RE: [xsl] XSL to ODF/OOXML, cknell | 
| Month |