Author |
Message
|
Charles1 |
Posted: Wed Oct 13, 2004 11:02 am Post subject: Ampersand in input XML |
|
|
Newbie
Joined: 27 Apr 2004 Posts: 6
|
Could someone point me in the right direction?
In the following msg flow:
MQInput ---> Compute ---> MQOutput
I have the following code in the compute node:
Code: |
SET OutputRoot = InputRoot;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
Set OutputRoot.XML.Data.Desc =
CASE
When InputRoot.XML.Data.Code = 'A&B' Then 'AB Warehouse'
When InputRoot.XML.Data.Code = 'DEF' Then 'DEF Warehouse'
Else
'XXXXX'
End;
|
My input XML looks like:
Code: |
<Data><Code>A&B</Code></Data>
|
The message flow won't process the message due to the & imbedded in the data. Is there a way around this problem?
Thanks. |
|
Back to top |
|
 |
JLRowe |
Posted: Wed Oct 13, 2004 11:15 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
& is illegal in content, you must use & or a CDATA section. Take a look at some XML tutorials for an explanation. |
|
Back to top |
|
 |
Charles1 |
Posted: Wed Oct 13, 2004 11:39 am Post subject: |
|
|
Newbie
Joined: 27 Apr 2004 Posts: 6
|
Thank you for your insightful reply.
While I realize that the & is illegal in content, I don't have control over what is coming through in the XML message. It is basically a free form field that a client enters data into. Additionally, I don't own the code that places the message on the queue.
There must be a way to program around this situtation.
Thanks again. |
|
Back to top |
|
 |
EddieA |
Posted: Wed Oct 13, 2004 11:52 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
There must be a way to program around this situtation |
Write your own XML parser in ESQL.
Seriously, you have to tell your client to provide valid data. NO XML parser should handle that.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
JT |
Posted: Wed Oct 13, 2004 1:16 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
It's not a pretty solution, but if you're desperate you could:
- Set the mesage domain of the Input node to BLOB
- In a compute node, using the REPLACE function (if you're at v5, if you're at v2, then you can use the POSITION and OVERLAY functions) to change all occurrences of '&' with '&'.
- After the compute node, using the ResetContentDescriptor Node convert the message domain from BLOB to XML.
See this post for details: http://www.mqseries.net/phpBB2/viewtopic.php?t=16567 |
|
Back to top |
|
 |
EddieA |
Posted: Wed Oct 13, 2004 3:23 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
change all occurrences of '&' with '&' |
And don't forget '<', '>', ''', and '"'.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
JLRowe |
Posted: Wed Oct 13, 2004 11:43 pm Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
The trouble is those characters appear in tags and attribute values also.
Personally, I would tell the sender to tweak their code to send valid XML. |
|
Back to top |
|
 |
mqbrk_newbie |
Posted: Thu Oct 14, 2004 4:33 am Post subject: |
|
|
 Acolyte
Joined: 13 Sep 2004 Posts: 70
|
hi,
This is not the way you code because its a special character . you code is
CASE
When InputRoot.XML.Data.Code = 'A&B' Then 'AB Warehouse'
When InputRoot.XML.Data.Code = 'DEF' Then 'DEF Warehouse'
trythis instead of above, hope it will work...
CASE
When InputRoot.XML.Data.Code.(XML.ASISElementContent) = 'A&B' Then 'AB Warehouse'
When InputRoot.XML.Data.Code = 'DEF' Then 'DEF Warehouse' |
|
Back to top |
|
 |
Charles1 |
Posted: Thu Oct 14, 2004 6:39 am Post subject: |
|
|
Newbie
Joined: 27 Apr 2004 Posts: 6
|
Everyone,
Thank you for your ideas and solutions. I have requested the sending program to be modified to only send valid XML. But to be on the safe side I'm going to try converting from within a Blob to XML.
Thanks again. |
|
Back to top |
|
 |
kirani |
Posted: Thu Oct 14, 2004 8:40 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Why do you need to do duplicate processing? If the sending system sends you valid XML message then you don't need to do this logic in your code. It could affect your performance. You can simply reject the message and write it to failure queue. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
JT |
Posted: Thu Oct 14, 2004 8:53 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
kirani wrote: |
reject the message and write it to failure queue. |
.....or run the message through the "conversion" logic, and re-process the message only when a parsing error is detected. |
|
Back to top |
|
 |
adoyle65 |
Posted: Wed Aug 30, 2006 4:18 am Post subject: Using the & in XML |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
Hi all,
Can someone explain why when using the & to signify the ampersand character in XML, that the trailing spaces after the ampersand character are stipped upto the next non space character?
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 30, 2006 5:08 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Which domain are you using? Sounds like the whitespace is being stripped from the message, which sounds like the compact model. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
adoyle65 |
Posted: Wed Aug 30, 2006 5:28 am Post subject: |
|
|
Apprentice
Joined: 18 Feb 2004 Posts: 37 Location: Canada
|
The input node of the message flow is set to the XML domain. If I look at the message using RFHUTIL the spaces appear in the message element. However when our websphere app parses the message they appear to be removed.
Does this help?
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 30, 2006 5:35 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
adoyle65 wrote: |
The input node of the message flow is set to the XML domain. If I look at the message using RFHUTIL the spaces appear in the message element. However when our websphere app parses the message they appear to be removed.
Does this help?
Thanks |
Somewhat
So you've got a message sitting on a queue, which has been through a message flow via the XML domain; this message has the whitespace intact is viewed directly via RFHUTIL - yes? That's what I'd have expected because the XML parser is non-compact (you don't mention which version of broker you're using but I think that's true for all of them. Someone will correct me if not!).
You then read the message with an application running under Websphere and the whitespace has been stripped off. The question then becomes what does the app use as a parser? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|