Saturday, 15 September 2012

Explain: xmlns, xsd, xsi:schemaLocation

This post is a reminder/introduction to some XML related terminology and acronyms.


xmlns stands for XML namespace. This item is used to declare namespaces in XML documents. It allows one use the XML element and attributes of this namespace in the XML document.

Several namespaces can be declared in a single XML document. In order to avoid name collisions, one can add a prefix (i.e., xmlns:myprefix) to differentiate between same XML elements and attributes.
For example:
<?xml version="1.0" encoding="UTF-8"?>
  ... >
The above declares two namespaces, a default one without prefix (security) and one with the beans prefix (beans). One can use all items of the security namespace without prefix, but the elements and the attributes of the bean namespace must be used with the beans prefix, such as <beans:beans ...> and </beans:beans>.


An xsd file defines a XML schema, that is, how elements and attributes of an XML document can interact with each other. Typically, these xsd files are used to validate XML documents.


Once one includes the XML schema instance namespace in a document (typically with xmlns:xsi=""), one can specify the XML schema's location against which the XML document should be validated, with xsi:schemaLocation:

No comments:

Post a comment