Java Reference
In-Depth Information
<xs:element name="ingredients">
<xs:complexType>
<xs:sequence>
<xs:element
ref="ingredient"
maxOc-
curs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ingredient">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="qty"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
After creating the schema, you'll want to reference it from a recipe document. Ac-
complishthistaskbyspecifying
xmlns:xsi
and
xsi:schemaLocation
attributes
on the document's root element start tag (
<recipe>
), as follows:
<recipe xmlns="http://www.tutortutor.ca/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-in-
stance"
xsi:schemaLocation="http://www.tutortutor.ca/
schemas recipe.xsd">
ment's default namespace. Unprefixed elements and their unprefixed attributes belong
to this namespace.
The
xmlns:xsi
attributeassociatestheconventional
xsi
(XMLSchemaInstance)
prefix with the standard
http://www.w3.org/2001/XMLSchema-instance
namespace. The only item in the document that's prefixed with
xsi:
is
schem-
aLocation
.
The
schemaLocation
attributeisusedtolocatetheschema.Thisattribute'svalue
canbemultiplepairsofspace-separatedvalues,butisspecifiedasasinglepairofsuch