The statements used to exclude or include a section(s) in DTD are called conditional statements IGNORE and INCLUDE or in other words conditional statements INCLUDE
or IGNORE
are used to add or ignore a part of DTD document respectively. Conditional statements are used with external DTD subset only. The INCLUDE
or IGNORE
sections are mostly used with parameter entity references.
Parameter entity reference
A parameter reference of an entity in DTD can be re-used multiple times in a document. Parameter entities are used with DTD only. The parameter entity reference can be internal as in below example or external. The external parameter entity reference have two types, the public and private. The private types are defined as SYSTEM
and are used by a single author or a group of authors. Public types are for wide public and are intended for broader use.
Syntax for parameter ENTITY
<!ENTITY %name “entity_value”> - Internal Parameter entity reference
<!ENTITY %name SYSTEM “URI”> - Private Parameter entity reference
<!ENTITY %name PUBLIC “public_ID” “URI”> - Public Parameter entity reference
Example of using parameter ENTITY
The example of parameter entities formSchool
and formOffice
with INCLUDE
and IGNORE
conditional statements and their values.
<!ENTITY %formSchool "INCLUDE">
<!ENTITY %formOffice "IGNORE">
<![ %formSchool;[
<!ELEMENT form(name, schoolName)>
]]>
<![ %formOffice;[
<!ELEMENT form(name, officeName, area)>
]]>
Example with external file using parameter ENTITY
genform.dtd:
<!ENTITY % formSchool "IGNORE">
<![ %formSchool;[
<!ELEMENT form (name, schoolName)>
]]>
<!ENTITY % formOffice "INCLUDE">
<![ %formOffice;[
<!ELEMENT form (name, officeName, area)>
]]>
<!ELEMENT name (#PCDATA)>
<!ELEMENT schoolName (#PCDATA)>
<!ELEMENT officeName (#PCDATA)>
<!ELEMENT area (#PCDATA)>
Schoolform.xml:
<?xml version="1.0" encoding="UTF-8" standalone = "no"?>
<!DOCTYPE form SYSTEM "genform.dtd">
<form>
<name>Rakesh</name>
<officeName>CTD</officeName>
<area>RTNagar</area>
</form>
Comments
No comments have been made yet.
Please login to leave a comment. Login now