You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary L Peskin <ga...@firstech.com> on 2000/10/21 01:37:08 UTC

[XalanJ2] JOE, SCOTT, DEVELOPERS -- Important

Sorry to shout but I think this is important.

I've discovered what I think is a major problem with using
NodeIterators.  The problem surfaced while I was looking into the
message "API versus command line for Xalan-J2 alpha" sent yeterday by
Derrick Koes.  What it boils down to is that XalanJ2 doesn't work when
select tracing is specified.

The reason is that when calling TraceManager.fireSelectedEvent, we need
to provide the current selected node-set as an XObject.  So far no
problem.  However, we only have the node-set as a NodeIterator.  In
order to build a NodeSet and then an XNodeSet, we call new
NodeSet(NodeIterator).  The problem is that in building the new NodeSet,
we have to call nextNode() on the NodeIterator.  However, this destroys
the position in the NodeIterator so that it can't be used anymore.

The problem is that once a NodeIterator is created, there's no way to
clone it.

>>>   Any use of it destroys it.   <<<<

So, once we use it to build the XObject for the trace, the NodeIterator
is not available for use in the rest of our transform processing, which
ends immediately with no output!!  This is not good.

The real solution, I think, is for Joe to get W3C to add a clone method
into the DOM Level 2 Traversal spec if it's not too late.  Otherwise,
we're faced with kludgy subclassing to accomodate the current features
of our class design.  You can see this creeping in already in
TransformerImpl.transformSelectedNodes() and XNodeSet.nodeset() to name
two places.  This can only lead to future errors and ugliness, in my
opinion.

I toyed with making a number of changes in several different ways.  One
of the things that I thought about was to keep a count of the number of
nextNode() calls we made in creating our NodeSet and then make the same
number of previousNode() calls when we were done.

When I was done throwing up [:)], I decided that this was a pretty big
thing so I thought Scott should be consulted before anything is done.

Scott, I know you're having a good time at ApacheCON.  But, if you or
someone could give this some thought, we can get XalanJ2 working with
tracing.

Gary