java - 如何获取节点的字符串值?

标签 java saxon

XPath string(/ROOT/Products/UnitPrice) 在 dom4j 和 .NET 运行时中运行良好。但在撒克逊语中它会抛出一个异常:

net.sf.saxon.s9api.SaxonApiException: A sequence of more than one item is not allowed as the first argument of string() (<UnitPrice/>, <UnitPrice/>, ...) 

这是怎么回事?为什么这样不行?

最佳答案

Saxon 期望单个节点作为输入。

.NET 实现不同;它只考虑第一个:

The string() function converts a node-set to a string by returning the string value of the first node in the node-set, which in some instances may yield unexpected results.

参见MSDN

关于java - 如何获取节点的字符串值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50787050/

相关文章:

javascript - javascript中测试当前线程是否为主线程

java - 如何显示Saml断言节点?

java - 在 Java 中将字符串转换为颜色

java - 无法将 net.sf.saxon.jaxp.TemplatesImpl 转换为可序列化

aws-lambda - Saxon XSLT 转换作为 Amazon AWS Lambda 函数交付

xml - 使用 ant 和 xslt 动态连接 xml 文件

java - JAXP 撒克逊-he : XMLfile StreamSource doesn't release file access after parsing error

java - java 序列中的服务(线程)

java - 使用mysql、jdbc创建表

java - 我想我迭代 key(itr) 的方式错误?