XML Namespace Leitfaden
Referenz für XML namespaces, prefix binding, und 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
- xmlns:prefix
- Prefix binding
- URI
- Identifier not address
no prefix needed ns:element 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
- QName
- Prefix in value
- identity
- URI matters, not prefix
must use prefix xsi:type="ns:Type" prefix is alias