Subject: Re: [xsl] recursivly applying a transform to a result tree From: tcn@xxxxxxxxxxxxx (Trevor Nash) Date: Sun, 08 Apr 2001 15:49:56 GMT |
>The language is completly recursive by nature and obviously so is an >implementation of the transform. >But something strikes me as being very odd. Why are there no facilities for >recursivly applying a transform to a result tree fragment ? Is this a design >philosophy or perhaps a omission cq flaw ? Is this the sort of thing you have in mind: given <a depth="n"/> the following transform yields an <a> element with n nested <x> elements, e.g. <a depth=3/> gives <a><x><x><x/></x></x></a> (its not supposed to be useful, just to demonstrate). This works with processors which support XSLT1.1, for example with Saxon 6.2.2. NB, XSLT 1.1 is not a recommendation yet. For other processors you may be able to use the extension function node-set(). <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="a[@depth=0]"> <a><xsl:copy-of select="child::node()"/></a> </xsl:template> <xsl:template match="a[@depth>0]"> <xsl:variable name="tree"> <a depth="{@depth - 1}"> <x><xsl:copy-of select="node()"/></x> </a> </xsl:variable> <xsl:apply-templates select="$tree"/> </xsl:template> </xsl:stylesheet> Is this of any help? Regards, Trevor Nash XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] recursivly applying a transfo, M.A. Voetberg | Thread | Re: [xsl] recursivly applying a tra, M.A. Voetberg |
[xsl] determine node position, Kristof Bernaert | Date | [xsl] Re: XSL Path/Context problem, Marji_Berkman |
Month |