java - How to write accented characters from XML into MarkLogic using JavaApi? -


i have xml of 20mb having accented characters Ö,É,Á, , many more.here problem when insert file marklogic, these characters saved in english format o,e,a.but want store in same format.so how can store characters in accented format , read xml in same way. xml file iso-8859-1 encoded.

code have written writing , reading :

     databaseclient client = databaseclientfactory.newclient(ip, port,         database_name, username, pwd, authentication.digest);     xmlinputfactory factory = xmlinputfactory.newinstance();     xmlstreamreader streamreader = null;     streamreader = factory.createxmlstreamreader(new filereader("record.xml"));     xmldocumentmanager xmldocmgr = client.newxmldocumentmanager();     xmlstreamreaderhandle handle = new xmlstreamreaderhandle(streamreader);     xmldocmgr.write("/" + filename, handle);     

for reading xml:

 xmldocumentmanager docmgr = client.newxmldocumentmanager();  domhandle xmlhandle = new domhandle(); docmgr.read("/" + filename, xmlhandle); string doc = xmlhandle.tostring(); string data = normalizer.normalize(doc, normalizer.form.nfd).replaceall("[^\\p{ascii}]", ""); return data; 

i returning data display in browser. not able find problem is.

if xml file not have xml prologue declares encoding, should specify iso-8859-1 encoding when reading file before writing file database (as flafoux has pointed out).

you should specify encoding when reading content database unless destination accepts utf-8 encoding.

for more information, see:

http://docs.marklogic.com/guide/java/document-operations#id_11208

hoping helps,


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -