I have a class that evaluates an XPath expression against an XML stream
with multiple namespaces and returns a NodeList.  I know by looking at
the XML that the node I am retrieving is composed of 20 elements, called
'<summary>'.  I also know that two of those elements have no value.  The
relevant code looks like this:


  XML2Doc xmldoc = new XML2Doc(getXmlFile());
  Document domTree = (Document) xmldoc.getDoc();
  domTree.getDocumentElement().normalize();
  NamespaceResolver myResolver = new NamespaceResolver();
  XObject xObj = XPathAPI.eval(domTree,getXpathExp(),myResolver);
  NodeList = xObj.nodelist();





The problem I am running into is that of the 20 <summary> elements some
are empty (<summary type="html"></summary>).  Upon evaluating the XPath
expression the NodeList returned only 18 items event though I know there
are twenty.  It seems that the elements that weren't valued became
insignificant as the NodeList was generated.

Is this the correct behavior?  I'm expecting my NodeList to have the
same number of <summary> elements because I'll be matching them against
their related <title> elements during presentation time.  Perhaps there
is something I need to do in my code to establish the fact that empty
elements are significant and should be included in the NodeList?  I
tried removing the normalize() call but that didn't help.

To make things more interesting I am developing this code using JDK
1.4.2 because that it is the development environment the customer is
using and requires.


Thanks - Tod

Reply via email to