You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Kyle Downey <ky...@amberarcher.com> on 2000/02/16 21:25:53 UTC

using XPath standalone

I have an application for which I'd like to use XPath for designating portions
of documents. I looked at the XPath and ValidateXPath code, and this seemed
possible without getting the whole Stylesheet processor involved. However,
when I tried to do an elementary match I hit a NullPointerException deep
inside the MutableNodeListImpl.

Attached is a test that reproduces it. It uses my JAXP driver for Xerces to
access the parser, and a helper class called DOMWriter to verify that the
parser is reading the document all right. I'm including these in part for full
reproduction, but also as a "present" if it interests you: both are GPL'd
code.

running it like this:

FACTORY=amberarcher.xml.XercesDocumentBuilderFactory
java -Djavax.xml.parsers.DocumentBuilderFactory=$FACTORY
amberarcher.xml.XPathTest test.xrpc "//params/param"

will fail with the Exception included in the ZIP file. 

Included:
--------
XercesDocumentBuilderFactory.java
XercesDocumentBuilder.java
DOMWriter.java
DefaultPrefixResolver.java
XPathTest.java
test.xrpc
test.out

Could someone give me a basic explanation of how to use XPath (correctly!) to
get pointers to document nodes and sub-trees? Based on my reading, the code in
XPathTest should do it--execute(), then unpack XObject with rtree() or one of
the other readers--but I don't know the whole system well enough to figure out
if it's misuse or a bug that causes that NPE.

Help! Thanks. I will share results of my work once getting past this hump....

Platform:
Win98
Xerces 1.0.1
Xalan 0.19.2
JDK 1.2.2 with Sun JAXP beta (and JDK 1.3rc1; same NPE)

regards,
kd