>1) Is my implementation of the extension functions buggy, because is >it e.g. forbidden to construct (and indirectly return) an element with no >owner document?
Every DOM node has a specific owner document, since we may need to use document-wide contextual information (such as the table of unique IDs). Note that, as in the DOM, ownership is independent of whether the node is actually part of the main document tree. Since you're creating and returning DOM nodes, you have to follow that rule. We don't promise to process broken DOMs sucessfully. (Generally, this means it's safer to use the DOM's Document.createElementNS factory method, rather than trying to instantiate your ElementImpl directly.) As to whether this is exposing a bug in Xalan: I haven't analysed this deeply enough to have an opinion yet.
