Author |
Message
|
yshakraj |
Posted: Wed Aug 29, 2012 10:28 pm Post subject: replacing ''' with actual symbol through esql |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
pls tell me a way to replace ''' in the incoming data with " ' " in the esql  |
|
Back to top |
|
 |
nathanw |
Posted: Wed Aug 29, 2012 11:37 pm Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
|
Back to top |
|
 |
yshakraj |
Posted: Thu Aug 30, 2012 1:48 am Post subject: |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
I have read the link which you have suggested , i cannot make out anything from that link Could you please help me fix this.
Currently i'm using this function,
SET AcceptInputData = REPLACE(AcceptInputData, ''','\');
which is actually the incorrect one. Please tell me a way to put actual " ' " in place of "\". |
|
Back to top |
|
 |
mqsiuser |
Posted: Thu Aug 30, 2012 3:03 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
yshakraj wrote: |
pls tell me a way to replace ''' in the incoming data with " ' " in the esql  |
If you have xml coming in it will be like "<root> ... </root>". There might be "escaped" xml embeded within that... with XML-Entities (e.g. <, > and ').
If you parse this with an XML-Parser then there are no more < and > (but just fields/elements and a tree) and the "escaped" xml should be an xml-string now (so with "<", ">" and "'")... it is "unescaped" now.
Parse this xml(-string) again and you have a logical message tree (of the originally embedded (and escaped) xml)).
You should really read the link provided by nathanw carefully.
If you still want to use REPLACE then try this:
Code: |
SET AcceptInputData = REPLACE(AcceptInputData, ''', ''''); |
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 30, 2012 4:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
yshakraj wrote: |
I have read the link which you have suggested , i cannot make out anything from that link Could you please help me fix this. |
What couldn't you make out?
You should never need to do what you're trying to do. What you're trying to do is at variance with the W3C XML standard.
Even if you succeed in using REPLACE or other means to change this value as soon as you output the XML you've created WMB will re-escape the value to ' because WMB's XML parser conforms to the W3C standard. If you finagle output as you suggest, the resulting XML document will fail to be parsed by any W3C compliant parser. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nathanw |
Posted: Thu Aug 30, 2012 4:45 am Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
Vitor wrote: |
yshakraj wrote: |
I have read the link which you have suggested , i cannot make out anything from that link Could you please help me fix this. |
What couldn't you make out?
You should never need to do what you're trying to do. What you're trying to do is at variance with the W3C XML standard.
Even if you succeed in using REPLACE or other means to change this value as soon as you output the XML you've created WMB will re-escape the value to ' because WMB's XML parser conforms to the W3C standard. If you finagle output as you suggest, the resulting XML document will fail to be parsed by any W3C compliant parser. |
which is what I was trying to point out
am curious why there is a sudden raft of these queries abut replacing apos with ' _________________ Who is General Failure and why is he reading my hard drive?
Artificial Intelligence stands no chance against Natural Stupidity.
Only the User Trace Speaks The Truth  |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 30, 2012 4:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nathanw wrote: |
which is what I was trying to point out |
Well quite, and I'm unclear why the OP "couldn't make anything out". Which I suspect is a euphamism for "I couldn't see where it was telling me how to do the silly thing I'm trying to do" but I'm in a grumpy mood this morning.
nathanw wrote: |
am curious why there is a sudden raft of these queries abut replacing apos with ' |
Presumably there's a sudden raft of development involving home brew non-compliant W3C "parsers" that just look for "<" and ">" and go from there. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
yshakraj |
Posted: Thu Aug 30, 2012 10:06 pm Post subject: |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
Thanks mqsiuser!!!
It worked for me.
Code: |
SET AcceptInputData = REPLACE(AcceptInputData, ''', ''''); |
Regards,
yshak |
|
Back to top |
|
 |
WBIMaestro |
Posted: Mon Sep 03, 2012 2:25 pm Post subject: |
|
|
Acolyte
Joined: 18 Feb 2005 Posts: 53
|
I am seeing a similar issue, though not sure if the same solution would work for me.
I am using the IA9Z - job execution node to echo a string to a file to trigger something else. basically an 'echo' statement, but the '>>' is getting replaced by ' > >' in the output stream.
IVe tried using CDATA Tags and the ESQL CDATA.Section commands:
Code: |
SET OutputRoot.XMLNSC.message.command.(XML.CDataSection) = COMMAND ; |
but no success yet. would the above REPLACE clause or some variant of the same be a solution in this case?
basically the question is quite generic - i need to preserve the '>' as is when getting output to outputroot.xml tree. I am looking to set:
Quote: |
SET OutputRoot.XMLNSC.message.command = "echo 'some string' >> some file" |
|
|
Back to top |
|
 |
mqsiuser |
Posted: Mon Sep 03, 2012 3:12 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
< and > are used by XML (for the elements ). Any XML-Parser will replace them (if they occur some place else, e.g. an embedded string) with > and < I think you cannot use REPLACE.
So: Dont use XMLNSC. Create a BLOB and write that out (or use MRM).
Code: |
SET OutputRoot.BLOB = CAST('echo ''some string'' >> some file' AS BLOB); |
|
|
Back to top |
|
 |
kimbert |
Posted: Tue Sep 04, 2012 1:26 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I am using the IA9Z - job execution node to echo a string to a file to trigger something else. basically an 'echo' statement, but the '>>' is getting replaced by ' > >' in the output stream. |
IF the output file is an XML file, THEN
a) XMLNSC is the correct choice of parser and
b) the ou
b) you will be reading the file using an XML parser, and it will automatically convert the '>>' back to '>>'.
ELSE
the output file is not XML, and you should use the BLOB parser to write it.
Quote: |
i need to preserve the '>' as is when getting output to outputroot.xml tree |
You cannot ever put the literal character '>' into an XML document. It's just not allowed by the XML specification. But you can put '>' into the XML document, and it will be interpreted as '>' by any XML parser. |
|
Back to top |
|
 |
rekarm01 |
Posted: Thu Sep 06, 2012 1:15 am Post subject: Re: replacing ''' with actual symbol through esql |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
WBIMaestro wrote: |
I've tried using CDATA Tags and the ESQL CDATA.Section commands:
Code: |
SET OutputRoot.XMLNSC.message.command.(XML.CDataSection) = COMMAND; |
|
The XMLNSC parser requires XMLNSC parser constants:
Code: |
SET OutputRoot.XMLNSC.message.(XMLNSC.CDataField)command = COMMAND; |
The XMLNSC parser escapes any markup characters after the message flow executes its ESQL, so the REPLACE function is not a suitable option here.
kimbert wrote: |
You cannot ever put the literal character '>' into an XML document. It's just not allowed by the XML specification. |
Please double-check that. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 06, 2012 5:25 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Please double-check that. |
You're absolutely right. My statement was too strongly worded. I should have said 'You cannot ever put the character '>' into the value of an XML tag, unless you wrap it in a CData section.'
The main point stands, though. The XMLNSC parser is behaving reasonably, and the OP needs to check that they are approaching the problem in the right way. |
|
Back to top |
|
 |
|