E Tensible Arkup Anguage Unit-3: Basic XML DTD XML Schema Dom Vs Sax Presenting XML
E Tensible Arkup Anguage Unit-3: Basic XML DTD XML Schema Dom Vs Sax Presenting XML
Unit-3 Contents
Basic XML
DTD
XML schema
DOM Vs SAX
Presenting XML
XML stands for Extensible Markup Language. It is a
text-based markup language derived from Standard
Generalized Markup Language (SGML).
XML tags identify the data and are used to store and organize
the data
<to>Tony</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me</body>
</note>
<?xml version = "1.0"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
All XML Elements Must Have a Closing Tag
◦ <p>This is a paragraph
◦ <p>This is a paragraph</p>
◦ <Message>This is incorrect</message>
<message>This is correct</message>
XML Elements Must be Properly Nested
XML Documents Must Have a Root Element
◦ <root>
<child>
<subchild>.....</subchild>
</child>
</root>
XML Attribute Values Must be Quoted
◦ <note date=12/11/2007> (Incorrect)
◦ <note date="12/11/2007"> (correct)
Entity References
< < less than
<sex>female</sex>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
Some of the problems with using attributes
are:
◦ attributes cannot contain multiple values (elements
can)
◦ attributes cannot contain tree structures (elements
can)
◦ attributes are not easily expandable (for future
changes)
Attributes are difficult to read and maintain.
Use elements for data. Use attributes for
information that is not relevant to the data.
XML with correct syntax is "Well Formed"
XML.
External DTD
Syntax:
Simple Type
Complex Type
Simple type element is used only in the
context of the text. Some of the predefined
simple types are: xs:integer, xs:boolean,
xs:string, xs:date.
For example -
<xs:element name="xxx" type="yyy"/>
xs:string
xs:decimal
xs:integer
xs:boolean
xs:date
xs:time
The date data type is used to specify a date.
The date is specified in the following form
"YYYY-MM-DD" where:
The following is an example of a date
declaration in a schema:
<xs:element name="start" type="xs:date"/>
"hh:mm:ss" where:
The following is an example of a time
declaration in a schema:
<xs:element name="start" type="xs:time"/>
An element in your document might look like
this:
<start>09:00:00</start>
The boolean data type is used to specify a
true or false value.
The following is an example of a boolean
declaration in a schema:
<xs:attribute name="disabled"
type="xs:boolean"/>
An element in your document might look like
this:
<prize disabled="true">999</prize>
END OF UNIT-3