You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by xa...@xml.apache.org on 2004/10/01 23:56:32 UTC

[jira] Resolved: (XALANJ-1965) NullPointerException when using XPath Expression

Message:

   The following issue has been resolved as DUPLICATE.

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XALANJ-1965

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XALANJ-1965
    Summary: NullPointerException when using XPath Expression
       Type: Bug

     Status: Resolved
   Priority: Major
 Resolution: DUPLICATE

    Project: XalanJ2
 Components: 
             XPath API
   Versions:
             CurrentCVS

   Assignee: 
   Reporter: Yash Talwar

    Created: Wed, 22 Sep 2004 12:53 PM
    Updated: Fri, 1 Oct 2004 2:56 PM
Environment: Windows 2000.  JRE 131.  Xalan Java 2.6.0

Description:
The following execption occurs when I run java class:
-------------------------------------------------------
java.lang.NullPointerException
at org.apache.xpath.compiler.OpMap.getStepLocalName(OpMap.java:446)
at org.apache.xpath.axes.WalkerFactory.createDefaultWalker(WalkerFactory.java:1282)
at org.apache.xpath.axes.WalkerFactory.loadWalkers(WalkerFactory.java:111)
at org.apache.xpath.axes.WalkingIterator.<init>(WalkingIterator.java:61)
at org.apache.xpath.axes.WalkingIteratorSorted.<init>(WalkingIteratorSorted.java:70)
at org.apache.xpath.axes.WalkerFactory.newDTMIterator(WalkerFactory.java:281)
at org.apache.xpath.compiler.Compiler.locationPath(Compiler.java:635)
at org.apache.xpath.compiler.Compiler.compile(Compiler.java:175)
at org.apache.xpath.compiler.Compiler.compile(Compiler.java:121)
at org.apache.xpath.XPath.<init>(XPath.java:170)
at org.apache.xpath.XPath.<init>(XPath.java:199)
at TestClass.main(TestClass.java:22)
Exception in thread "main" 
-------------------------------------------------------
Java main class:
-------------------------------------------------------
import javax.xml.transform.TransformerException;

import org.apache.xerces.dom.CoreDocumentImpl;
import org.apache.xerces.dom.DOMInputImpl;
import org.apache.xerces.parsers.DOMParserImpl;
import org.apache.xerces.parsers.XML11Configuration;
import org.apache.xml.utils.PrefixResolver;
import org.apache.xpath.XPath;
import org.w3c.dom.Document;
import org.w3c.dom.ls.LSParser;
import org.w3c.dom.xpath.XPathEvaluator;
import org.w3c.dom.xpath.XPathNSResolver;

public class TestClass 
{
  public static void main(String[] args) 
  {
    LSParser parser = new DOMParserImpl(new XML11Configuration());
    Document doc = parser.parse(new DOMInputImpl(null, "input.xml", null));
    XPathEvaluator eval = (XPathEvaluator) ((CoreDocumentImpl) doc).getFeature("+XPath", "3.0");
    XPathNSResolver resolver = eval.createNSResolver(doc);
    try 
    {
      XPath xpath =  new XPath("/namespace::title",null,(PrefixResolver) resolver, XPath.SELECT);
    } 
    catch (TransformerException e) 
    {
      e.printStackTrace();
    }

  }
}

-------------------------------------------------------
input.xml
-------------------------------------------------------
<?xml version="1.0"?>
<book xmlns:pre="http:exmple.com">
   <title xmlns:pre1="hi">Amazing Book</title>
   <author>Good Person</author>
</book>
-------------------------------------------------------



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org