xsi:schemaLocation
The xsi:schemaLocation
attribute locates schemas for elements and
attributes that are in a specified namespace. Its value is a
namespace URI followed by a relative or absolute URL where the
schema for that namespace can be found. It is most commonly
attached to the root element but can appear further down the tree.
For example, this person
element in the http://www.cafeconleche.org/namespaces/person
namespace claims that it should be validated against the schema
found at http://www.elharo.com/person.xsd:
<person xmlns="http://www.cafeconleche.org/namespaces/person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cafeconleche.org/namespaces/person http://www.elharo.com/person.xsd"> <name> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>
If more than one namespace is used in a document, each
namespace must have its own schema. The namespace URIs and schema
URLs can be listed in sequence in the same xsi:schemaLocation
attribute. For
example, the xsi:schemaLocation
attribute on this person element says that items from the http://www.cafeconleche.org/namespaces/person
namespace should be validated against the schema found at http://www.elharo.com/person.xsd, while items from
the http://www.cafeconleche.org/namespaces/names
namespace should be validated against the schema found at the
relative URL names.xsd:
<person xmlns="http://www.cafeconleche.org/namespaces/person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cafeconleche.org/namespaces/person http://www.elharo.com/person.xsd http://www.cafeconleche.org/namespaces/names names.xsd"> <name xmlns="http://www.cafeconleche.org/namespaces/names"> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>
These are only suggestions. Schema processors are allowed to
use other means of locating the relevant schemas and to ignore the
hints provided by xsi:schemaLocation
.