Hi,

I'm writing a stylesheet that needs to maintain a global state of variables
during transformation. I wrote an extension to Xalan in Java to maintain
this state through simple 'get' and 'set' functions.
Now, I wanted to retrieve that state as a node-set in order to do something
like this:

<xsl:template name="apply-current-state">
  <xsl:for-each select="ext:getState()">
    ... do something with state
  </xsl:for-each>
</xsl:template>

The state is maintained as a node-set that is manipulated in my Java-class.
My extension is implemented along these lines:

public Node getState ()
{
  return fStateNode; // fStateNode is actually an Element;
}

Now comes the problem: if I do it as shown above, every application of
'apply-current-state' results in the *same state*; even when it has been
altered in the meantime. I figure this is because Xalan thinks I am
returing the same node over and over again, without knowing that I have
altered it.

That's why I tried:
public Node getState ()
{
  return fStateNode.cloneNode(true);
}

... but this leads to a *huge* memory-leak. Where the first approach never
consumes more than 5MB; the latter explodes to up to 256MB before crashing
on my 800kb XML-document...
>From a quick run with a memory-profiler, it  seems as though the
garbage-collector doesn't want to clean these nodes up...

Any ideas or suggestions on how export a node-set from a Java extension
into the resulting document..?

kind regards,

Koen.

BTW: where can I find the xalan-dev archives? Google only returned
covalent.net, but they only keep archives up to 2001 (or have I missed
something?)


Reply via email to