是否允许前缀不匹配的元素?

Are elements with mismatched prefixes allowed?

"Common Syntatic Constructs" section of the XML 1.0 Recommendation 包含以下注释:

The Namespaces in XML Recommendation 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.

这意味着以下内容无效XML:

<xhtml:span
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:html="http://www.w3.org/1999/xhtml">
  <xhtml:a>Anchor text</html:a>
</xhtml:span>

但是,the "Qualified Names" section of the Namespaces in XML Recommendation 包含此语句:

Note that the prefix functions only as a placeholder for a namespace name. Applications SHOULD use the namespace name, not the prefix, in constructing names whose scope extends beyond the containing document.

这会导致歧义。当发生这种情况时,XML 建议是否具有优先权,使上述文档无效,或者命名空间感知 XML 处理器是否应该首先将前缀转换为其适当的命名空间并认为上述文档有效?

名称空间建议在第 7 节(一致性)中指出:

To conform to this specification, a document MUST be well-formed according to the XML 1.0 specification [XML].

因此开始和结束标记中使用的前缀必须匹配。