Re: [xsl] recursivly applying a transform to a result tree

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



(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().

 xmlns:xsl=""; version="1.0"

<xsl:template match="a[@depth=0]">
   <a><xsl:copy-of select="child::node()"/></a>

<xsl:template match="a[@depth>0]">
   <xsl:variable name="tree">
      <a depth="{@depth - 1}">
          <x><xsl:copy-of select="node()"/></x>
   <xsl:apply-templates select="$tree"/>


Is this of any help?

Trevor Nash

 XSL-List info and archive:

Current Thread