Problem writing UTF-8 XML with an Umlaut

"Johnson, Wayne" <[email protected]>
Newsgroups gmane.text.xml.xerces-j.user
Message-ID <[email protected]>
I have a Java program that is writing information from a database to an XML file.  I create a DOM document, add an element, and set the value with:

    Element id=parent.createElement("EventRuleInputDefinition");
...
    id.setAttribute("Value", getVal());

Later, I then go to write the Document with:

        StringWriter sw = new StringWriter();
...
            TransformerFactory transformerFactory =
                TransformerFactory.newInstance();
...
                Transformer transformer = transformerFactory.newTransformer();
                transformer.setOutputProperty (OutputKeys.ENCODING, "UTF-8");
                // Puts each stanza on a new line
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                DOMSource source = new DOMSource(node); // node is the document root.
                StreamResult result = new StreamResult(sw);
                transformer.transform(source, result);

The XML file is properly generated with the header:
<?xml version="1.0" encoding="UTF-8"?>
But the element is written with an actual umlaut character which when read back in generates the error:

[Fatal Error] :564:103: Invalid byte 1 of 1-byte UTF-8 sequence.
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.

We're using Xerces 2.8.1 (don't laugh, I know it's a bit old).  Could this be an issue in Xerces, or am I doing something wrong?

Thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.