Merits and Demerits of XML DTD's
MERITS:
- For merits refer slide no 22 in xml intro.
DEMARITS:
- Not XML compliant. Cannot be parsed by XML parsers.
- Difficult to extract information from XML applications.
- Closed construct: all defined within one DTD. Not easily extensible.
- Difficult to break down to smaller pieces.
- Type definition not rich. E.g.
- Insufficient types and precisions.
- no int, float, etc.
- No user defined types.
- Do not work well with XML namespaces.
- Difficult to enforce sophisticated constraints.
Example
Create
a DTD for a catalog of four-stroke motorbikes, where each motor bike has the
following child elements-make, model, year, color, engine, chasis number and
accessories. The engine element has the child elements engine number, number of
cylinders, type of fuel. The accessories element has the attributes like disc
brake, auto — start & radio, each of which is required and has the possible
values yes and no. Entities must be declared for the names of the popular
motorbike makes.
<!ELEMENT
Catalog(MotorBike)*>
<!ELEMENT
MotorBike(make, model. Year. Color. Engine. chasis-num. accessories)>
<!ELEMENT
make(*PCDATA)>
<!ELEMENT
model(#PCDATA)>
<!ELEMENT
year(#PCDATA)>
<!ELEMENT
color(#PCDATA)>
<!ELEMENT
engine(engine-num. cylinders-num, fuel-type)>
<!ELEMENT
chasis-num(#PCDATA)> <!ELEMENT accessories disc-brake(yes| no) #REQUIRED
auto-start(yes
| no) *REQUIRED
radio
(yes | no) #REQUIRED>