Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Multiple Attlist declarations

 
Prasad Joshi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XML specification says this regarding multiple Attlist declarations "When more than one AttlistDecl is provided for a given element type, the contents of all those provided are merged. When more than one definition is provided for the same attribute of a given element type, the first declaration is binding and later declarations are ignored" ..is it true that this support is provided for over-riding attribute declarations using the internal subset..?? coz if its true ..how can we override the declaration , when the first one is always binding ..
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could overide the declaration by using an internal DTD to overide the declarations made in an external DTD.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic