I have a rather fundamental question about XML here. When declaring an element’s xmlns attribute, is it ever legal to use http://www.w3.org/2001/XMLSchema? And when declaring the xmlns:xsi attribute, is it legal to use http://www.w3.org/2001/XMLSchema-instance as the value?
I ask this because I have seen XML auto-generated by some XML editors which references these namespaces, and yet (at least on the XMLSchema-instance page) W3C says that “This schema should never be used as such: the XML Schema Recommendation forbids the declaration of attributes in this namespace”.
So I’m confused; is it always illegal to say something like:
<?xml version="1.0" encoding="UTF-8"?>
<myElement xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
[...]
</myElement>
… and if not, why does W3C seem to say that the namespace should never be used? What would one use it for? I’ve tried to read the XML 1.0 spec but it’s extremely verbose and difficult to understand.
That namespace should not be used for anything else. It must be used to reference the attributes declared within that namespace.
You may not declare any elements or attributes within a namespace that belongs to someone else. This means you may not declare your
myElementwithin the “XMLSchema” namespace.