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 » CHARACTER STRING - & CONVERTED TO &

Post new topic  Reply to topic
 CHARACTER STRING - & CONVERTED TO & « View previous topic :: View next topic » 
Author Message
mocha
PostPosted: Mon Apr 25, 2011 11:40 pm    Post subject: CHARACTER STRING - & CONVERTED TO & Reply with quote

Newbie

Joined: 25 Apr 2011
Posts: 4

Hi,

WB MQ V 7.0
WB Message Broker V6.1.0.5

We have an MQ message input to a message flow ( based on message set MRM CwXML ) which has a character string with data 'STEPNEY & SMITH'.
The message flow has simple mapping from i/p to o/p ( again MRM CwXML).
However the output from the flow indicates the following for the above string ' STEPNEY & SMITH'.
Unable to understand why the conversion '&' to '&' is taking place.

Just to add , the data is passed by a source system and '&' is quite commonly used instead of 'and'.
We tried using the REPLACE function within the flow compute node to replace any occurence of '&' with '&' but that did not work and the output is still coming out as '&'.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Apr 26, 2011 12:44 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

The representation of the '&' character as '&' is standard for HTML & XML and other markup document types.

This document http://www.w3.org/TR/xml/ is essential reference for just about any software developer in this day and age.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
jlaisbett
PostPosted: Tue Apr 26, 2011 12:47 am    Post subject: Reply with quote

Apprentice

Joined: 27 Nov 2009
Posts: 39

& is being converted to & when it serializes the message to xml because you are using an XML format and & is a special character in xml.

It's supposed to be doing that and whatever reads the xml is supposed to convert it back when it reads it.

If you have a legitimate requirement to do it differently then maybe you aren't really working with xml as such.
Back to top
View user's profile Send private message
mocha
PostPosted: Tue Apr 26, 2011 1:12 am    Post subject: Reply with quote

Newbie

Joined: 25 Apr 2011
Posts: 4

Many thanks for the replies .

The requirement is to pass 'A & B' which exists as a name field in a source oracle table to another name field in destination oracle table as 'A & B' rather than 'A & B' which is the result.

Source DB --> JCA adaptor ----> MQ message -----> Message Broker ---> MQ message ----> JCA adaptor ---> target DB.

Ideally we would not be wanting to request the target application to make any changes to be able to read '&' as '&'.

Placing a trace before the compute node in the message flow shows that that the parser has already converted '&' to '&' .

so why would using the REPLACE function within the compute node
( to replace '&' with '&' ) not have the desired effect.
If it is because the target message set is based on CwXML so it would convert to '&' then how do we ensure that the target receives 'A & B' and not 'A & B' as is happening.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Apr 26, 2011 4:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mocha wrote:
If it is because the target message set is based on CwXML so it would convert to '&' then how do we ensure that the target receives 'A & B' and not 'A & B' as is happening.


Have the target parse the XML you're sending it with any parser that conforms to the XML standard!

As the link that my worthy associate provided indicates, '&' is a special character in an XML document so if it appears as text it has to be escaped as &amp.

If the target application claims it's taking XML as input but doesn't understand that it's not really using XML. What parser is it employing? Or does it have some homegrown thing looking for '<' and '>'?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
joebuckeye
PostPosted: Tue Apr 26, 2011 4:22 am    Post subject: Reply with quote

Partisan

Joined: 24 Aug 2007
Posts: 365
Location: Columbus, OH

Quote:
then how do we ensure that the target receives 'A & B' and not 'A &amp; B' as is happening.


Don't use XML then.

As has been explained '&' is a special character in XML, as are '<' and '>'.

The receiving app needs to be aware of this and either to the conversion from '&amp;' itself or use a parser that will do it for them when reading the XML.

If it can't do this then you need to use a message format other than XML.
Back to top
View user's profile Send private message
flahunter
PostPosted: Tue Apr 26, 2011 6:10 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Oct 2008
Posts: 62

The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section

So how about using CDATA in your xml format?
Back to top
View user's profile Send private message
mocha
PostPosted: Wed Apr 27, 2011 3:15 am    Post subject: Reply with quote

Newbie

Joined: 25 Apr 2011
Posts: 4

Thanks to all for the replies.

I don't think I have been particularly succint in the explanation of the scenario that we are experiencing.

1. MQ Message
2. mapped to input message set (MRM CwXML) in broker.
3. one attribute in the MQ message has the following data
'Line Cgo & Clearance Co. W.L.L'
4. This data is derived from an oracle table : which is source for a number of different MQ messages which are mapped to appropriate message sets ( all MRM CwXML ).

the confusion now is that for the same data in two different messages mapped to two differnt message sets ( both MRM CwXML) differences are observed namely :
with the first & is replaced by &amp; and with the second it is not

eg:
<TBMS_BILLTOSITE_LANGUAGE:ASA_NAME>Line Cgo &amp; Clearance Co. W.L.L</TBMS_BILLTOSITE_LANGUAGE:ASA_NAME>

<TBMS_PARTYUPDATE:ACM_NAME>Line Cgo & Clearance Co. W.L.L</TBMS_PARTYUPDATE:ACM_NAME>



Initial thoughts are that there must be some inherent differences for the message set defintions but that is not the case.
One point of note which may or may not be relevant is that for the second the message has a parent child structure but for the first it does not .

clutching at straws now
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Apr 27, 2011 4:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I don't think I have been particularly succint in the explanation of the scenario that we are experiencing.
If you mean that you should have given a lot more information in your first post, then I agree.

This comment surprises me:
Quote:
Placing a trace before the compute node in the message flow shows that that the parser has already converted '&' to '&amp;' .
We have not seen your message flow, so we don't know what nodes you have. However, if this Compute node is connected to the MQInput node, then the message tree should contain & and not &amp;.
I suggest that you take the database and the JCA adapter out of the equation. Test your message flow using the test client or RFHUtil to put a message directly onto the input queue. Use Trace nodes to monitor what happens within the flow.

I also suggest that you read this section in the XML specification: http://www.w3.org/TR/2006/REC-xml-20060816/#syntax
Your comments so far indicate that you are shaky on the fundamentals of XML, and that is a dangerous place to be if you are working as an integration developer.
Back to top
View user's profile Send private message
mocha
PostPosted: Wed Apr 27, 2011 10:31 pm    Post subject: Reply with quote

Newbie

Joined: 25 Apr 2011
Posts: 4

Thank you for your time in replying Kimbert.
Your deduction is pretty much on the ball as I am not an integration developer as such.
I am assisting our internal integration team ( I have some MQ experience from the distant past) that has unfortunately been decimated due to an external event.
Your comments have been taken on board and we will follow your guidance and hopefully estalish an understanding of the root cause.

Thanks again
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CHARACTER STRING - & CONVERTED TO &amp;
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.