You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Greg Matthews <gm...@flex.com.au> on 2000/03/16 06:01:56 UTC

treewalker. can someone explain this?

dear all,

we're having some wierd stuff happening with treewalkers and the nextnode method.

i'm printing which nodes the nodefilter (see attached) gets passed and it seems like something is going wrong.

can anyone see what we might be doing wrong? or is this a bug?

the funny behaviour *only* seems to happen when we try to find a node that doesn't exist in the xml document, e.g. search for an element called "fred" in the document shown below.

input xml doc.

<a>
  <b/>
  <c/>
  <f>
    <g>
      <h>
        <i>
          <j/>
        </i>  
      </h>
    </g>
  </f>
</a>

output from elementfilter, which does a println as the first line in it's accept method.

b
c
f
g
h
i
j
i
h
g
f
a   <= i'm ok down to here. what's the rest of the stuff though?
h
g
f
a
g
f
a
f
a
a


the treewalker is created with the following code.

  org.apache.xerces.dom.DocumentImpl impl = (org.apache.xerces.dom.DocumentImpl)node.getOwnerDocument();
  TreeWalker tw = impl.createTreeWalker( node, (short)NodeFilter.SHOW_ELEMENT, new ElementFilter( nodeName ));

thanks,
greg.


Re: treewalker. can someone explain this?

Posted by Greg Matthews <gm...@flex.com.au>.
sorry, forgot to include version details.

Xerces-J 1.0.3, Windows 2000, JDK1.3rc1

seems to happen with jdk1.2.2 (no HotSpot) as well.

this is a real showstopper for us. it can take 30-40 
seconds for the nextNode method to finish.

is using a treewalker with a nodefilter the correct
approach to locating a specific node within a doc?

thanks,
greg.
  ----- Original Message ----- 
  From: Greg Matthews 
  To: xerces-dev@xml.apache.org 
  Sent: Thursday, March 16, 2000 4:01 PM
  Subject: treewalker. can someone explain this?


  dear all,

  we're having some wierd stuff happening with treewalkers and the nextnode method.

  i'm printing which nodes the nodefilter (see attached) gets passed and it seems like something is going wrong.

  can anyone see what we might be doing wrong? or is this a bug?

  the funny behaviour *only* seems to happen when we try to find a node that doesn't exist in the xml document, e.g. search for an element called "fred" in the document shown below.

  input xml doc.

  <a>
    <b/>
    <c/>
    <f>
      <g>
        <h>
          <i>
            <j/>
          </i>  
        </h>
      </g>
    </f>
  </a>

  output from elementfilter, which does a println as the first line in it's accept method.

  b
  c
  f
  g
  h
  i
  j
  i
  h
  g
  f
  a   <= i'm ok down to here. what's the rest of the stuff though?
  h
  g
  f
  a
  g
  f
  a
  f
  a
  a


  the treewalker is created with the following code.

    org.apache.xerces.dom.DocumentImpl impl = (org.apache.xerces.dom.DocumentImpl)node.getOwnerDocument();
    TreeWalker tw = impl.createTreeWalker( node, (short)NodeFilter.SHOW_ELEMENT, new ElementFilter( nodeName ));

  thanks,
  greg.