Subject: [xsl] recursivly applying a transform to a result tree From: "M.A. Voetberg" <marco@xxxxxxxxxxxx> Date: Sun, 8 Apr 2001 13:24:22 +0200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSLT/Java implementer que, Tobias Reif | Thread | Re: [xsl] recursivly applying a tra, Trevor Nash |
RE: [xsl] XSLT/Java implementer que, Tobias Reif | Date | [xsl] determine node position, Kristof Bernaert |
Month |