简体   繁体   中英

Escaping XML using Java and Marklogic

I am loading XML into a Marklogic database using Java and Marklogic's XCC API. Before I do so, I use Apache Commons to escape the elements' contents (StringEscapeUtils.escapeXml). Upon loading the contents, though, I error out due to a curly brace character in the contents. escapeXml doesn't handle the curly brace. My questions are:

1) Is that a Marklogic specific issue (maybe with XCC) or is it an issue with XML in general?
2) Are there other characters that could also cause a problem (ie not escaped by the escapeXml routine)?
3) Is there a different routine that could be used to avoid this and any future undesired characters?

You should not escape contents when using XCC, it escapes them itself so you would be doing double-escapes. However curly brackes are generally not something XML complains about, perhaps you are using the Invoke instead of Insert methods. ( ie then XCC would try to interpret your content as XQuery )

Could you provide a sample of your content and code snippet ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM