SDOM
I find that public support forums like IRC are useful even
when nobody answers your question -- even when nobody even
acknowledges that you asked a question. This is because
that is what often happens (at least, to me) when the
question itself is totally wrongheaded. Getting the online
equivalent of crickets chirping in a silent auditorium tells
me that I need to go back and check the assumptions that led
me to ask in the first place.
Case in point, I've been trying to get someone in Freenode
#xml to explain how entity dereferencing could possibly be
sanely implemented in the context of the DOM. Because an
entity reference can be expanded, as per the DOM
recommendation, into practically any of the full set of DOM
Node types, I wanted to know what a reasonable DOM
implementation would be expected to do with a situation like:
<!ENTITY ent ""><foo
attr="baz"></foo>">
...
<foo
attr="bar&ent"></foo>
If the expansion lead to:
<foo attr="bar"><foo
attr="baz"></foo></foo>
...that would be problematic for my DOM implementation,
since the parent of the entity reference and any nodes that
came after it in the document order could have the meanings
modified or positions changed, and I'd probably have to pass
a serialized version of the entire document back through the
XML parser. The proposition filled me dread.
But when I didn't have any luck on IRC, I went back to the
DOM recommendation and eventually realized that I didn't
have much of a problem after all -- regardless of where
entity references can appear during XML parsing, when you're
manipulating the DOM they can only be added as proper
children of nodes, and not as children of text or CDATA
sections. The only case that has to be taken care of is
something like this:
<foo
attr="bar">&ent</foo>
No sweat!