[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: "M.A. Voetberg" <marco@xxxxxxxxxxxx>
Date: Mon, 9 Apr 2001 13:24:30 +0200
xml apply templates
> 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().
>
> Is this of any help?
>
> Regards,
> Trevor Nash

Thanks,

This does help. At least I can get my example to work with:

<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="a">
  <b><c>
    <xsl:apply-templates />
  </c></b>
</xsl:template>

<xsl:template match="modifyA>
  <xsl:variable name="tree">
    <xsl:apply-templates/>
  </xsl:variable>
  <xsl:apply-templates select="$tree" />
</xsl:template>

<xsl:template match="b/c">
  <d>
    <xsl:apply-templates />
  </d>
</xsl:template>

</xsl:stylesheet>

So that <a/> gives <b><c/><b>,
and <modifyA><a/></modifyA> gives <d />

But this gives the next problem that if the input already has b/c it also
will be transformed to <d />. This
I solved by using mode="tree" in the <xml:apply templates select="$tree" />
and the
<xsl:templates match="b/c">.

It works, but I'm not really charmed about the solution. I also read
something in the XSLT1.1 spec that the result tree fragments were going to
be removed ? But I'm not sure (I'm not getting any response from
w3c.org so I can't look it up). If they remove this feature, I hope they
will add a slightly more elegant way to apply templates to result tree
fragment.

Regards,

Marco Voetberg



 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.