Question

What is the importance of a namespace in a XSD schema? Why is namespace used in a schema? It often resembles a URL which doesn't point to anything.

Can anyone please give more insight on the namespaces and their significance with an example ?

Was it helpful?

Solution

The URI used as the namespace signifier does not have to actually point to anything. It is merely intended as a semi-human-readable unique identifier to that particular namespace. It often does look like a URL, but it doesn't have to be; the spec specifies URI, so it could be a URN, for example, in which case it definitely would not point to anything.

As for why namespaces are used, they enable mixing multiple schemas in a single XML document, while still ensuring that even if schemas have identically-named elements, it can still be determined which namespace a particular element belongs to. For example, the Dublin Core namespace is used to assign metadata to various resources. Sure, you could just have this information as part of your own schema, but by using DC elements, you are using a well-established set of elements and attributes that are understood by many more tools. DC can be added on to HTML, RDF, Atom, and many other XML-based schemas.

You can read more about XML namespaces on Wikipedia.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top