为什么 XML 命名空间是 HTTP 地址? [英] Why are XML namespaces HTTP addresses?

查看:46
本文介绍了为什么 XML 命名空间是 HTTP 地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使命名空间 URI 不是 HTTP 上可用的真正资源,XML 命名空间的目的是什么?XML 解析器与它有什么关系?他们的识别(命名空间)在哪里?

Even though namespace URIs are not real resources available over HTTP, what is the purpose of XML namespaces? And how are XML parsers related to it? Where their recognition (namespaces) exist?

推荐答案

XML 命名空间的目的在 第 1 节,动机和总结 W3C 建议:XML 1.0 中的命名空间(第三版):

The purpose of XML namespaces is explained clearly in Section 1, Motivation and Summary of the W3C Recommendation: Namespaces in XML 1.0 (Third Edition):

我们设想了可扩展标记语言 (XML) 的应用程序,其中单个 XML 文档可能包含元素和属性(此处称为作为标记词汇表"),为多个定义和使用软件模块.这样做的一个动机是模块化:如果这样存在易于理解的标记词汇表是有用的软件可用,最好重新使用此标记而不是重新发明它.

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.

这些考虑要求文档结构应该具有构造名称以避免来自不同名称的名称之间发生冲突标记词汇.该规范描述了一种机制,XML命名空间,它通过分配扩展名称到元素和属性.

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 命名空间采用 URI 的词法形式,但您是对的,不必可检索;根据第 3 节,声明命名空间:

An XML namespace takes the lexical form of a URI, but you are correct that it does not have to be retrievable; per in section 3, Declaring Namespaces:

属性的规范化值必须是一个 URI 引用——标识命名空间的命名空间名称 - 或空字符串.这命名空间名称,为了达到其预期目的,应该具有具有独特性和持久性的特点.这不是目标它可以直接用于检索模式(如果有的话)存在).

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 的一个主要好处是域名持有者可以被视为被授权管理域在定义命名空间时的独特使用.

A primary benefit of using a URL is that the domain name holder can be considered to be authorized to manage the unique use of the domain in defining the namespace.

解析器将命名空间 URI 视为组件(元素和属性)名称的词法部分.解析器还使用 xsi:schemaLocation 中的命名空间来帮助定位 XSD 以与每个用户提示"的 XML 文件相关联.

Parsers consider namespaces URIs to be lexical parts of component (element and attribute) names. Parsers also use namespaces in xsi:schemaLocation to help locate the XSD to associate with an XML file per user "hints".

这篇关于为什么 XML 命名空间是 HTTP 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆