ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Ampersand in input XML

Post new topic  Reply to topic Goto page 1, 2  Next
 Ampersand in input XML « View previous topic :: View next topic » 
Author Message
Charles1
PostPosted: Wed Oct 13, 2004 11:02 am    Post subject: Ampersand in input XML Reply with quote

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
View user's profile Send private message
JLRowe
PostPosted: Wed Oct 13, 2004 11:15 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

& is illegal in content, you must use &amp; or a CDATA section. Take a look at some XML tutorials for an explanation.
Back to top
View user's profile Send private message Send e-mail
Charles1
PostPosted: Wed Oct 13, 2004 11:39 am    Post subject: Reply with quote

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
View user's profile Send private message
EddieA
PostPosted: Wed Oct 13, 2004 11:52 am    Post subject: Reply with quote

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
View user's profile Send private message
JT
PostPosted: Wed Oct 13, 2004 1:16 pm    Post subject: Reply with quote

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 '&amp'.
  • 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
View user's profile Send private message
EddieA
PostPosted: Wed Oct 13, 2004 3:23 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
change all occurrences of '&' with '&amp'

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
View user's profile Send private message
JLRowe
PostPosted: Wed Oct 13, 2004 11:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mqbrk_newbie
PostPosted: Thu Oct 14, 2004 4:33 am    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger
Charles1
PostPosted: Thu Oct 14, 2004 6:39 am    Post subject: Reply with quote

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
View user's profile Send private message
kirani
PostPosted: Thu Oct 14, 2004 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
JT
PostPosted: Thu Oct 14, 2004 8:53 am    Post subject: Reply with quote

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
View user's profile Send private message
adoyle65
PostPosted: Wed Aug 30, 2006 4:18 am    Post subject: Using the &amp; in XML Reply with quote

Apprentice

Joined: 18 Feb 2004
Posts: 37
Location: Canada

Hi all,

Can someone explain why when using the &amp; 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
View user's profile Send private message
Vitor
PostPosted: Wed Aug 30, 2006 5:08 am    Post subject: Reply with quote

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
View user's profile Send private message
adoyle65
PostPosted: Wed Aug 30, 2006 5:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Wed Aug 30, 2006 5:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Ampersand in input XML
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.