[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] outputting unknown amount of child elements
Subject: Re: [xsl] outputting unknown amount of child elements From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 9 Feb 2004 13:02:22 +0000 |
Hi David, > I should have stressed that not only do I want to ouput all the > elements using recursion but I also want, effectively to know how > many ancestors they each have in order to structure the output so it > makes clear the hierarchical structure of the data. You can do that in two ways. You can count the number of ancestors of the <item> element that you're on using: count(ancestor::item) Alternatively, you can pass a parameter into the template, adding one on each recursion, as in: <xsl:template match="item"> <xsl:param name="ancestors" select="0" /> ... <xsl:apply-templates> <xsl:with-param name="ancestors" select="$ancestors + 1" /> </xsl:apply-templates> </xsl:template> If you're dealing with very deep hierarchies, using a parameter will probably be speedier. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] outputting unknown amount, David Elsmore | Thread | [xsl] Fwd: [XSLT2.0] Binding of a l, Dimitre Novatchev |
Re: [xsl] outputting unknown amount, David Elsmore | Date | [xsl] document() function not worki, Markus Gamperl |
Month |