OK, fixed this myself - of course it was an encoding issue but knowing what the
problem is and fixing it are different altogheter!
I had to change from using a StringWriter to using a ByteArrayOutputStream (cos
you can't specify an encoding with Writers, but you can with OutputStreams):
Then use out.toString() to get the XML (with the correct encoding)...
BTW, is there a way to find out what encoding a particular DOM is using? There
does not seem to be a Document.getEncoding() method...
Pete
------------------------------
DOMSource incomingDOM = (DOMSource) sources[0];
Document incomingDoc = incomingDOM.getNode().getOwnerDocument();
Element incomingElement = (Element) incomingDOM.getNode();
String incomingNamespace = incomingElement.getNamespaceURI();
OutputFormat format = new OutputFormat(incomingDoc, "UTF-8", false);
//Serialize DOM
OutputStream out = new ByteArrayOutputStream();
OutputStreamWriter osw = null;
try{
osw = new OutputStreamWriter( out , "UTF8" );
} catch(Exception e) {
System.out.println("Could not create OutputStreamWriter");
e.printStackTrace();
}
XMLSerializer serial = new XMLSerializer(osw, format);
try {
serial.serialize(incomingElement);
} catch(Exception e) {
System.out.println("Serialization exception");
e.printStackTrace();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]