In the previous chapter we learnt DTD that is Traditional way of validating an XML document, which were inherited from SGML. Over many times people have complained to the W3C about the complexity of DTDs and have asked for something simpler. W3C for the above complaint assigned a committee to work on the problem, and came up with a solution, which is more complex than DTDs called XML Schemas. On the other hand XML Schemas are also far more powerful than DTDs ever- were.
\ue000XML Schema is based on XML, not some specialized syntax.
\ue000XML can be parsed and manipulated just like any other XML document.
\ue000XML Schemas support a verity of data types (int, floats, Booleans, dates, Strings...)
\ue000XML Schemas present an open-ended data model, which allows you to extend
As with many other developers, Microsoft got caught basing its software on a relatively early XML specification, which promptly changed. As implemented in IE, Microsoft's Schemas are based on the XML data.
The DTD is very straight forward, primarily because XML schema is a pretty simple vocabulary by most standards. The root element of all XML schema documents is schema, which is declared in the DTD as potentially containing three child elements: AttributeType, ElementType and Description. In addition to these elements, the XML schema vocabulary declares several other elements that are used to describe document schemas. The following are the elements that make you the XML schema vocabulary
The name attribute establishes the name of the schema. The Xmlns attribute is very important in that it establishes the namespace for the schema. This attribute must be set to urn: schemas-microsoft-com: xml -data in order to use Microsoft's XML schema implementation.
<Schema name="myschema" xmlns="urn:schemas-microsoft-com: xml -data">
<!--schema content goes here-->
</ Schema >
Namespace are used in XML documents to guarantee uniqueness among element and attribute names associated with a given XML vocabulary. Namespaces take the form of URLs, which are often the familiar URLs, used to identify resources on the Web.
The schema element can contain child elements of type AttributeType, ElementType and Description. The AttributeType and ElementType elements define attribute types and element types.
The Element Type element is used to define element types that establish the schema of documents. The ElementType element can contain datatypes, element, group, AttributeType, attribute and Description child elements. The element attribute identifies an instance of a child element with in the element; you use the element attribute to establish the content model for an element type.
Attributes for an element type are established using the AttributeType and attribute elements. The AttributeType element defines a type of attribute, while the attribute element identifies an actual attribute of the element type. Any attribute types defined with in an ElementType element are considered local to that element.
<ElementType name="name" content="textOnly" dt:type="string"/>
<ElementType name="type" content="textOnly" dt:type="string"/>
<ElementType name="product" content="eltOnly" model="closed" order="seq">
This action might not be possible to undo. Are you sure you want to continue?