EclipseLink MOXy @XmlPath支持axis/parent

mik*_*pr4 7 xpath jaxb eclipselink moxy

是否可以接受以下任何XPath表达式?使用eclipselink的2.3.1版

@XmlPath("../header/@type")
@XmlPath("/root/header/@type")
@XmlPath("parent::*/header/@type")
Run Code Online (Sandbox Code Playgroud)

基本上这是在XML文档(/root/tag)中重复的类中,如果不清楚我会详细说明.

我试图遍历树而不是向下.我的其他@XmlPath注释工作正常.

bdo*_*han 2

EclipseLink JAXB (MOXy)目前不支持轴/父级。如果您对此类支持感兴趣,请输入增强请求:

它确实支持 XPath,例如:

  • @XmlPath(".") // 映射到自身节点,当将两个对象映射到同一元素时很有用
  • @XmlPath("@foo") // 映射到属性
  • @XmlPath("foo") // 映射到元素
  • @XmlPath("foo[2]") // 映射到第二次出现
  • @XmlPath("foo[@bar='Hello World']") // 映射到带有 bar 属性且值为“Hello World”的 foo 元素
  • @XmlPath("ns1:foo/ns2:@bar") // 映射到命名空间限定节点

了解更多信息