Author |
Message
|
ein |
Posted: Sat May 16, 2009 10:23 pm Post subject: Is MB can Identify these values( '<' and '>') |
|
|
Centurion
Joined: 14 Mar 2009 Posts: 108
|
Helllo
My input msg contains some values characters like < and >
Ineed to convert those values into < and > .
I have used REPLACE and TRANSLATE functions.
Can any one help me plz.. |
|
Back to top |
|
 |
Vitor |
Posted: Sun May 17, 2009 8:04 am Post subject: Re: Is MB can Identify these values( '<' and '> |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
[quote="ein"]Ineed to convert those values into < and > .
ein wrote: |
nly confuse any XML parsers you encounter.
[quote="ein"]I have used REPLACE and TRANSLATE functions. |
What happened when you tried this? Post your code. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Sun May 17, 2009 12:02 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Here is my guess at your real requirement:
You are receiving an XML fragment embedded within another XML document. The sender has *not* used a CDATA section, so the sending application has replaced < and > ( and probably & ) with other characters.
You now need to parse the XML, so you need to perform the reverse transformation to recover the original XML message.
If my guess is correct, then the best solution is to change the sending application to
a) put a CDATA section around the embedded XML document
b) embed the document without doing any escaping of XML markup characters.
If the sending application cannot be changed, then REPLACE / TRANSLATE is the best solution. |
|
Back to top |
|
 |
Vitor |
Posted: Sun May 17, 2009 11:41 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kimbert wrote: |
Here is my guess at your real requirement:
You are receiving an XML fragment embedded within another XML document. The sender has *not* used a CDATA section, so the sending application has replaced < and > ( and probably & ) with other characters.
You now need to parse the XML, so you need to perform the reverse transformation to recover the original XML message. |
Ah....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
DTechBuddy |
Posted: Sun May 17, 2009 11:50 pm Post subject: |
|
|
Novice
Joined: 05 May 2009 Posts: 20
|
I had a similar issue, where i was required to replace '<' with '<' and '>' with '>'.
After much tracing, i concluded that it cannot be handled at ESQL level.
REPLACE & TRANSALATE functions didn't worked for me, as the contents of trace revealed that Broker didn't recognise '<' and '>'.
Thus i took care of it at script level.
Using the commands as :-
sed 's/</</g' <InputFile> > <OutputFile>
sed 's/>/>/g' <OutputFile> > <InputFile> |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 18, 2009 12:21 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
DTechBuddy wrote: |
After much tracing, i concluded that it cannot be handled at ESQL level. |
Yes it can!
Obviously requires some sleight of hand, depending on how stupid the input message is, but the PoC I've just done managed it in a simplistic example. I suspect the broker "didn't recognise" these characters as they'd been transformed to something else within the message tree.
This does not invalidate the advice of kimbert, as it's always best to send XML that's well-formed. Especially if you plan to parse it. Nor does it say that a sed script isn't a valid solution to a particular situation. Or the best solution in a given situation. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 18, 2009 1:23 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
DTechBuddy said:
Quote: |
I had a similar issue, where i was required to replace '<' with '<' and '>' with '>'.
After much tracing, i concluded that it cannot be handled at ESQL level.
REPLACE & TRANSALATE functions didn't worked for me, as the contents of trace revealed that Broker didn't recognise '<' and '>'. |
There are two possibilities here:
- REPLACE has a defect
- You were not using REPLACE correctly
If you cannot prove that REPLACE has a defect then you should not be giving advice like this.
For most users, a JavaCompute node would be a better solution than a script. |
|
Back to top |
|
 |
ein |
Posted: Mon May 18, 2009 3:43 am Post subject: |
|
|
Centurion
Joined: 14 Mar 2009 Posts: 108
|
kimbert wrote: |
Here is my guess at your real requirement:
You are receiving an XML fragment embedded within another XML document. The sender has *not* used a CDATA section, so the sending application has replaced < and > ( and probably & ) with other characters.
You now need to parse the XML, so you need to perform the reverse transformation to recover the original XML message.
If my guess is correct, then the best solution is to change the sending application to
a) put a CDATA section around the embedded XML document
b) embed the document without doing any escaping of XML markup characters.
If the sending application cannot be changed, then REPLACE / TRANSLATE is the best solution. |
Thanks Kimbert..
it works with CDATA.
Thank you very much |
|
Back to top |
|
 |
|