cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: xsl problem: converting rows to a hierarchy
Date Sat, 02 Sep 2000 18:36:04 GMT
Steve Conover <sconover@groundswell.net> wrote:
>Another recursion problem:
>
>Given a set of rows
>
><rows>
>	<row>apple</row>
>	<row>orange</row>
>	<row>banana</row>
>	<row>grape</row>
></rows>
>
>I'd like to put them in a hierarchy:
>
><item>
>	apple
>	<item>
>		orange
>		<item>
>			banana
>			<item>
>				grape
>			</item>
>		</item>
>	</item>
></item>
>
>Any suggestions?  I haven't dealt with coding my own recursion in xsl yet 
>so
>it's kinda hard to know where to start.

I haven't tried this but it's probably along the right lines:


<xsl:template match="rows">
  <xsl:apply-templates select="row[position()=1]"/>
</xsl:template>

<xsl:template match="row">
  <item>
    <xsl:value-of select="."/>
    <xsl:apply-templates select="following-siblings::row[position()=1]"/>
  </item>
</xsl:template>


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Mime
View raw message