Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
XML Schema

XML Schema

Ratings: (0)|Views: 124|Likes:
Published by api-25930603

More info:

Published by: api-25930603 on Oct 16, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less






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.

What DTDs cannot provide?
Specific data types for attribute type.
But where as Schemas supports data types for attributes.
A Schema is a set of rules for constraining the structure and articulating the information set of
XML documents.
Advantages of Schema over DTDs

\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

vocabularies and establish inheritance relationships between elements without
invalidating documents.
\ue000XML Schemas support namespace integration, which allows you o associate
individual nodes of a document with type declarations in a schema.
\ue000XML Schemas support attribute groups, which allows you to logically combine
attributes. One of the original proponents of XML Schemas was Microsoft. Microsoft
documentation on
\ue000XML frequently decried DTD as being too complex and said that schemas would fix
the problem. In fact, the Microsoft implementation of XML Schemas in IE was
promptly outdated not long after it was introduced.
XML Schemas in Internet Explorer

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.

Writing XML Schema

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

Serves as the root element for XML schema documents
Describes data types for elements and attributes
Describes a type of element
Identifies an element that can occur with in another element type
Organizes elements into groups for ordering purposes
Attribute type
Describes a type of attribute
Identifies an attribute that can occur within an element type
Provides documentation for an element or attribute
The Schema Element
The schema element serves as the root (document) element for XML schema documents and acts as
a container for all other schema content. The schema element includes two attributes
The name of the schema
The namespace for the schema

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.

In addition to specifying the namespace for the schema, usually it is also necessary to specify the
namespace for XML schema data types. The data type namespace is typically assigned to the
xmlns:dt attribute and is set to urn: schemas-microsoft-com:datatypes. You must set this
namespace in order to use any of the XML schema datatypes, such as date, time, int and float.
<Schema name="myschema "xmlns="urn:schemas-microsoft-com:xml-data"
<! --Schema content goes here-->

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 ElementType Element

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.

The ElementType element includes several attributes for defining the specific parameters of the
element type:
The name of the element
Whether the content model is open or closed
The type of content contained within the element
The order of the child elements and groups contain within the element
The type of the element
The following are the examples of element types defined using the ElementType 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">
<element type="name"/>

Activity (10)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Krishna Kumar liked this
jayavardhankoti liked this
bharat liked this
athirai liked this
sujitha14 liked this
Rishi Goenka liked this
wanliammar liked this
mssiddiqui liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->