I have no idea what the reason might be but maybe you want to try: org.apache.cocoon.components.source.SourceUtil.toDOM(source);
I already found a workaround:
var domBuilder = new Packages.org.apache.cocoon.xml.dom.DOMBuilder(); source.toSAX(domBuilder); return domBuilder.document;
(BTW, what's the difference between my version and yours?)
but I don't have time to dig deeper into the problem ATM and just wanted to let it be known. Maybe it's just my installation. Can anyone else confirm it?
Ugo