EclipseLink MOXy @XmlPath support for axes/parent

半世苍凉 提交于 2019-11-26 23:29:42

问题


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.


回答1:


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

  • https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink

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

  • http://blog.bdoughan.com/2010/07/xpath-based-mapping.html
  • http://blog.bdoughan.com/2010/09/xpath-based-mapping-geocode-example.html
  • http://blog.bdoughan.com/2011/03/map-to-element-based-on-attribute-value.html


来源:https://stackoverflow.com/questions/8404134/eclipselink-moxy-xmlpath-support-for-axes-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!