|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Apostrophe Escaping |
« View previous topic :: View next topic » |
Author |
Message
|
elaforc |
Posted: Thu Nov 12, 2009 7:45 am Post subject: Apostrophe Escaping |
|
|
Novice
Joined: 29 Sep 2009 Posts: 10
|
Currently I am seeing issues in my syslog.user concerning a XPath parse error. See error below. I have tried taking out the apostrophes and the message will go through the message flow correctly. However the client would like to keep the apostrophes in the message. I have tried different methods to escape the apostrophe, but no luck. I have tried using backslash and ampersand code ' and ' It is almost like it is escaping correctly, but the XPath set-value() method can't read single quotes? So the main question is how do I escape an apostrophe inside XPath set-value() so XPath doesn't complain? I have also copied the code I am using below, where the "body" variable is the Java string that contains the single quote.
Code: |
outMessage.getRootElement().evaluateXPath("?XML/?Message/?^Body[set-value('" + body + "')]");
|
Error Message in syslog.user:
Quote: |
Nov 6 15:20:30 entmqst2 user:err|error WebSphere Broker v6003[962634]:
(ENTCLTT2.CIS)[3101]BIP4382E: XPath parse error at column '696' in
expression '?XML/?Message/?^Body[set-value('module: "". Code :
"-904". Type : "D". Severity: "S". Count : "1". Message :
"DATA SERVER DB2 ERROR PROG=PXWMT111 LOC=RETRIEVE-FWR-DA REG=SYSD
TRNID=PXWB TASKN=0004608 DATE=1062009 TIME=0133655
TABLE=FIELD_WORK_REQUEST MSG= DSNT408I SQLCODE
= -904, ERROR: UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE
RESOURCE. REASON 00C900A3, TYPE OF RESOURCE 00000210, AND RESOURCE NAME
CBISPDA .TSFWREQ .00000002 DSNT418I SQLSTATE = 57011 SQLSTATE RETURN
CODE DSNT415I SQLERRP = DSNXRRC SQL PROCEDURE DETECTING ERROR DSNT416I
SQLERRD = 102 13172746 0 13223106 -974970878 12714050 SQL DIAGNOSTIC
INFORMATION DSNT416I SQLERRD = X'00000066' X'00C9000A' X'00000000'
X'00C9C4C2' X'C5E32002' X'00C20042' SQL DIAGNOSTIC INFORMATION".')]'. :
ENTCLTT2.427390ba-2401-0000-0080-f0ee2ffe6101:
/build/S600_P/src/DataFlowEngine/PluginInterface/ImbX
|
[/code] |
|
Back to top |
|
 |
Michael Dag |
Posted: Thu Nov 12, 2009 3:17 pm Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
|
Back to top |
|
 |
elaforc |
Posted: Fri Nov 13, 2009 8:26 am Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 10
|
Michael Dag wrote: |
why are you not using the setValue function as you did here ??? |
Good point. I guess I over thought it. Anyways that worked like a charm once I figured out the correct tree traversal. See code below
Code: |
// ----------------------------------------------------------
// Add user code below
//Retreive email values Notification
String fromEmail = outMessage.getRootElement().evaluateXPath("string(/Notification/From)").toString();
String toEmail = outMessage.getRootElement().evaluateXPath("string(/Notification/To)").toString();
String subject = outMessage.getRootElement().evaluateXPath("string(/Notification/Subject)").toString();
String body = outMessage.getRootElement().evaluateXPath("string(/Notification/Body)").toString();
//Set email values
MbElement root = outMessage.getRootElement().getLastChild();
MbElement emailFromAddr = (MbElement)((List)root.evaluateXPath("?Message/?From")).get(0);
emailFromAddr.setValue(fromEmail);
root = outMessage.getRootElement().getLastChild();
MbElement emailToAddr = (MbElement)((List)root.evaluateXPath("?Message/?To")).get(0);
emailToAddr.setValue(toEmail);
root = outMessage.getRootElement().getLastChild();
MbElement emailSubject = (MbElement)((List)root.evaluateXPath("?Message/?Subject")).get(0);
emailSubject.setValue(subject);
root = outMessage.getRootElement().getLastChild();
MbElement emailBody = (MbElement)((List)root.evaluateXPath("?Message/?Body")).get(0);
emailBody.setValue(body);
// End of user code
// ----------------------------------------------------------
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,outMessage); |
|
|
Back to top |
|
 |
Michael Dag |
Posted: Fri Nov 13, 2009 8:30 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|