I would like to do something like this:
<root:secondlevel:thirdlevel
xmlns:secondlevel="http://secondlevel.com"
xmlns:secondlevel:thirdlevel="http://thirdlevel.com">
</root:secondlevel:thirdlevel>
Is there a way to do those multiple levels root:secondlevel:thirdlevel
as valid XML?
No, there can be at most one namespace prefix in XML.
The XML Namespace BNF rules for names are based on QName, which allows only a single
PrefixedName
:Neither
Prefix
norLocalPart
allow colon (:
) characters, so there can be at most one colon (and at most onePrefix
) part to aQName
.Side note: multiple colons are syntactically allowed in base level XML:
But the W3C XML Recommendation is clear that colons should not be used except for namespaces purposes:
And Namespaces do not allow multiple namespace prefixes as shown above.
See also: