• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Question about Multiple Attlist declarations

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could overide the declaration by using an internal DTD to overide the declarations made in an external DTD.
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic