![]() ![]() |
We have examined the XML schema for the employeeList XML and have explained the various elements that make up the schema definition. In this section, we take a look at how the schema is tied to the employeeList XML instance and briefly describe how a simple JAXP program is used to parse and validate the XML.
The targetNamespace declaration signifies that all elements defined in the schema (employeeList, employee, email, etc.) belong to the www.flute.com namespace. In turn, the XML instance document for Flute employeeList signifies that all elements used in the instance document belong to the www.flute.com namespace.
The instance document also provides a hint to the XML processor as to the location of the schema, using the schemaLocation attribute. This attribute contains a pair of values separated by whitespace: The first value (http://www.flute.com)is the namespace, and the second (employee.xsd) is the location of the appropriate schema document. Note that the values provided by this attribute are only a hint and that the processor is free to use other schemas obtained by other means.
Listing A.2 uses JAXP API to invoke the Apache Xerces validating parser to validate the employee XML with the employee schema. The Xerces parser comes with the JAVA WSDP 1.0 download.
![]() ![]() |