Home | | Web Technology | XML DTD vs XML Schema

Chapter: Web Technology : Representing Web Data

XML DTD vs XML Schema

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

XML Element

 

An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can contain:

 

-  other elements

-  text

-  attributes

-  Or a mix of all of the above...

 

XML vocabulary:

 

XML vocabulary is used to define - element and attribute names

-  element content

-  Semantics of elements and attributes

 

 

Some of the xml vocabularies are XHTML, RSS, XSL, DTD, and Schema

 

XML DTD:

 

Document Type Definition purpose is to define the structure of an XML document. It defines the structure with a list of defined elements in the xml document.

 

<!DOCTYPE note

[

 

<!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>

 

]>

 

Where PCDATA refers parsed character data. In the above xml document the elements to, from, heading, body carries some text, so that, these elements are declared to carry text in DTD file.

 

This definition file is stored with .dtd extension.

 

XML Schema:

 

It is an alternative to DTD to define the structure of an XML document. <xs:element name="note">

 

<xs:complexType>

<xs:sequence>

 

<xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence>

 

</xs:complexType>

 

</xs:element>

This definition file is stored with .xsl extension.

 

XML DTD vs XML Schema:

 

The schema has more advantages over DTD. A DTD can have two types of data in it, namely the CDATA and the PCDATA. The CDATA is not parsed by the parser whereas the PCDATA is parsed. In a schema you can have primitive data types and custom data types like you have used in programming.

 

XML Parsers:

 

An XML parser converts an XML document into an XML DOM object - which can then be manipulated with a JavaScript.\

 

Two types of XML parsers:

– Validating Parser

It requires document type declaration

It generates error if document does not

– Conform with DTD and

– Meet XML validity constraints

– Non-validating Parser

It checks well-formedness for xml document

It can ignore external DTD

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Web Technology : Representing Web Data : XML DTD vs XML Schema |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.