Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Question about Multiple Attlist declarations

 
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 ..
 
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.
 
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;
 
She'll be back. I'm just gonna wait here. With this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic