& In Your XML

| No Comments

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

Leave a comment

About this Entry

This page contains a single entry by Lee Sutton published on November 29, 2007 2:37 PM.

Calling LiveCycle When Deployed In A Cluster was the previous entry in this blog.

LiveCycle - Simple Stupid PDF Generator Watch Folder Configuration is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.