RE: [xsl] acccessing and changing result tree nodes

Subject: RE: [xsl] acccessing and changing result tree nodes
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 9 Nov 2004 08:26:14 +0200
Hi,

> How do I access result tree nodes and change the value
> based upon some conditions?

You don't.

You can, however, generate a RTF, convert that into a node-set and then
process that.

> Normally all match or test attributes point to source
> tree.
>
> I have a situation where in the same xsl file, an
> attribute is being generated somewhere deep in the
> result tree. This attribute is also being copied from
> source tree to result in some other places in the
> tree. After all this processing is complete, I now
> must recheck the value of this attribute in the result
> tree (no matter where in the tree it occurs) and  if
> it is emtpy, make it equal to the value of another
> attribute that is also present in the same element and
> may have itself be generated anew or copied from
> source to result tree.

Are you sure you can't do this without two passes, be it using temporary tree
or actually with two transformations? It would probably require a lot more
tree navigation and re-doing some things just to generate the value of the
attribute, but often times it can be done.

> I know one way is to split the process into 2 stages
> and create a second xsl file but I am looking for
> above solution for performance reasones.

Doing two piped transformations can be faster than trying to do everything in
one go due to less tree navigation. Also, separating the transformation will
most likely make your stylesheets and logic more readable and maintainable. Of
course you have to implement the piped transformation, but it's fairly trivial
using e.g. JAXP (,thought it should be easier still).

Cheers,

Jarno

Current Thread