Re: odd NodeSet behavior

Adam Jenkins <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
>>XPath which gathers those nodes
>>Try to avoid the temptation to force XSLT into using stateful 
non-XSLT objects

Yep, understood, unfortunately the 'best practice' way of doing what I need to do (large multi document xslt processing block) is just way too memory intensive due to recursion requirements.

We initial had a standard solution as you suggest, which worked fine, but required over 3Gb of memory! 

The one big draw back of XSLT is crappy recursion.

But thanks for the suggestion :)

--- On Tue, 21/4/09, [email protected] <[email protected]> wrote:

From: [email protected] <[email protected]>
Subject: Re: odd NodeSet behavior
To: 
Cc: [email protected]
Received: Tuesday, 21 April, 2009, 10:51 AM

> Then, when I had to collect a range of different nodes to work with
> (kind of like a preprocessing step) I created one directly and added
> nodes to it.  They added correctly, however I can no longer use
> xsl:for-each.

> <xsl:variable name="nodebucket"
> select="java:org.apache.xpath.NodeSet.new()"/>

A more idiomatic and more portable approach would be to write an XPath 
which gathers those nodes, assign that into a variable, then use the exslt 
nodeset function to make that variable accessible as an XSLT node set 
which you could then for-each over.

General tip: Try to avoid the temptation to force XSLT into using stateful 
non-XSLT objects. Remember that order of execution of a stylesheet is not 
guaranteed; optimizers may rearrange things. At best, relying on 
extensions may hamstring optimization; at worst, they may not be executed 
in the order you expect. You may get away with it in one release of a 
processor only to have it behave correctly-but-differently in the next 
release. In most cases, there really are XSLT-native ways of saying the 
same things, or ways which need only the well-standardized exslt 
extensions.



______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)



      Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.