Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Features

Technology
  Tech. Home
  GPS
  OSI
  WiMAX
  VoIP
  WiFi
  HSDPA
  LBS
  Vehicle Tracking
  SCADA
  Tech. What is?
Jobs At RoseIndia.net!
 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

DTD-Elements

                         

In a DTD, elements are declared with an ELEMENT declaration.

Declaring Elements : syntax

In a DTD, XML elements are declared  with the following syntax:

<!ELEMENT element-name category>
or
<!ELEMENT element-name (element-content)>

Empty Elements

Empty elements are declared with the  keyword EMPTY inside the parentheses.

<!ELEMENT element-name EMPTY>
DTD Example: <!ELEMENT br EMPTY>
In XML document: 
  <br />

Elements with Parsed Character Data

Elements with only parsed character data are declared with  #PCDATA inside the parentheses:

<!ELEMENT element-name (#PCDATA)>

DTD Example :

<!ELEMENT To (#PCDATA)>
<!ELEMENT From (#PCDATA)>

Elements with Data

Elements declared with the keyword ANY, can contain any combination of parsable data:

<!ELEMENT element-name ANY>
DTD Example:
<!ELEMENT E-mail (To,From,Subject,Body)>
<!ELEMENT To (#PCDATA)>
<!ELEMENT From (#PCDATA)>

Elements with Children (sequences)

Elements with one or more children are declared with the name of the children elements inside the parentheses as :

<!ELEMENT element-name (child1)>
or
<!ELEMENT element-name (child1,child2,...)>
DTD Example:
<!ELEMENT E-mail (To,From,Subject,Body)>

When children are declared in a sequence separated by commas, the children must appear in the same sequence in the document. In a full declaration, the children must also be declared.Children can  have children. The full declaration of the "E-mail" element is:

<!ELEMENT E-mail (To,From,Subject,Body)>
<!ELEMENT To (#PCDATA)>
<!ELEMENT From (#PCDATA)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Body (#PCDATA)>

Declaring Only One Occurrence of an Element 

<!ELEMENT element-name (child-name)>
DTD Example:
<!ELEMENT  color  (Fill-Red)>

The example above declares that the child element "Fill-Red" must occur once, and only once inside the "color" element.

Declaring Minimum One Occurrence of an Element

<!ELEMENT element-name (child-name+)>
DTD Example:
<!ELEMENT color  (Fill-Red+)>

The '+' sign in the example above declares that the child element "Fill-Red" must occur one or more times inside the "color" element.

Declaring Zero or More Occurrences of an Element 

<!ELEMENT element-name (child-name*)>
DTD Example:
<!ELEMENT color (Fill-Red*)>

The '*' sign in the example above declares that the child element  "Fill-Red" can occur zero or more times inside the "color" element.

Declaring Zero or One Occurrence of an Element 

<!ELEMENT element-name (child-name?)>

DTD Example:

<!ELEMENT color (Fill-Red?)>

The '?' sign in the example above declares that the child element "Fill-Red"  can occur zero or one time inside the "color" element.

Declaring either/or Content

DTD Example:

<!ELEMENT E-mail (To,From,Subject,(Message|Body))>

The example above declares that the "E-mail" element must contain a "To" element, a "From" element, a "Subject" element, and either a "Message" or a "Body" element.

Declaring Mixed Content

DTD Example:

<!ELEMENT E-mail(#PCDATA|To|From|Subject|Body)*>

The example above declares that the "E-mail" element can contain zero or more occurrences of a parsed character data, "To", "From", "Subject", or "Body" elements.

                         

Ask programming questions?

 

 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.

[an error occurred while processing this directive]