cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Manfred Knobloch)
Subject Re: xsl problem: converting rows to a hierarchy
Date Mon, 04 Sep 2000 12:56:30 GMT schreibt:
>	<row>apple</row>
>	<row>orange</row>
>	<row>banana</row>
>	<row>grape</row>
>I'd like to put them in a hierarchy:

think that would do, idea taken from XSLT Programmers reference by M. Kay
p.172, who shows
a similar example about list processing. 
The trick is to call a named template recursivly. 
This template cracks up the list in first and rest (car/cdr in lisp
speaking). First is given to
the output and rest is passed to the template as parameter again.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

	<xsl:template match="rows">
			<xsl:call-template name="stepin">
				<xsl:with-param name="listofnodes" select="row"/>

	<xsl:template name="stepin">
		<xsl:param name="listofnodes"/>
		<xsl:if test="$listofnodes">
                    <xsl:value-of select="$listofnodes[1]" />
				<xsl:call-template name="stepin">
					<xsl:with-param name="listofnodes"


Manfred Knobloch

Kompetenzzentrum für Multimedia und Telematik
Konrad Adenauer Str. 40
72072 Tübingen

tel: ++49 (0)7071 / 979 232
fax: ++49 (0)7071 / 979 322

View raw message