xmlns 属性在哪里定义? [英] Where is xmlns attribute defined?
问题描述
我知道这是正确的 XML
I know that this is correct XML
<Data xmlns="http://w3.schools.com">
<One>Data1</One>
</Data>
xmlns
是一个属性,使用上述语法意味着所有节点都属于双引号中的命名空间.我不明白的是 xmlns
属性在哪里定义?
xmlns
is an attribute and using the above syntax means all nodes belong to the namespace in double quotes. What I can't understand is where is xmlns
attribute defined?
推荐答案
参见 XML 1.0 W3C 建议中的命名空间,用于定义 xmlns
属性和 xmlns:
前缀.
See Namespaces in XML 1.0 W3C Recommendation for the definitions of both the xmlns
attribute and xmlns:
prefix.
使用xmlns
的原因总结:
Summary of reasons to use xmlns
:
- 使用
xmlns
作为属性来定义一个XML命名空间,它是一个命名标准旨在允许各方独立定义元素和属性名称的词汇表,同时避免命名碰撞. - 使用
xmlns:
作为前缀来定义一个自定义前缀,XML命名空间值可以通过速记引用.
- Use
xmlns
as an attribute to define an XML namespace, which is a naming standard designed to allow parties to independently define vocabularies of element and attribute names while avoiding naming collisions. - Use
xmlns:
as a prefix to define a custom prefix by which an XML namespace value can be referenced by shorthand.
DefaultAttName ::= 'xmlns'
前缀 xmlns:
[2] PrefixedAttName ::= 'xmlns:' NCName
前缀 xmlns 仅用于声明命名空间绑定,由绑定到命名空间名称的定义 http://www.w3.org/2000/xmlns/.它不能被声明.其他前缀不能绑定到这个命名空间名称,并且不得将其声明为默认命名空间.元素名称不得带有前缀 xmlns.
The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. It MUST NOT be declared . Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace. Element names MUST NOT have the prefix xmlns.
参考来自 XML 推荐
注意:
XML 建议中的命名空间 [XML 名称] 赋予意义包含冒号字符的名称.因此,作者不应使用XML 名称中的冒号(命名空间除外),但 XML处理器必须接受冒号作为名称字符.
The Namespaces in XML Recommendation [XML Names] assigns a meaning to names containing colon characters. Therefore, authors should not use the colon in XML names except for namespace purposes, but XML processors must accept the colon as a name character.
这篇关于xmlns 属性在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!