I'm confused about how the various DOM node types fit in with DTDs.
Okay, so the W3C DOM specification categorizes XML/HTML components into nodes (which most of us are familiar with through Javascript programming or XML parsing.)
The nodes types are:
Document
DocumentFragment
DocumentType
EntityReference
Element
Attr
ProcessingInstruction
Comment
Text
CDATASection
Entity
Notation
What confuses me here are the idea of Entity nodes.
I understand what an Entity node is - it basically let's you define an "entity" which can later be references using the &; syntax, and expanded. It's sort of like a way to use variables in XML.
Okay, but what really confuses me is that, as far as I understand, Entity nodes generally can only appear within DTDs (Document Type Declarations.) But a DTD is really a totally separate format from XML, with totally separate node types, like !ELEMENT nodes, !ATTLIST nodes and !ENTITY nodes. A DTD can be embedded within an XML document using the ubiquitous !DOCTYPE declaration, but my question is:
Why are !ENTITY nodes specifically given a node type in the W3C DOM specification, whereas other DTD node types aren't? Why don't we see !DOCTYPE nodes and !ELEMENT nodes and !ATTLIST nodes in the W3C DOM model? Why are only !ENTITY nodes included as a node type?
No comments:
Post a Comment