You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Michael Shapiro <mi...@creativescience.com> on 2000/08/18 00:57:37 UTC

xpath.Process problem or am I doing something wrong?

Sorry in advance for the [most probably] stupid question.

I'm trying to use XPathProcessor and I ran into the problem.

Here is the problem:

c:\>java org.apache.xalan.xpath.Process file:///C:\test.xml -select "/"
Parsing XML:
java.lang.NullPointerException:
        at
org.apache.xalan.xpath.SimpleNodeLocator.findRoot(SimpleNodeLocator.java:114
5)
        at org.apache.xalan.xpath.SimpleNodeLocator.step(Compiled Code)
        at
org.apache.xalan.xpath.SimpleNodeLocator.locationPath(SimpleNodeLocator.java
:321)
        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 org.apache.xalan.xpath.Process.main(Compiled Code)

The test.xml file content is:
<?xml version="1,0"?>
<a>
    <b/>
</a>

After spending sometime on the source code study I found that somehow the
    doc = callbacks.parseXML(url, null, null);
goes to XPathSupportDefault that always returns null

I think it should go to xerces parser (through XMLParserLiason) but in
reallity it goes to XPathSupportDefult that has a parseXML method returning
null.

Any advice would be greatly appriciated.

Michael


Re: xpath.Process problem or am I doing something wrong?

Posted by Gary L Peskin <ga...@firstech.com>.
Michael --

Thanks for the clarification.  I really haven't looked into this too
much.  It looks like parseXML was deprecated in XPathSupport because no
one else was using it anymore.  You might want to have a look in the
XPathAPI.java source in samples\ApplyXPath.  This is the class that
actually does the work for ApplyXPath.  It looks like it just takes a
Node which would work for you maybe.

Like I said, I haven't really studied this but the techniques in
XPathAPI might give you some insight to a workaround or proper
implementation.

Gary

Michael Shapiro wrote:
> 
> Gary,
> 
> Thank you very much.
> 
> Yes, I could use ApplyXPath and the high level API it's presenting but my
> real task is somewhat different.
> I'm trying to put a thin DOM layer around some tree-like structured object
> that has it's own accessors and mutators.
> The first thing I'd like to implement is something similar to
> xpath.Process.main. ApplyXPath example is using DOMParser directly that's
> why it's less useful in my case.
> 
> Thanks again,
> 
> Michael

Re: xpath.Process problem or am I doing something wrong?

Posted by Michael Shapiro <mi...@creativescience.com>.
Gary,

Thank you very much.

Yes, I could use ApplyXPath and the high level API it's presenting but my
real task is somewhat different.
I'm trying to put a thin DOM layer around some tree-like structured object
that has it's own accessors and mutators.
The first thing I'd like to implement is something similar to
xpath.Process.main. ApplyXPath example is using DOMParser directly that's
why it's less useful in my case.

Thanks again,

Michael


----- Original Message -----
From: "Gary L Peskin" <ga...@firstech.com>
To: <xa...@xml.apache.org>
Sent: Thursday, August 17, 2000 7:10 PM
Subject: Re: xpath.Process problem or am I doing something wrong?


> Michael --
>
> You are correct that this is the problem.  I haven't looked into fixing
> Process.main to go to parse where it seems like it should go.  However,
> you can accomplish what you want with the following command line:
>
> java ApplyXPath c:\test.xml /
>
> This is explained at http://xml.apache.org/xalan/samples.html#xpath
>
> Also, you'll need to change the comma in version="1,0" to a period.
>
> HTH,
> Gary
>
> Michael Shapiro wrote:
> >
> > Sorry in advance for the [most probably] stupid question.
> >
> > I'm trying to use XPathProcessor and I ran into the problem.
> >
> > Here is the problem:
> >
> > c:\>java org.apache.xalan.xpath.Process file:///C:\test.xml -select "/"
> > Parsing XML:
> > java.lang.NullPointerException:
> >         at
> >
org.apache.xalan.xpath.SimpleNodeLocator.findRoot(SimpleNodeLocator.java:114
> > 5)
> >         at org.apache.xalan.xpath.SimpleNodeLocator.step(Compiled Code)
> >         at
> >
org.apache.xalan.xpath.SimpleNodeLocator.locationPath(SimpleNodeLocator.java
> > :321)
> >         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 org.apache.xalan.xpath.Process.main(Compiled Code)
> >
> > The test.xml file content is:
> > <?xml version="1,0"?>
> > <a>
> >     <b/>
> > </a>
> >
> > After spending sometime on the source code study I found that somehow
the
> >     doc = callbacks.parseXML(url, null, null);
> > goes to XPathSupportDefault that always returns null
> >
> > I think it should go to xerces parser (through XMLParserLiason) but in
> > reallity it goes to XPathSupportDefult that has a parseXML method
returning
> > null.
> >
> > Any advice would be greatly appriciated.
> >
> > Michael
>


Re: xpath.Process problem or am I doing something wrong?

Posted by Gary L Peskin <ga...@firstech.com>.
Michael --

You are correct that this is the problem.  I haven't looked into fixing
Process.main to go to parse where it seems like it should go.  However,
you can accomplish what you want with the following command line:

	java ApplyXPath c:\test.xml /

This is explained at http://xml.apache.org/xalan/samples.html#xpath

Also, you'll need to change the comma in version="1,0" to a period.

HTH,
Gary

Michael Shapiro wrote:
> 
> Sorry in advance for the [most probably] stupid question.
> 
> I'm trying to use XPathProcessor and I ran into the problem.
> 
> Here is the problem:
> 
> c:\>java org.apache.xalan.xpath.Process file:///C:\test.xml -select "/"
> Parsing XML:
> java.lang.NullPointerException:
>         at
> org.apache.xalan.xpath.SimpleNodeLocator.findRoot(SimpleNodeLocator.java:114
> 5)
>         at org.apache.xalan.xpath.SimpleNodeLocator.step(Compiled Code)
>         at
> org.apache.xalan.xpath.SimpleNodeLocator.locationPath(SimpleNodeLocator.java
> :321)
>         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 org.apache.xalan.xpath.Process.main(Compiled Code)
> 
> The test.xml file content is:
> <?xml version="1,0"?>
> <a>
>     <b/>
> </a>
> 
> After spending sometime on the source code study I found that somehow the
>     doc = callbacks.parseXML(url, null, null);
> goes to XPathSupportDefault that always returns null
> 
> I think it should go to xerces parser (through XMLParserLiason) but in
> reallity it goes to XPathSupportDefult that has a parseXML method returning
> null.
> 
> Any advice would be greatly appriciated.
> 
> Michael