简体   繁体   English

XPath“评估”方法如何工作?

[英]How does XPath “evaluate” method work?

I want to understand a difference between execution of evaluation when-我想了解执行评估之间的区别 -

  1. Document object's setNameSpaceAware and isValidating is set to true - In this case, I understand that if my XML uses a namespace, then I need to set NameSpaceContext.文档对象的setNameSpaceAwareisValidating设置为true - 在这种情况下,我了解如果我的 XML 使用命名空间,那么我需要设置 NameSpaceContext。 If I do not set NameSpaceContext, how does evaluate method work/ handle this condition?如果我没有设置 NameSpaceContext,评估方法如何工作/处理这种情况?
  2. Document object's setNameSpaceAware and isValidating is set to false - What happens exactly if these 2 are set to false?文档对象的setNameSpaceAwareisValidating设置为false - 如果这两个设置为 false 会发生什么?

(This question could be linked to an issue mentioned in this question.) (这个问题可能与这个问题中提到的问题有关。)

XPath is not defined except on namespace-aware source documents. XPath 未定义,除了命名空间感知源文档。 So the simple answer is, anything might happen depending on the implementation.所以简单的答案是,任何事情都可能发生,具体取决于实现。

By constrast, XPath should work regardless of the setting of isValidating, and in nearly all cases should produce the same results.相比之下,无论 isValidating 的设置如何,XPath 都应该工作,并且几乎在所有情况下都应该产生相同的结果。 An exception might be the use of the id() function, which depends on ID attributes being recognised.一个例外可能是使用 id() function,这取决于识别的 ID 属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM