7

Are any of the following XPath expressions acceptable? Using version 2.3.1 of eclipselink

@XmlPath("../header/@type")
@XmlPath("/root/header/@type")
@XmlPath("parent::*/header/@type")

Basically this is in a class which repeats within the XML document (/root/tag), if that isn't clear I'll elaborate.

I'm trying to traverse up the tree rather than down. My other @XmlPath annotations are working fine.

Wayne
  • 59,728
  • 15
  • 131
  • 126
mikeapr4
  • 2,830
  • 16
  • 24

1 Answers1

2

EclipseLink JAXB (MOXy) does currently not support axes/parent. If you are interested in this kind of support please enter an enhancement request:

It does support XPath like:

  • @XmlPath(".") // Map to self node, useful when mapping two objects to same element
  • @XmlPath("@foo") // Map to attribute
  • @XmlPath("foo") // Map to element
  • @XmlPath("foo[2]") // Map to 2nd occurence of
  • @XmlPath("foo[@bar='Hello World']") // Map to foo element with bar attribute with value "Hello World"
  • @XmlPath("ns1:foo/ns2:@bar") // Map to namespace qualified nodes

For More Information

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Any update on this? MOXy is really good, but for our team to push it, our project needs 'parent' and 'child' due to the complicated xml object in certain instances. – JackDev Feb 05 '16 at 00:44
  • Wondering whether there are any updates on this (2 years after the last comment here) - I really appreciate MOXy but it feels a bit like an incomplete tool without supporting at least the ancestor axis .. – William Apr 10 '19 at 12:48