& 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 "
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 - "'"