【发布时间】:2015-05-04 10:26:42
【问题描述】:
我们正在尝试通过 JAVA API 将 ISO 编码的 xml 插入 MarkLogic,但出现此错误。 xml中包含特殊字符,例如:注册商标标志-
®
Bad Request. Server Message: XDMP-DOCUTF8SEQ: Invalid UTF-8 escape sequence at line 14145 -- document is not UTF-8 encoded.
代码:
DatabaseClient client = DatabaseClientFactory.newClient(IP, PORT,
DATABASE_NAME, USERNAME, PWD, Authentication.DIGEST);
// acquire the content
InputStream xmlDocStream = XMLController.class.getClassLoader()
.getResourceAsStream("path to xml file");
// create a manager for XML documents
XMLDocumentManager xmlDocMgr = client.newXMLDocumentManager();
// create a handle on the content
InputStreamHandle xmlhandle = new InputStreamHandle(xmlDocStream);
// write the document content
xmlDocMgr.write("/" + filename, xmlhandle);
【问题讨论】:
-
如果我们使用 mlcp (marklogic content pump) 加载这个 xml,我们会得到同样的错误
-
是的,代码是……?
-
您基本上已经问过这个问题,但措辞略有不同? stackoverflow.com/questions/30028454/…
-
@fge 我们已经添加了相关代码。
标签: java xml encoding utf-8 marklogic