Exforsys.com
 

Sponsored Links

 

XML Tutorials

 
Home Tutorials XML
 

XML - Elements in Document Type Definitions (DTD)

 
Category: XML
Comments (0)

XML - Elements in Document Type Definitions (DTD)

Page 1 of 3

XML - Elements in Document Type Definitions (DTD)

In this tutorial you will learn about Elements in DTD, Elements, child elements (nested elements), declaring elements with character data only, declaring elements with mixed content, declaring elements with any content, declaring elements with no content and element order indicators and qualifiers.



Elements in DTD.


ELEMENTS

Every element used in the valid XML document must be declared in the Document’s DTD.


SYNTAX : < !ELEMENT element_name content_specification >


element_name: Specifies name of the XML tag
Content_specification: Specifies the contents of the element which could of the following five types


I) Standard Content
II) Only Character Data
III) Mixed Content
IV) AnyType of Content
V) No Content


CHILD ELEMENTS (NESTED ELEMENTS)

Most Element declarations define one or more child elements.


For Example, < !ELEMENT customer (customer_name) >


Here , Element customer contains one and only one nested element i.e. customer_name


< !ELEMENT Address (Name, Street, City) >


Here, element Address contains three nested elements Name, Street and City respectively

SYNTAX: < !ELEMENT parent (child) >


OR


< !ELEMENT parent (child1,child2, . . . , childN) >


DECLARING ELEMENTS WITH CHARACTER DATA ONLY

Top level elements generally contain other elements but low-level elements may contain parsed character data. In XML, #PCDATA is the keyword to declare elements with parsed character data. An element declared as #PCDATA
Can contain character data
Can contain Entities such as <, >
Cannot contain other elements

SYNTAX < !ELEMENT element_name (#PCDATA) >


Example:


< !ELEMENT Street (#PCDATA) >


• Element Street contains the parsed character data


#CDATA is another keyword to declare character data. But unlike #PCDATA, whitespaces are retained as it is in #CDATA.




SYNTAX < !ELEMENT element_name (#CDATA) >

Example: < !ELEMENT City (#CDATA) >


Here, DTD declares the City element to contain character data.
In XML, document < City > London < /City >
The XML, parse will take take the data as “ London ” and not as “London”
as in the case of #PCDATA


Next Page: XML - Elements in Document Type Definitions (DTD) - Page 2


Read Next: XML Advantages



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape