tags:

views:

606

answers:

2

Is it legal to use no targetNamespace attribute or an empty one in an Xml schema?

If so then what does it mean, are we "adding" something to the "empty namespace" (which always exists) or creating an "anonymous namespace" which is not related to other schemas?

How would an instance xml document look like, do elements need to be explicitly bounded to some namespace?

A: 

Yes, definitely. XML namespaces are optional - you can leave them out if you wish to do so, and if you don't get into any trouble with ambigious XML elements in your "XML world" :-)

Marc

marc_s
+1  A: 

See XML Schema Part 0: Primer for a very concise description of how undeclared targetNamespaces work.

As for an empty targetNamespace, that's not valid. From the spec:

Since the empty string is not a legal namespace name, supplying an empty string for targetNamespace is incoherent, and is not the same as not specifying it at all. The appropriate form of schema document corresponding to a ·schema· whose components have no {target namespace} is one which has no targetNamespace attribute specified at all.

Jaka Jančar