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 » Remove special characters from a string

Post new topic  Reply to topic Goto page Previous  1, 2
 Remove special characters from a string « View previous topic :: View next topic » 
Author Message
jefflowrey
PostPosted: Mon Jun 18, 2007 2:53 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

A CDATA section is a very robust solution for this as well, as long as you can guarantee that your string will not contain a CDATA end tag.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Luca81
PostPosted: Mon Jun 18, 2007 3:41 am    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

kimbert wrote:
Of course it's possible. But is it a good idea? I don't recall other users wanting to do this. So are you sure that removing these characters using ESQL is
a) necessary
b) the best solution

Quote:
But If I have '<' '>' '&' ecc ecc I have parser exception

All the WMB XML parsers ( XML / XMLNS / XMLNSC / MRM ) will automatically escape these characters and many others when they write the output message. What exactly is this string, and what are you trying to do with it?


Yes... is necessary... and I think this is the best solution...
This is the code

SET ErrorSource =COALESCE(refQoSP.ErrSource,'noSource');
SET ErrorNumber = COALESCE(refQoSP.ErrNumber,'noNumber');
SET ErrorReason = COALESCE(refQoSP.ErrReason,'noReason');
SET DiagInfo = COALESCE(refQoSP.DiagInfo,'noDiagInfo');

SET resp = ' <NS1:WsResp xmlns:NS1="http://SanPaolo.com/WBINS/" xmlns="http://tempuri.org/output.xsd">' ||
' <xs:schema id="output" targetNamespace="http://tempuri.org/output.xsd" xmlns:mstns="http://tempuri.org/output.xsd"' ||
' xmlns="http://tempuri.org/output.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"' ||
' attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="output" msdata:IsDataSet="true">' ||
' <xs:complexType><xs:choice maxOccurs="unbounded">' ||
' <xs:element name="Exception"><xs:complexType><xs:sequence>' ||
' <xs:element name="ErrorSource" type="xs:string" minOccurs="0" />' ||
' <xs:element name="ErrorNumber" type="xs:string" minOccurs="0" />' ||
' <xs:element name="ErrorReason" type="xs:string" minOccurs="0" />' ||
' <xs:element name="DiagInfo" type="xs:string" minOccurs="0" />' ||
' </xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><Exception>' ||
' <ErrorSource>'||ErrorSource||'</ErrorSource>' ||
' <ErrorNumber>'||ErrorNumber||'</ErrorNumber>' ||
' <ErrorReason>'||ErrorReason||'</ErrorReason>' ||
' <DiagInfo>'||DiagInfo||'</DiagInfo>' ||
'</Exception></NS1:WsResp>';

The 'resp' String will be pass to a special procedure (that I can't manipulate for a lot of reasons!!) that will envelope the string with SOAP.
And I can't modify the bold lines... the type must be String...


The Strings ErrSource,ErrReason ecc ecc can have special characters...
Pls tell me how remove special characters from those strings...
Thx
Luca
Back to top
View user's profile Send private message
Luca81
PostPosted: Mon Jun 18, 2007 7:23 am    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

kimbert wrote:
Of course it's possible.


How?
Thx
Luca
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 18, 2007 1:08 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5543
Location: Southampton

OK - point taken. Here are your options:
a) If the 'special characters' are legal for XML ( see the XML spec http://www.w3.org/TR/2006/REC-xml-20060816/ for the allowed set ) then you can and should use CDATA. CDATA is simply an alternative XML notation for the value of an element ( xs:string or any other schema type).
b) if at least one of the 'special characters' is illegal for XML then you need to write some ESQL to get rid of them. Advice has been offered already on this thread, so I won't repeat it. I repeat, though, that it is pointless to remove <, > and & because the broker will do that for you.

re: character codes, all names and values in the message broker tree are in code page 1200 ( UTF16 ). You can find the list using Google.
Back to top
View user's profile Send private message
Luca81
PostPosted: Mon Jun 18, 2007 11:22 pm    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

kimbert wrote:

b) if at least one of the 'special characters' is illegal for XML then you need to write some ESQL to get rid of them. Advice has been offered already on this thread, so I won't repeat it. I repeat, though, that it is pointless to remove <, > and & because the broker will do that for you.
.



Broker does not remove <,>,",& for me... If my strings have one those characters I have a parser exception!! o I have to remove them with ESQL code...
But I can't use a REPLACE for every characters! So I would like understand how remove them with ESQL code! I can use loop to check every chars in my string if it is between 0..9,A...Z and a...z.
How to check if it is between ?
Every character has own char code. And I should check if it is less then ... or higher than ... BUT HOW??? How can I check this???
This is the question!!! Only this!! I don't care about other solutions! And I would obtain an answer for this question!! ONLY for this question!
Thx a lot
Luca
Back to top
View user's profile Send private message
svu
PostPosted: Wed Aug 29, 2007 6:17 am    Post subject: Reply with quote

Voyager

Joined: 30 Jan 2006
Posts: 99

Luca81 wrote:

Every character has own char code. And I should check if it is less then ... or higher than ... BUT HOW??? How can I check this???

Same question here. Anybody knows?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Remove special characters from a string
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.