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
1
vote
0 answers

How to extract all the values within a segment in an XML file using JXPathContext getValue with the same tag name

Below is a sample input xml file that I'm trying to parse. I'm able to get the value for most the elements except the 5th element from the REF segment where there are multiple comps. What's happening is, the value being extracted from that 5th…
Marielly
  • 11
  • 3
1
vote
2 answers

How to get JXPath to cleanly set list/collection entries

I've started to use Commons JXPath in my unit and integration tests, as a simple way to set a set of properties in a bean hierarchy. One scenario where I can't use JXPath "cleanly" is in setting list entries. I'd really like for JXPath to do the…
David M. Karr
  • 14,317
  • 20
  • 94
  • 199
1
vote
3 answers

How to parse XML file with JxPath and DOM parser

I need simple example how can be possible to parse XML files with Java DOM parser and Apache JxPath. I am aware with DOM parser technology, but now I'm trying to integrate JxPath in my source. I have searched in a network, but I can't find working…
Armer B.
  • 753
  • 2
  • 9
  • 25
1
vote
0 answers

How to get boolean value from a JAXB ajav object using jxpath?

I am using spring 4.1.1 and JXpath 1.3. I am able to read all the values from an JAXB java object using JXPath query except boolean values. Do I need to follow any specific instructions to read boolean using JXpath?
bsk
  • 11
  • 1
1
vote
1 answer

How to use a substring of a string in a JXPath expression

I have a list of java objects that contain flight numbers and gate numbers: public class Flight { public String flightNumber; public String gateNumber; } For the purposes of this question, my list contains objects with the following flight…
Jason
  • 11,744
  • 3
  • 42
  • 46
1
vote
2 answers

XPath to select nodes in different namespaces

I need some help with coming up with a proper XPath expression to extract values out of the XML. I can get the values using jaxb however I need xpath because I have a decision table kind of mapping rules that I want to externalise, which if I use…
Chetya
  • 1,267
  • 1
  • 17
  • 31
1
vote
1 answer

how to compile xsd into a set of equivalent java objects using moxy?

I'm looking to use JAXB however since I have a lot of attributes that I need to pluck out of my xmls I would prefer to use xpath queires instead of doing it through the dot notation on my java objects. My questions : Is there a different…
Chetya
  • 1,267
  • 1
  • 17
  • 31
1
vote
1 answer

jxpath not honoring JAXB's XmlElement name of xjc-generated classes

I use an XML Schema Definition and JAXB to generate Java classes with proper @XmlElement or @XmlRootElement annotations. Since the schema has some deep nesting in it (not my choice), I'd rather use jxpath to access deeply buried classes using an…
Pierre D
  • 24,012
  • 7
  • 60
  • 96
1
vote
1 answer

Can JXPath find objects by type?

I have a relatively complicated object graph. Is it possible to have an expression in JXPath that will find any objects by type? For example: List myList = JXPathContext.newContext(rootObject).getValue(??objects of type…
Freiheit
  • 8,408
  • 6
  • 59
  • 101
1
vote
1 answer

JXPath with multiple namespaces

I need to create a query on a JAXB generated object using JXPath. The trial code below generates the following error: Exception in thread "main" org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath:…
UESer
  • 25
  • 4
1
vote
1 answer

Using the // operator in JXPath

Some root object has field MyCollection myCollection. The class MyCollection implements Collection interface. The names of elements are available by calling someService().getName() that's why I created Rules…
LancerX
  • 1,211
  • 7
  • 23
  • 40
1
vote
1 answer

Add node using JXPATH

I am using jxpath to print all nodes and add a child node to the feature tag in this xml 1 1 2 This is what my code looks like (the part that…
user1432913
  • 79
  • 6
  • 14
0
votes
2 answers

How to evaulate xpath expression using JXpath library

I'm using apache JXPath library to parse an XML. I'm trying to find an API in JXPath which does similar function as XPath evaluate, i.e. check if the xpath expression exists ? Its similar in the lines of
Shamik
  • 1,671
  • 11
  • 36
  • 64
0
votes
0 answers

JXPath trouble running query on a nesting element

I have this XSD of Jira workflow:
KC Wong
  • 2,410
  • 1
  • 18
  • 26
0
votes
0 answers

Apache JXPath attribute selector not working

I have this XML: I generated the Java classes using JAXB and successfully unmarshalled it in variable "wf". Then invoking JXPath: String…
KC Wong
  • 2,410
  • 1
  • 18
  • 26