XmlValidator is using java.lang.String.getBytes() to get the byte array for the contents, which converts to platform default encoding. If the platform default is not a UTF8, validation fails since the parser assumes UTF8.