Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

createTextNode, entities, and json


createTextNode, entities, and json

We have some data that is being exposed via a JSON web service that is being consumed in a custom XUI app. The content provided in the JSON data already has a variety of entity references in it (ex: &). When we pass this data to the createTextNode(...) method of the Document class, it translates the "&" character in the & entity to a "&", resulting in the value & being stored in the SGML document. Clearly, we could modify the JSON service to no longer output entity references, but is there another way to skin this cat? Is there a way to cause the createTextNode(...) Document class method not translate characters to entities as described above?

Alternative suggestions are welcome.





There's an ACL function for that: entity_expand(str, 1, doc), where 'str' is
the string with the entities, '1' means "expand character entities" (2 is
text entities, 3 is both), and doc is the ACL ID of the document to use to
look up the entity references. So assuming you're in Java:

String docId = ((ADocument) doc).getAclId() + ";

String fixedStr = Acl.func("entity_expand", str, "1", docId);

Text textNode = doc.createTextNode(fixedStr);

Another option would be to use the AOM ARange interface to insert the

Range r = ((DocumentRange) doc).createRange();


((ARange) r).insertParsedString(str);

r.detach(); // Dispose of the range's resources. Or reuse and detach when
you're done.


Chris, this worked like a charm! Thank you!

Top Tags