【发布时间】:2022-01-16 14:34:50
【问题描述】:
我正在使用仅支持 XPath 1.0 的 xmllint --xpath。 我知道 XPath 1.0 支持 concat() 之类的函数:https://www.w3.org/TR/1999/REC-xpath-19991116/
但是当我尝试在 XPath 中使用它们以从 xml 文档中提取内容时,我会遇到如下错误:
xmllint --debug --xpath "//*[local-name()='artifactId' and contains(text(),'log4j')]/../concat(groupId/text(),' ',artifactId/text(),' ', version/text())" ~/aax1
XPath error : Invalid expression
//*[local-name()='artifactId' and contains(text(),'log4j')]/../concat(groupId/text(),' ',artifactId/text(),' ', version/text())
xmlXPathEval: evaluation failed
XPath evaluation failure
我正在阅读 XPath 规范。不清楚如何在 XPath 表达式中使用这些函数(很清楚如何在 XSLT 中使用它们)。是否可以在谓词之外的 XPath 1.0 中使用它们?
【问题讨论】: