|
[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
>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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








