Wednesday, 22 December 2010

Why is the W3C XML Schema important?  Give examples of its role.

# XML is established based on two facts, represent documents and data as trees and represent the types of documents and data using tree grammars. Tree grammars are represented based on DTDs or XML Schema. In additional, W3C XML schema was the initial separate schema language for XML to get recommendation status by W3C. Due to the confusion of XML schema as a specific W3C specification and use of the same term to describe schema languages in general, some referred it as WXS, and rest referred as XSD.
W3C XML schema provides a mechanism for specifying the structure and constraints on XML documents. They offer a means for describing the structure, content and semantics if XML documents in more details. It is more powerful than DTDs. Among other things, it uses a uniform XML syntax, supports derivation of documents types, permits al groups and nested definitions and provides automatic data types in addition to character data.  Below is some more importance of W3C XML Schema:
  • One of the most significance of XML Schemas is its support for data types. With support for data types it makes easier for many works such as to describe document content, validate the correctness of data, work with data from a database, convert data between different data types, etc. For instance, below is the simple schema document to describe student details.



<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
  <xs:element name="StudentDetails">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="StudentID" type="xs:string" minOccurs="0"/>
        <xs:element name="Name" type="xs:string" />
        <xs:element name="Course" type="xs:string" />
        <xs:element name="Year" type="xs:string" />
        <xs:element name="Email" type="xs:string" />
         </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>  
  • Another great strength of XML Schema is written in XML. Because of those benefits we don’t have to learn a new language if we have knowledge about XML, can use XML editor to modify the schema files, can use XML parser to parse schema files, etc.
  •  XML Schemas are extensible in nature because they are written in XML. And with this features of XML Schema we can reuse schema on other schemas, we can create individual data types resulting from the standard types, reference multiple schemas in the same document.
  • The XML document should always be in well-formed and for that the document should follow all the rules of the XML syntax. But even if documents are well-formed they can still have some errors and that can be a serious problem which can be caught by the use of XML Schema.

No comments:

Post a Comment