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 2

Page 2 of 3


.


.




DECLARING ELEMENTS WITH MIXED CONTENT

At times it is required to declare elements with mixed content i.e. both data and other elements. In such situations the pipe symbol (|) is used.

SYNTAX < !ELEMENT parent (#CDATA or #PCDATA,child1,child2, . . . , childN) >

Example:

< bank >
This account is Active
< account >123456< /account >
This account is Closed
< account >423578< /account >
< /bank >


DECLARING ELEMENTS WITH ANY CONTENT

In Real world scenarios, the developer is many a times not sure about the exact document structure while creating the DTD. At such times, ANY keyword comes handy. An element declared as ANY can


  • Contain child elements
  • Contain character data
  • Contain mixed content

SYNTAX: < !ELEMENT element_name ANY >


DECLARING ELEMENTS WITH NO CONTENT

Sometimes it is required that an elements has only attributes but no data. In such scenarios the EMPTY keyword is used.

SYNTAX : < !ELEMENT element_name EMPTY >


ELEMENT ORDER INDICATORS AND QUALIFIERS

The various order and qualification governing symbols are listed in the table append below



ORDER




QUALIFIER




TYPE


VALUE


CONTEXT


DESCRIPTION


|


Choice


Either one child element or another can occur


()


Group


Groups related elements together


,


Sequence


Element must follow another element


?


Optional


Elements appear once or not at all


*


Optional and Repeatable


Elements appear zero or more times


+


Required and Repeatable


Elements appear one or more times


EXAMPLES:

The pipe symbol (|) specifies choice. So occurrence of either of the chiold element is considered valid by the parser.

Following declaration specifies that name must contain either first_name or last_name

< !ELEMENT name (fist_name | last_name) >



Thus,
< name >
< first_name >Nick< /first_name >
< /name >

as well as

< name >
< last_name >Price< /last_name >
< /name >

are valid.




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


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 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape