[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: recursivly applying a transform to a result tree

Subject: Re: recursivly applying a transform to a result tree
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Sun, 08 Apr 2001 15:49:56 GMT
nash transform
>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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.