« Calling LiveCycle When Deployed In A Cluster | Main | LiveCycle - Simple Stupid PDF Generator Watch Folder Configuration »

& In Your XML

If you are moving XML element values to String variables and later hoping to put those variables into other XML documents you may find that the XML in your String is no longer a valid XML value. If you set the value of a String variable from an XML element such as "J & J" the result will be "J & J". If you concatenate this variable into a string and then into an XML document using XPath your operation will fail.

Before moving variables into values that will be used in an XML document, be sure they are valid & free of special characters.

You'll need something a little more comprehensive, but here's a quick executeScript sample to rid your variables of '&':

String inString = patExecContext.getProcessDataStringValue("/process_data/@myString");
String outstring = inString.replace("&", "&");
System.out.println("***** String: " + myString);
patExecContext.setProcessDataStringValue("/process_data/@myString", outstring);

XML defines the following five entity references as special characters:

Ampersand - "&"
Left angle bracket - "<"
Right angle bracket - ">"
Straight quotation mark - ""
Apostrophe - "'"

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)