You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Mikael Helbo Kjær <mh...@dia.dk> on 2000/03/08 08:38:21 UTC

Weird problem in Xalan-0_20_0

As I posted yesterday (for me at least) I keep encountering a
NullPointerException when using the Xalan XPath engine to search through a
DOM tree, which I have stored in memory and access using a stored Element
reference gotten using from [instance of a Document].getDocumentElement().
However when I call the XPath using the following snippet of code:

      try{
          XPathSupport xps = new XMLParserLiaisonDefault();
          PrefixResolver pr = new
PrefixResolverDefault(m_nDocumentElement.getNodeType() == Node.DOCUMENT_NODE
                                                         ?
((Document)m_nDocumentElement).getDocumentElement() : m_nDocumentElement);
          XPath xpath = new XPath();
          XPathProcessorImpl xpparser = new XPathProcessorImpl(xps);
          xpparser.initXPath(xpath, strXPATH,  pr);
          XObject list = xpath.execute(xps,m_nDocumentElement,pr);
          nl = list.nodeset();
      }catch( SAXException se )
      {
        System.err.println( se.getMessage() );
        se.printStackTrace();
      }

I get the following exception
java.lang.NullPointerException
        at
org.apache.xerces.dom.NamedNodeMapImpl.findNamePoint(NamedNodeMapImpl
.java:770)
        at
org.apache.xerces.dom.NamedNodeMapImpl.getNamedItem(NamedNodeMapImpl.
java:222)
        at
org.apache.xerces.dom.ElementImpl.setupDefaultAttributes(ElementImpl.
java:731)
        at
org.apache.xerces.dom.DeferredElementImpl.synchronizeData(DeferredEle
mentImpl.java:154)
        at org.apache.xerces.dom.NodeImpl.getNodeName(NodeImpl.java:229)
        at
org.apache.xalan.xpath.xml.XMLParserLiaisonDefault.getNamespaceOfNode
(XMLParserLiaisonDefault.java:1073)
        at
org.apache.xalan.xpath.SimpleNodeLocator.nodeTest(SimpleNodeLocator.j
ava:1688)
        at
org.apache.xalan.xpath.SimpleNodeLocator.findChildren(SimpleNodeLocat
or.java:720)
        at
org.apache.xalan.xpath.SimpleNodeLocator.step(SimpleNodeLocator.java:
402)
        at
org.apache.xalan.xpath.SimpleNodeLocator.step(SimpleNodeLocator.java:
495)
        at
org.apache.xalan.xpath.SimpleNodeLocator.step(SimpleNodeLocator.java:
495)
        at
org.apache.xalan.xpath.SimpleNodeLocator.locationPath(SimpleNodeLocat
or.java:295)
        at org.apache.xalan.xpath.XPath.locationPath(XPath.java:964)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:1381)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:1354)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:311)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:274)
        at com.dia.TestXPath.getDocument(TestXPath.java:39)
My code uses the Xerces 1_0_2, Xalan 0_20_0 running in a HotSpot 1.0.1 in
JDK 1.2.2. My XML Document is validated using a DTD, however my document
does not use an XML namespace.
Please help me (this thing otherwise forces me to shift parser to another
parser with XPath support to see if that alleviates the problem)

Mikael Helbo Kjær
Software Developer @ DIA a/s