xml - 命名空间检查是基于 xml 字符串还是基于 URI?

标签 xml namespaces

我一直想知道 XML 解析器如何处理 URI namespace 的检查。它是基于字符串还是基于 URI?换句话说,这是 SVG 的标准 URI

xmlns="http://www.w3.org/2000/svg"

假设我改写

xmlns="http://www.w3.org/2000/../2000/svg"

xmlns="http://www.w3.org/2000/svg/"

甚至

xmlns="http://www.w3.org:8000/2000/svg"

这些情况会被识别为 svg 命名空间(基于 URI)还是不被识别(基于字符串)?

谢谢

编辑:您可以使用 URN(如 uuid)这一事实让我觉得它是基于字符串的,因为您无法将正确的 URL/URI 考虑因素应用于非 URL 类 URI。但也许在那种情况下它只能作为字符串工作?

编辑:正如 Tormod 指出的那样,它是通过字符串比较完成的。这促使我想知道是否有定义 URI 的建议(例如:末尾没有斜线,全部小写,等等)。还是只是一场混战?

最佳答案

它们是基于字符串的。您所有的示例 URI 都解析为不同的命名空间。

http://www.w3.org/TR/REC-xml-names/#NSNameComparison

URI references identifying namespaces are compared when determining whether a name belongs to a given namespace, and whether two names belong to the same namespace. [Definition: The two URIs are treated as strings, and they are identical if and only if the strings are identical, that is, if they are the same sequence of characters. ] The comparison is case-sensitive, and no %-escaping is done or undone.

关于xml - 命名空间检查是基于 xml 字符串还是基于 URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/765769/

相关文章:

c# - 如何使用 XDocument 读取 xml 文件?

xml - 如何绘制由 IAR Embedded Workbench 生成的 xml 调用图?

python - 在xml中创建具有命名空间的子元素

c++ - 奇怪的重复模板模式——继承和 friend

ruby-on-rails - 使用 Nokogiri 将 XML 提要解析为 Ruby 对象?

java - 如何查找 testng.xml 文件中正在执行的测试数量

r - 如何使用 xml2 包将数据帧转换为 xml?

c# - C#中的命名空间

c++ - 导出类的部分命名空间

PHP SoapClient : How to pass complex-type parameters to a webservice?