Regarding locking the DOMDocument while it is being written to:
It looks like DOMDocument is meant to be used in a single-threaded manner[1], so it should be all right to just grab an interface and not worry about threads attempting to manipulate the document while it is being written to by an mxwriter.
For how to lock it, unless anyone has a better idea I think it would work to add an IWineXMLDOMDocumentLock interface with lock() and unlock() methods, and output a FIXME if this interface is unavailable.
thanks, Jefferson
[1] https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms756987(...