xsl-list
[Top] [All Lists]

Re: [xsl] flatened hiearchies for xslt2

2007-03-07 10:26:50

This is a classic for-each-group example:


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="section" name="group">
    <xsl:param name="s" select="section"/>
    <xsl:param name="l" select="1"/>
   <xsl:for-each-group select="$s" group-starting-with="*[(_at_)level=$l]">
     <section id="{(_at_)id}">
       <xsl:call-template name="group">
         <xsl:with-param name="s" select="current-group()[position()!=1]"/>
         <xsl:with-param name="l" select="$l+1"/>
       </xsl:call-template>
     </section>
   </xsl:for-each-group>
  </xsl:template>
</xsl:stylesheet>


 saxon8 fl.xml fl.xsl \!indent=yes
<?xml version="1.0" encoding="UTF-8"?>
<section id="1">
   <section id="1-1"/>
   <section id="1-2">
      <section id="1-2-1"/>
      <section id="1-2-2"/>
   </section>
</section>
<section id="2"/>


David


--~------------------------------------------------------------------
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>
--~--