gpt4 book ai didi

xml - 为什么 XML namespace 是 HTTP 地址?

转载 作者:行者123 更新时间:2023-12-05 04:13:12 24 4
gpt4 key购买 nike

即使命名空间 URI 不是通过 HTTP 可用的真实资源,XML 命名空间的目的是什么? XML 解析器与它有何关系?他们的识别(命名空间)存在于何处?

最佳答案

XML 命名空间的用途在 Section 1, Motivation and Summary 中有清楚的解释。的 W3C Recommendation: Namespaces in XML 1.0 (Third Edition) :

We envision applications of Extensible Markup Language (XML) where a single XML document may contain elements and attributes (here referred to as a "markup vocabulary") that are defined for and used by multiple software modules. One motivation for this is modularity: if such a markup vocabulary exists which is well-understood and for which there is useful software available, it is better to re-use this markup rather than re-invent it.

Such documents, containing multiple markup vocabularies, pose problems of recognition and collision. Software modules need to be able to recognize the elements and attributes which they are designed to process, even in the face of "collisions" occurring when markup intended for some other software package uses the same element name or attribute name.

These considerations require that document constructs should have names constructed so as to avoid clashes between names from different markup vocabularies. This specification describes a mechanism, XML namespaces, which accomplishes this by assigning expanded names to elements and attributes.

XML namespace 采用 URI 的词法形式,但您认为它不必可检索是正确的;每英寸 section 3, Declaring Namespaces :

The attribute's normalized value MUST be either a URI reference — the namespace name identifying the namespace — or an empty string. The namespace name, to serve its intended purpose, SHOULD have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists).

使用 URL 的一个主要好处是可以认为域名持有者被授权管理在定义命名空间时对域的唯一使用。

解析器将 namespace URI 视为组件(元素和属性)名称的词法部分。解析器还在 xsi:schemaLocation 中使用 namespace 来帮助定位 XSD 以根据用户“提示”与 XML 文件关联。

关于xml - 为什么 XML namespace 是 HTTP 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38271786/

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