gpt4 book ai didi

java - 解释对多个 XML 文档应用多个 xpath 查询的规则

转载 作者:行者123 更新时间:2023-12-01 05:57:18 26 4
gpt4 key购买 nike

我需要构建一个组件,该组件将在输入中获取一些 XML 文档并检查以下类型的规则:

XML1:/bookstore/book[price>35.00] != null 
and (XML2:/city/name = 'Montreal'
or XML3://customer[@language] contains 'en')

基本上我的组件应该能够:

  • 用相应的 XML 文档替换 XML 标记(冒号之前)
  • 对此 XML 文档应用 xpath 查询
  • 根据预期结果检查 xpath 输出(“=”、“!=”、“包含”)
  • 遵循基本语法(“and”、“or”和括号)
  • 判断规则是对还是错

你知道有什么图书馆可以帮助我吗?也许是JavaCC?

谢谢

最佳答案

为了评估 XPATH,我推荐 JAXEN .

Jaxen is an open source XPath library written in Java. It is adaptable to many different object models, including DOM, XOM, dom4j, and JDOM. Is it also possible to write adapters that treat non-XML trees such as compiled Java byte code or Java beans as XML, thus enabling you to query these trees with XPath too.

Java XPath API (Java 5/javax.xml.xpath) 也是一个选项,但我还没有尝试过。

关于java - 解释对多个 XML 文档应用多个 xpath 查询的规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2477898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com