> I think these things that I attempted are not too rare - having the XML go
> through different parsers and outputters. Transferring objects between VMs
> might also be something that people want to do, so I am not too sure if it
> is a good idea to check equality of namespaces by object reference.

I don't either, but I haven't followed the discussions and Java strings give me 
a headache.

> You don't happen to have a code snippet around that does exactly that
> (Java)?

I don't do Java any more (see headache above). The xmltooling code underneath 
opensaml-j, which I didn’t write, has helper routines that provide one way to 
do it, and they appear to use a DOM3 LSSerializer:

public static void writeNode(Node node, Writer output) {
    DOMImplementation domImpl = node.getOwnerDocument().getImplementation();
    DOMImplementationLS domImplLS = (DOMImplementationLS) 
domImpl.getFeature("LS", "3.0");
    LSSerializer serializer = domImplLS.createLSSerializer();
    LSOutput serializerOut = domImplLS.createLSOutput();
    serializerOut.setCharacterStream(output);
    serializer.write(node, serializerOut);
}

There's also a pretty-print version that seems to be similar to what you're 
doing but not exactly the same.

-- Scott


Reply via email to