alt
Advertisement
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow XML arrow XML - Elements in Document Type Definitions (DTD)
Site Search


XML - Elements in Document Type Definitions (DTD)
Article Index
XML - Elements in Document Type Definitions (DTD)
Page 2
Page 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



 
< Prev   Next >
Sponsored Links
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape