Re: [xsl] Flat DB structure into XML Hierarchy

Subject: Re: [xsl] Flat DB structure into XML Hierarchy
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 29 Jan 2007 15:33:33 GMT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="2.0">

<xsl:output indent="yes"/>

<xsl:template name=" group" match="data">
<xsl:param name="r" select="row"/>
<xsl:param name="d" select="1"/>
<xsl:for-each-group select="$r" group-starting-with="*[section_depth=$d]">
  <section>
    <title><xsl:value-of select="section_title"/></title>
    <xsl:call-template name="group">
      <xsl:with-param name="r" select="current-group()[section_depth&gt;$d]"/>
      <xsl:with-param name="d" select="$d+1"/>
    </xsl:call-template>
  </section>
</xsl:for-each-group>
</xsl:template>

</xsl:stylesheet>


$ saxon8 dep.xml dep.xsl
<?xml version="1.0" encoding="UTF-8"?>
<section>
   <title>Home</title>
   <section>
      <title>Events</title>
      <section>
         <title>Event 1</title>
      </section>
      <section>
         <title>Event 2</title>
      </section>
   </section>
   <section>
      <title>Equipment</title>
   </section>
   <section>
      <title>News</title>
      <section>
         <title>News 1</title>
      </section>
      <section>
         <title>News 2</title>
      </section>
   </section>
</section>



David

Current Thread