I started work where some XML and DTD files were provided to me. They work fine, but I noticed that in DTD they reused such an element.
DTD:
<!ELEMENT image EMPTY>
<!ATTLIST image
source CDATA
signature (true|false|1|0) "false"
>
and in xml the image element is displayed in two places, but only one of the places requires the attribute 'signature', otherwise it does not matter.
XML:
<root>
<element-with-optional-signature-image>
<image source="1.jpg" singature="true" />
<image source="2.jpg" />
</element-with-optional-signature-image>
<other>
<image source="3.jpg" />
</other>
</root>
I have never seen a DTD written this way before, and just wondered if this is the usual or really bad way to do this? I would create two different elements element-imageand other-image.
EDIT -
The above is also accepted as a DTD, for example:
<!ELEMENT element-image EMPTY>
<!ATTLIST element-image
source CDATA
signature (true|false|1|0) "false"
>
<!ELEMENT other-image EMPTY>
<!ATTLIST image
source CDATA
>
with XML as follows:
<root>
<element-with-optional-signature-image>
<element-image source="1.jpg" singature="true" />
<element-image source="2.jpg" />
</element-with-optional-signature-image>
<other>
<other-image source="3.jpg" />
</other>
</root>
source
share