Questions tagged [jxpath]

JXPath applies XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.

JXPath is a Java package that enables extraction of data from hierarchical data structures using XPath notation. JXPath can apply XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.

Example:

Address address = (Address)JXPathContext.newContext(vendor).
         getValue("locations[address/zipCode='90210']/address");

This XPath expression is equivalent to the following Java code:

Address address = null;
Iterator it = vendor.getLocations().iterator();
while (it.hasNext()){
    Location location = (Location)it.next();
    String zipCode = location.getAddress().getZipCode();
    if (zipCode.equals("90210")){
      address = location.getAddress();
      break;
    }
}
50 questions
25
votes
2 answers

Create an immutable list from a java.lang.Iterator

I'm using a library (JXPath) to query a graph of beans in order to extract matching elements. However, JXPath returns groups of matching elements as an instance of java.lang.Iterator and I'd rather like to convert it into an immutable scala list.…
Romain Rouvoy
  • 295
  • 1
  • 3
  • 9
4
votes
2 answers

What's the best way to wrap an XPath language/interface over POJOs?

I'd like to expose a tree of POJOs via a simple "XPath" like language so that users can do something like /purchaseOrder/location[@city = 'Mountain View']?
Ashwin Jayaprakash
  • 2,168
  • 24
  • 29
4
votes
0 answers

Parsing large XML files(Airspace, Point and Route in AIXM 5.1) with xlinks using Jaxb taking long time

I am trying to parse an AIXM5.1 xml file of size >50 MB using JAXB. I am able to unmarshal this xml within a minute itself. But, when I try to iterate through the java object and fetching values of the fields in XML it is taking huge time. After…
shivaram
  • 41
  • 4
4
votes
1 answer

jXPath quering attribute in super class

I have a couple of domain classes which all inherit a BaseDomain class. In this BaseDomain class I have a field that is public final String name; The value of name is set in the constructor. public class BaseDomain { public final String name; …
3
votes
2 answers

Using JXPath to Query a List

I have a simple class (for testing purposes) that I am trying to Query against using JXPath. I create a list of various animal objects, and I want to get an Iterator for: All Animals where type='CAT' All Animals where numLegs = 4 Here is the…
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
2
votes
3 answers

Is it possible to transform javabeans with XSLT and JXPath?

Suppose I have a vanilla javabean: class Person { String firstName; String lastName; ... } Now suppose I want to transform this into another javabean: class Human { String name; ... } I'm currently using JXPath to help me transform one…
lindelof
  • 34,556
  • 31
  • 99
  • 140
2
votes
1 answer

How to covert "org.w3c.dom.Document" object to "org.apache.commons.jxpath.xml.DocumentContainer" object in Java

I have a document object and need to parse XML using JXPath (which needs DocumentContainer object). Is there any to way to create DocumentContainer from Document. I don't have the file available physically
Mahipal Reddy
  • 389
  • 6
  • 20
2
votes
2 answers

Walk over a complex object graph in Java and get index to an attribute (similar to xpath)

Problem Statement: Imagine a nested object like below: class Company{ ... List departments; } class Department{ ... List employees; } class Employee{ String name; ... } A company has many departments, and each department…
hackmabrain
  • 457
  • 1
  • 6
  • 21
2
votes
1 answer

Does Apache Commons JXPath searching marshals an object during searching by XPath?

I am new to the expressions language, and I want to learn more about org.apache.commons.jxpath utilities. But I am wondering about the implementation of the JXPath utilities. Is the object first marshaled, upon which XPath searching will be applied,…
Zubair Ahmed
  • 147
  • 4
  • 13
1
vote
1 answer

JxPath: evaluation of '' = 0

I am evaluating the expression '' = 0 in JxPath 1.3, and I expect the result to be false. This is my code: JXPathContext.newContext(ctaSectionABean).getValue("'' = 0"); However, the result returned to be is true! If I evaluate the same expression…
Markos Fragkakis
  • 7,499
  • 18
  • 65
  • 103
1
vote
1 answer

JXPath to filter SOAP message

I'm trying to extract the value of the node GoodEmail from a SOAP response. It seems that no matter what I try, I always get a org.apache.commons.jxpath.JXPathNotFoundException. SOAP response:
Oskar Ferm
  • 227
  • 1
  • 5
  • 12
1
vote
1 answer

Issue with XML parsing using Commons JXPath

I'm trying to parse a XML using Apache Commons JXPath. But for some reason, its not able to identify the child nodes after the xml is being parsed. Here's the sample code : private static void processUrl(String seed){ String test = "
Shamik
  • 1,671
  • 11
  • 36
  • 64
1
vote
2 answers

Find elements within array, by specific property with jxpath

What is wrong with the JXpath expression in the code below? The following code always throws this exception: org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath: countries[gdp=4] However I expected the country Germany to be…
eztam
  • 3,443
  • 7
  • 36
  • 54
1
vote
1 answer

java jsonxpth parsing json jumping to node

I have the following data and i am using "http://commons.apache.org/jxpath/" i want to directly read the coordinates: [51.464426 -0.382974] which is lat,lng how can i read this any quick example i search around and found there is another jsonpath as…
d-man
  • 57,473
  • 85
  • 212
  • 296
1
vote
1 answer

What are the differences between XPath and JXPath?

I need to get the values from a DOM object using Java, I would like to know the differences between XPath & JXPath.
Mahipal Reddy
  • 389
  • 6
  • 20
1
2 3 4