Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30946

XPath problem

Newsgroups comp.lang.java.programmer
Date 2015-01-28 09:57 -0800
Message-ID <77ecdbc0-4d08-4bc1-a409-5eb546352356@googlegroups.com> (permalink)
Subject XPath problem
From Captain Obvious <mr.happeee@gmail.com>

Show all headers | View raw


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");

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

XPath problem Captain Obvious <mr.happeee@gmail.com> - 2015-01-28 09:57 -0800
  Re: XPath problem Captain Obvious <mr.happeee@gmail.com> - 2015-01-28 10:12 -0800

csiph-web