Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

element with ANY content

 
Serge Adzinets
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got a question in a mock exam, if this document is valid. The answer was no, because though an element was declared with ANY content, it could contain only declared elements. I guess this is wrong. Any thoughts?

 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Siarhei Adzinets:
Got a question in a mock exam, if this document is valid. The answer was no, because though an element was declared with ANY content, it could contain only declared elements. I guess this is wrong. Any thoughts?


No. It is correct !!
Here is the quote from the DTD specs


Well-formedness constraint: Element Type Match

The Name in an element's end-tag MUST match the element type in the start-tag.

An element is valid if there is a declaration matching elementdecl where the Name matches the element type, and one of the following holds:

The declaration matches ANY, and the content (after replacing any entity references with their replacement text) consists of character data and child elements whose types have been declared.





To see more see this link
http://www.w3.org/TR/REC-xml/

and search for "Validity constraint: Element Valid" using "find box" in Edit menu in IE

Hope this helps
 
Serge Adzinets
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hari,

Tried to parse the file with Xerces and got an error
I was in doubt because "XML Professional" doesn't mention this important detail.

Tnanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic