xsl-list
[Top] [All Lists]

Re: XSL and DOM

2003-06-11 11:03:17
Paramdeep Ahuja wrote:

Hi

XSL transforms a source DOM tree into a target DOM Tree separate from the
source...Is it possible to apply the transformation on only a part of the
source DOM Tree and the changes be done in the same tree itself rather than
create a new DOM Tree as XSLT does...I wanted to know if this can be done
through some tool developed in Xalan C++


Thnx
Param



XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

If you are trying to do this using an XSLT library (as opposed to a command line utility) Apache Xalan allows you to apply a transformation to a sub-tree of the DOM tree. However, the root tree is not modified but you can simulate this behaviour as such:

1. If the subtree(s) that you want to modify are not *all* the children of a node, create
a document fragment and copy/move them there.
2. Apply the transformation using the document fragment as root (or to the root of the nodes
if (1) doesn't hold)
3. Replace the initial nodes in the source tree with the result (which will normally be the
children of another document fragment that you provide)

There are two catches in this:
1st) It's dead slow
2nd) The "/" construct in XSLT always applies to the root of the document and not the root that you specifiy during the transformation function call. So, your stylesheets should
only use relative constructs.

I'm using this techniques a lot since we have implemented a transformation engine that among others handles subtrees individually. If anyone has a better solution (faster) please
let me know!

Hope this helps,

Mike.


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>