实体“uuml”被引用,但未声明 – XMLStreamException

试图从SpreadsheetML 2003 (基本上是一个XML)生成XLSX文件。 使用数据库中的CLOB,CLOB包含SpreadsheetML 2003(XML)。 我试图通过STAXparsing器parsingxml,并使用POI API将其写入XLSX文件,但在stax中处理时抛出exception。

注意:使用XML编码UTF-8格式。

例外:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,16706] Message: The entity "uuml" was referenced, but not declared. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588) at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getElementText(XMLStreamReaderImpl.java:845) at com.db.smis.planus.servlet.ServletApp.doProcess(ServletApp.java:224) 

示例XML:

  <?xml version="1.0"? encoding="UTF-8"> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Row> <Cell ss:StyleID="s29"><Data ss:Type="Number">7662</Data></Cell> <Cell ss:StyleID="s73"><Data ss:Type="String">C. &amp; A. AAAAA &amp; CO. KG</Data></Cell> </Row> <Row> <Cell ss:StyleID="s29"><Data ss:Type="Number">7662</Data></Cell> <Cell ss:StyleID="s28"><Data ss:Type="String">M&uuml;nchen,K&ouml;ln</Data></Cell> </Row> <Row> <Cell ss:StyleID="s29"><Data ss:Type="Number">7662</Data></Cell> <Cell ss:StyleID="s28"><Data ss:Type="String">D&uuml;sseldorf</Data></Cell> </Row> </Workbook> 

你需要声明&uuml; 实际上,或者用hex或十进制代替,在这种情况下,我猜ü

 <!DOCTYPE definition [ <!ENTITY uuml "&#220;"> ]> 

UPDATE
如果您有更多特殊字符,请使用我们的Apache commons lang的朋友StringEscapeUtils.unescapeXML

完整的例子