【问题标题】:Java XmlPath Annotation with multiple Conditions具有多个条件的 Java XmlPath 注释
【发布时间】:2016-08-21 11:37:59
【问题描述】:

我有以下 XML 架构:

<children>
    <component library="xml">
        <properties Output="1"/>
        <data>
            <root scrollposition="1">
                <entry name="Demo" expanded="1">
                    <entry name="Subentry">
                    </entry>
                </entry>
            </root>
        </data>
    </component>
    <component library="xml">
        <properties/>
        <data>
            <root scrollposition="1">
                <entry name="Demo" expanded="1">
                    <entry name="Subentry">
                    </entry>
                </entry>
            </root>
        </data>
    </component>
</children>

现在我想获取元素properties 中属性library 的值为xml 且属性Output 的值为1 的条目。 我的班级如下:

public class Component {
   @XmlPath("component[@library='xml' and properties[@Output='1']]/data/root/entry")
  private List<Entry> entries;

  public List<Entry> getEntries() {
    return entries;
  }

  public void setEntries(List<Entry> entries) {
    this.entries = entries;
  }
}

但列表为空。 我认为注释“XmlPath”中的某些内容是错误的,但我现在不知道有什么问题。

【问题讨论】:

    标签: java xml eclipselink moxy


    【解决方案1】:

    我发现问题在于当前版本的 MOXy 不支持 XPath 条件来检查属性是否存在或不等于条件。

    唯一支持的条件是[@name='val']

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      • 2021-05-21
      • 1970-01-01
      • 2012-06-24
      • 2013-08-07
      • 2016-08-21
      相关资源
      最近更新 更多