We are trying to insert an xml with ISO encoding to MarkLogic through JAVA API but gets this error. The xml contains special characters, for example: registered trademark sign - <h4> ® </h4>
Bad Request. Server Message: XDMP-DOCUTF8SEQ: Invalid UTF-8 escape sequence at line 14145 -- document is not UTF-8 encoded.
Code:
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);