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

recursivly applying a transform to a result tree

Subject: recursivly applying a transform to a result tree
From: "M.A. Voetberg" <marco@xxxxxxxxxxxx>
Date: Sun, 8 Apr 2001 13:24:22 +0200
voetberg
Hi,

I'm fairly new at XSL/XSLT and so far it is impressive. But I am wondering
about one thing.

In short:

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 ?

The long version:

Recursivly applying a transform to a result tree fragment is basically
equivalant to recursing the transform with the result tree fragment as the
source and a new stylesheet for processing:

e.g.
================================================

<xsl:template match="A">
  <B>
    <C>
      <xsl:appy-templates />
    </C>
  </B>
</xsl:template>

applied to <A/> gives <B><C/></B>.

Suppose we introduce a new feature to XSLT something like this:

<xsl:template match="ModifyA">
  <xsl:apply-recursive>

    <xsl:transform-source>
      <xsl:apply-templates />
    </xsl:transform-source>

    <xsl:stylesheet>
      <xsl:template match="B/C">
        <D>
          <xsl:apply-templates />
        </D>
      </xsl:template>

    </xsl:stylesheet>
  </xsl:apply-recursive>
</xsl:template>

The xsl:transform-source is denotes the source for the recursive transform.
In this case the result tree fragment created from xsl:apply-templates is
used.
The xsl:stylesheet is used as normal.

applied to:

<ModifyA>
  <A/>
</ModifyA>

first the result tree fragment is created as normal from the children of
ModifyA:

<B>
<C/>
</B>

this is used as the source for the recursive transform which eventually
gives us:

<B>
<D/>
</B>

and this is copyied to the output.

================================================
Of course this behaviour can be "faked" by using two stylesheets. The first
we apply to the source
document and the second to the result of the first. But then we would need
to have a rule
in the first to make sure that the ModifyA element does not disappear.

I think something that looks like what I described above would make a
valuable addition to the language.
At least for some special types problems. It would (I think ?) be useful for
increased reusabiliy of a template.

I have been going over this process in my mind an I can find any reasing why
this recursive scenario would
not work. And I can't find another way for this effect to be achieved. But
perhaps I missing something here ?
It seems odd to have a language where everything is recursive except the
toplevel process and implementation wise it should be a breeze to
incorporate this.

I hope someone can help me with these questions ?

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