posted 22 years ago
Here is the deal;
1) An internal subset always overrides the external subset declaration (something like the derived type choosing to have its own behaviour in OO programming)
Example:-
External dtd - sample.dtd
<!ELEMENT aa (#PCDATA)>
<!ATTLIST aa bb CDATA #FIXED "bb">
Xml file(sample.xml) with internal dtd subset overriding the external declaration for attribute bb -
<!DOCTYPE aa SYSTEM "sample.dtd"[
<!ATTLIST aa bb CDATA #REQUIRED>
]>
As this attribute bb is required as per the internal dtd subset,
<aa /> will be an invalid element with missing attribute bb, where as
<aa bb="cc"/> would be a valid element
2) If the same attribute is declared twice in the same subset(external or internal) of the dtd, the latter declaration will not be respected; Hence
External dtd - sample.dtd
<!ELEMENT aa (#PCDATA)>
<!ATTLIST aa bb CDATA #FIXED "bb">
<!ATTLIST aa bb CDATA #REQUIRED>
Xml file(sample.xml) -
<!DOCTYPE aa SYSTEM "sample.dtd"[
]>
<aa/> will be a valid xml document as the #FIXED declaration will be respected;
In a nutshell, the internal subset declaration( if any) will have the final say and in any given subset, the first !ATTLIST declaration for any given element will always be respected;
Any one please correct me for any mistakes;