- XML Schema: An Overview
- Element and Attribute Declarations
- Types
- Namespaces
- Multiple Schema Documents
- Specifying a Schema Location
- Additional Features
Specifying a Schema Location
XML documents can be linked with their schemas using the schemaLocation attribute. The schemaLocation attribute actually takes pairs of values, each pair consisting of a namespace name and a schema location, separated by white space. Example 8 is telling us that the processor can find declarations for elements and attributes in the http://example.org/emp namespace at the location emp.xsd. Because the schemaLocation attribute itself is in the http://www.w3.org/2001/XMLSchema-instance namespace, it is necessary to declare this namespace and map it to a prefix, usually xsi.
Example 8. Specifying a Schema Location
<emp:employee xmlns:emp="http://example.org/emp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.org/emp emp.xsd" hireDate="2001-04-02"> <number>557</number> <status>FT</status> </emp:employee>