コンテンツへスキップ
uencoder

XML Namespace ガイド

リファレンス 用 XML namespaces, prefix binding, および default namespace handling.

Namespace Basics

XML namespaces disambiguate element and attribute names by associating them with URIs. The xmlns attribute declares a default namespace; xmlns:prefix binds a prefix. Namespaces are URIs, not URLs; they need not be resolvable. The same local name in different namespaces are distinct elements. Namespaces enable mixing vocabularies (e.g., XHTML + SVG + MathML) in one document.

xmlns
Default namespace
no prefix needed
xmlns:prefix
Prefix binding
ns:element
URI
Identifier not address
need not resolve

Practical Issues

Default namespaces do not apply to attributes; attributes are unprefixed or use a prefix. Namespace prefixes are arbitrary; only the URI matters for identity. QNames in attribute values (e.g., xsi:type) require prefix-to-URI mapping. The XML Namespaces 1.1 spec allows undeclaring prefixes. Correct namespace handling is essential for schema validation and XPath/XSLT.

attributes
No default namespace
must use prefix
QName
Prefix in value
xsi:type="ns:Type"
identity
URI matters, not prefix
prefix is alias

関連ツール

参考链接