2

Having previously posted EclipseLink MOXy @XmlPath support for axes/parent

I'm still working with @XmlPath annotation and it appears to me predicate inequality isn't supported?

@XmlPath("node[@attr != 'a']")

Also valid for me would be to check for the existance of an attribute

@XmlPath("node[@x]")

Or even better, that it doesn't exist

@XmlPath("node[not(@x)]")

Is there a heavy cost introducing these features? I'm used to having the whole XPath array of features available. MOXy has provided me some fantastic functionality I'm very grateful for, but it seems a little inflexible in this regard.

Community
  • 1
  • 1
mikeapr4
  • 2,830
  • 16
  • 24

1 Answers1

0

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

MOXy currently supports:

  • @XmlPath("node[@x='foo']")

but not:

  • @XmlPath("node[@x!='foo']")
  • @XmlPath("node[@x]")
  • @XmlPath("node[not(@x)]")

Background

MOXy currently uses the same XPath for both marshalling and unmarshalling. It is 100% clear what each of the unsupported XPaths mean in terms of unmarshalling, it is a little less clear in terms of marshalling (but probably not unsolveable).

Action Items

Please enter an enhancement request for this functionality (Specify MOXy as the component). Bugs entered by external users are given priority in our backlog.

For More Information

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • In regards to marshalling, I see what you mean, these predicates cannot be used to create the XML, the only option I see is to ignore those predicates for marshalling. I'm sure `node[(@a='1') and (@b!='2')]` isn't supported right now, but if it were, the marshalling would need to understand that the `(@b!='2')` predicate isn't reversable and therefore should use `node[@a='1']` – mikeapr4 Jan 05 '12 at 09:26
  • Just one more thing, I use MOXy to allow more flexibility for parsing XML that's schema is not under my control. I'd say it's the most common use case for requiring XPath based mapping, as opposed to the more common JAXB use case of both marshalling and unmarshalling objects. Not sure if I represent the majority, but something to consider :) – mikeapr4 Jan 05 '12 at 09:33