2 – Start writing the first schema
< jacob:schema xmlns:jacob ="http://www.w3.org/2001/XMLSchema">
</ jacob:schema >
Listing 2.13: Example of a schema using non-standard namespace prefix.
Though you can change the namespace prefix, you cannot touch the namespace URI. The namespace URI should always be http://www.w3.org/2001/XMLSchema
.
Note that namespace URIs are case sensitive. Your schema will be invalid if you do not use the correct namespace name with correct casing.
Adding an element
The schema that we defined in the previous section was empty. It did not declare any element that should exist in the XML instance document.
We will use the term XML Instance Document to refer to an XML document that we intend to validate with a given schema.
Let us modify our schema and add an element declaration.
< xsd:schema xmlns:xsd = " http://www.w3.org/2001/XMLSchema " >
< xsd:element name = " Greetings " />
</ xsd:schema >
Listing 2.14: A schema with an element declaration.
The above schema declares a root element named
Greetings
. The XML
Instance Document of this schema should contain a root element named
Greetings.
Here is a valid XML instance document which successfully validates against this schema.
< Greetings > Welcome to XSD Workshop!
</ Greetings >
Listing 2.15: An XML instance document which validates against the schema in Listing 2.14.
31