Author |
Message
|
rock33 |
Posted: Sun Sep 22, 2013 11:18 am Post subject: Parsing '&' in Esql code |
|
|
Novice
Joined: 22 Mar 2013 Posts: 12
|
Hi
Is anyone knows how to parse '&' to the target xml. It is an hardcoded value at the compute node and the incoming parser is XMLNSC.
Ex:
Source attribute: <name id='&en' />
Expected target attribute: <name id='&en' />
Actual target attribute: <name id='&en' />
How to avoid append this 'amp' text to '&'.
Any advice would be appreciated. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Sep 22, 2013 11:34 am Post subject: Re: Parsing '&' in Esql code |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
rock33 wrote: |
Hi
Is anyone knows how to parse '&' to the target xml. It is an hardcoded value at the compute node and the incoming parser is XMLNSC.
Ex:
Source attribute: <name id='&en' />
Expected target attribute: <name id='&en' />
Actual target attribute: <name id='&en' />
How to avoid append this 'amp' text to '&'.
Any advice would be appreciated. |
Don't worry. &en is illegal XML. The correct XML value is <name id='&en' />
When extracted from the XML it will automatically revert to &en.
& is one of those values that HAVE to be escaped in XML.
Code: |
SET ref.name.(XMLNSC.attr)id='&en';
-- will result in <name id='&en' /> |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rock33 |
Posted: Sun Sep 22, 2013 11:48 am Post subject: |
|
|
Novice
Joined: 22 Mar 2013 Posts: 12
|
Thanks for the reply fjb_saper.
My target is fileOutput node.
Below is the line in the compute node.
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en';
Outcome :
<name ID="&amp;en;" />
Issue still exists. |
|
Back to top |
|
 |
goffinf |
Posted: Sun Sep 22, 2013 12:07 pm Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
rock33 wrote: |
Thanks for the reply fjb_saper.
My target is fileOutput node.
Below is the line in the compute node.
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en';
Outcome :
<name ID="&amp;en;" />
Issue still exists. |
Read fjb_saper's answer again (carefully).
In your code, Broker will convert the first & to the legal escape sequence & and then add the string literal amp;en as indeed you have found.
Fraser. |
|
Back to top |
|
 |
aggarwal.intouch |
Posted: Mon Sep 23, 2013 1:43 am Post subject: |
|
|
 Acolyte
Joined: 30 May 2011 Posts: 56 Location: India
|
When the XMLNS parser generates a bit stream from a message tree, occurrences of ampersand (&), less than (<), greater than (>), double quotation mark ("), and apostrophe ('), within the attribute value, are replaced by the predefined XML entities &, <, >, ", and '. |
|
Back to top |
|
 |
jsware |
Posted: Mon Sep 23, 2013 2:57 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
rock33 wrote: |
Thanks for the reply fjb_saper.
My target is fileOutput node.
Below is the line in the compute node.
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en';
Outcome :
<name ID="&amp;en;" />
Issue still exists. |
Use the following line instead:
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en'; _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
rock33 |
Posted: Mon Sep 23, 2013 4:53 am Post subject: |
|
|
Novice
Joined: 22 Mar 2013 Posts: 12
|
[quote="jsware"]
rock33 wrote: |
Use the following line instead:
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en'; |
Have you tested jsware the above line of code? |
|
Back to top |
|
 |
jsware |
Posted: Mon Sep 23, 2013 5:06 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
[quote="rock33"]
jsware wrote: |
rock33 wrote: |
Use the following line instead:
SET OutputRoot.XMLNSC.name.(XMLNSC.Attribute)ID = '&en'; |
Have you tested jsware the above line of code? |
Not specifically - have you? What happens? _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
jsware |
Posted: Mon Sep 23, 2013 5:53 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
Looking again at what you want:
<name ID='&en'>
This is invalid XML as fjb_saber mentioned. So are you asking how you can produce an invalid XML document containing an unmarked-up ampersand?
What I suggested will produce:
<name ID='&en'>
which is the XMLNSC parser working correctly.
If you are expecting '&en' to be an XML entity (like &) then &en is slightly incorrect. All XML entities are in the form '&name;' - beginning with ampersand and ending with semicolon. &en is not a valid entity name format - just like & is incorrect too - its &
To create inline DTD's that define custom XML entities, see http://pic.dhe.ibm.com/infocenter/wmbhelp/v9r0m0/topic/com.ibm.etools.mft.doc/ac67190_.htm for details.
If you are expecting the XMLNSC parser which, by design, produces well formed XML, to produce bad XML then that is going to be a bit more difficult. _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
rock33 |
Posted: Thu Sep 26, 2013 6:05 am Post subject: |
|
|
Novice
Joined: 22 Mar 2013 Posts: 12
|
Thanks jsware for the Explanation. |
|
Back to top |
|
 |
|