xsl-list
[Top] [All Lists]

Re: [xsl] Flat DB structure into XML Hierarchy

2007-01-29 08:34:02
<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


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

<Prev in Thread] Current Thread [Next in Thread>