|
|
XML elements can be defined as building blocks of an XML manuscript. Elements can behave as a container to hold text, elements, attributes, media substance or mix of all.
A DTD constituent is declared with an ELEMENT declaration. When an XML file is validating by DTD, parser primarily checks for the root constituent and then the child elements are validate.
All DTD component declaration has this general form:
Content of elements declaration in a DTD can be considered as below:
This is a particular case of element declaration. This element declaration does not hold any content. These are confirmed with the keyword EMPTY.
Following is the syntax for empty element declaration:
In the above syntax:
Following is a simple instance representing empty element declaration:
In this instance address is affirmed as an empty element. The mark-up for address element would appear as <address />.
In element declaration with element content, the content would be acceptable elements within parentheses. We can also contain more than one constituent.
Following is syntax of element declaration with element content:
Below example demonstrates a simple instance for element statement with element content:
In the above instance, address is the parent element and name, company and phones no are its child elements.
Below table show the list of operators and syntax rules which can be functional in defining child fundamentals:
Operator | Syntax | Description | Example |
---|---|---|---|
+ | <!ELEMENT element-name (child1+)> | It indicates that child element can occur one or more times inside parent element. | <!ELEMENT address (name+)>
Child elementnamecan occur one or more times inside the element nameaddress.
|
* | <!ELEMENT element-name (child1*)> | It indicates that child element can occur zero or more times inside parent element. | <!ELEMENT address (name*)>
Child elementnamecan occur zero or more times inside the element nameaddress.
|
? | <!ELEMENT element-name (child1?)> | It indicates that child element can occur zero or one time inside parent element. | <!ELEMENT address (name?)>
Child elementnamecan occur zero or one time inside the element nameaddress.
|
, | <!ELEMENT element-name (child1, child2)> | It gives sequence of child elements separated by comma which must be included in the the element-name. | <!ELEMENT address (name, company)>
Sequence of child elementsname,company, which must occur in the same order inside the element nameaddress.
|
| | <!ELEMENT element-name (child1 | child2)> | It allows making choices in the child element. | <!ELEMENT address (name | company)>
It allows you to choose either of child elements i.e.nameorcompany, which must occur in inside the element nameaddress.
|
We need to follow definite rules if there is more than one element satisfied:
The declaration indicates that the <address> element must have exactly three children - <name>, <company>, and <phone> - and that they must appear in this order.
This is the grouping of (#PCDATA) and children elements. PCDATA stand for parsed character data, that is, text that is not mark-up. Within mixed substance models, text can appear by itself or it can be interspersed between elements. The rules for mixed substance models are related to the element content as discussed in the previous section.
Following is a common syntax for mixed element content:
Following isa simple instance demonstrating the mixed content element statement in a DTD.
You can declare an element using the ANY keyword in the content. It is most frequently referred to as mixed group element. ANY is useful when you have yet to make a decision the allowable inside of the element.
Following is the syntax for declare basics with ANY substance:
Here, the ANY keyword indicates that text (PCDATA) and/or any elements affirmed within the DTD can be used within the substance of the <element name> element. They can be used in any order any number of times. However, the ANY keyword does not allow you to contain fundamentals that are not declared within the DTD.
Following is a simple instance representative the element declaration with ANY satisfied:
|
|
Document Type Definition (DTD) Related Tutorials |
|
---|---|
UML Tutorial | XML Tutorial |
J2EE Tutorial | Hibernate Tutorial |
Maven Tutorial | Apache Ant Tutorial |
XML DOM Tutorial |
Document Type Definition (DTD) Related Interview Questions |
|
---|---|
UML Interview Questions | XML Interview Questions |
J2EE Interview Questions | Hibernate Interview Questions |
Maven Interview Questions | Apache Ant Interview Questions |
XSLT Interview Questions | MathML Interview Questions |
XML DOM Interview Questions | Xml Publisher Interview Questions |
Document Type Definition (DTD) Related Practice Tests |
|
---|---|
UML Practice Tests | XML Practice Tests |
J2EE Practice Tests | Hibernate Practice Tests |
Maven Practice Tests | XSLT Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.