0

我有一个从 iso-8859-1 中的 XML DB 返回的实例,Orbeon 显然不喜欢这样并抛出:

Fatal error: Invalid byte 2 of 3-byte UTF-8 sequence.
at org.orbeon.oxf.xml.XMLUtils$ErrorHandler.fatalError(XMLUtils.java:332)
at orbeon.apache.xerces.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
at orbeon.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:351)
at orbeon.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:281)
at orbeon.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1771)
at orbeon.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
at orbeon.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
at orbeon.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
at orbeon.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
at orbeon.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1201)
at org.orbeon.oxf.xml.XMLUtils.inputSourceToSAX(XMLUtils.java:418)
at org.orbeon.oxf.xml.XMLUtils.inputStreamToSAX(XMLUtils.java:403)
at org.orbeon.oxf.xml.TransformerUtils.readDom4j(TransformerUtils.java:357)
...

有问题的字符是有效的 iso-8859-1 ä (e4)

4

1 回答 1

1

XML 的默认编码是 UTF-8。如果您的服务未使用 UTF-8,则需要在 XML 声明中指定正在使用的编码。例如,如果您的数据以 ISO-8859-1 编码,则服务返回的 XML 应以以下声明开头:

<?xml version="1.0" encoding="ISO-8859-1" ?>
于 2011-02-16T18:41:08.670 回答