Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XPath problem

120 views
Skip to first unread message

Captain Obvious

unread,
Jan 28, 2015, 12:57:33 PM1/28/15
to
Trying to debug something in the course of standing up some legacy code on a new server, would appreciate any comments: The code I am working with uses dom4j-1.6.1.jar with JRE 1.5.0_22. For some reason all attempts to execute

DocumentHelper.createXPath("//property");

result in this error:

[28-Jan-2015 12:31:27.335] DEBUG - Message: Invalid XPath expression: '//property'. Caused by: org.jaxen.dom4j.DocumentNavigator.getInstance()Lorg/jaxen/Navigator;
org.dom4j.InvalidXPathException: Invalid XPath expression: '//property'. Caused by: org.jaxen.dom4j.DocumentNavigator.getInstance()Lorg/jaxen/Navigator;

A few things I have determined while looking into this:

- The legacy argument to createXPath was createXPath("/config/property");

- The xml file I am working with contains many <property> blocks: <control><property>[stuff]</property>{followed by many more property blocks}</control>

- Have tried many variations of what appear to be valid arguments to createXPath(): "/config/property", "//config/property", "/property", "//property" and others all to no avail.

If anyone could offer some insight into what is wrong with my call to createXPath, or my environment, or how one might debug this problem, that would be great.

Thanks,
-jt

Below is a portion of the java source I am working with. This code is working as expected in the customer's production environment:

//java packages
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

//packages from dom4j-1.6.1.jar
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;
.
.
.
XPath xpathSelector = DocumentHelper.createXPath("/config/property");

Captain Obvious

unread,
Jan 28, 2015, 1:12:45 PM1/28/15
to
To clarify a bit: The "Invalid XPath expression" error messahe inludes whatever value I pass to createXPath(). Not always '//property' as above.
0 new messages