(e-mail address removed) (Magnus Lie Hetland) wrote in message
I'm not sure what you mean exactly by "without access to...". You need
a Document instance to create the elements, but they aren't added
automatically to it.
[snip]
Right. I understand this. Thanks to you and Martin for mentioning it,
though
My problem is that I'm building the DOM as part of a bottom-up parse,
where the various subtrees are build independently from each other,
through callbacks that are set as part of the parser. So... For all of
these to have access to a document object (so they can use the
createFoo methods) I'd have to either (1) hard-code a document into
the parser (meaning, basically, that each parser instance can only be
used once), or (2) refactor the parser to supply a context object to
each callback (which could be, for example, the document object).
I guess the latter is the way to go, but it does seem awkward that it
should be necessary. In my case it's OK, as the parsing code is part
of my project, but if I used an external parser, I'd have to create a
separate AST and then translate that into a DOM tree afterward; a bit
unnecessary...
Oh, well. Can't argue with the DOM, I suppose