Author |
Message
|
varunraot |
Posted: Sun Nov 13, 2016 3:05 am Post subject: Parsing "<" character in IIB |
|
|
Acolyte
Joined: 01 Jun 2011 Posts: 63
|
Is there any way to parse the XML containing character ("<") in IIB?
<SapMsel>
<MSID>100000000135428843</MSID>
<ATNAM>ZPPI_INSP_CHARAC_NAME_37</ATNAM>
<ATWRT>CWI - Lip pickoff < 250 mil</ATWRT>
<ATFOR>CHAR</ATFOR>
</SapMsel>
I have read various posts/articles about this including accepting it as BLOB and then converting to CDATA.
I am not sure if there is a workaround for this? |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 13, 2016 6:44 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Have you actually validated that XML?
Perhaps it is invalid  _________________ 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 |
|
 |
nelson |
Posted: Sun Nov 13, 2016 9:49 am Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
|
Back to top |
|
 |
timber |
Posted: Sun Nov 13, 2016 10:19 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
If that XML document is presented to *any* XML parser then it will be rejected because it is 'badly formed'.
Quote: |
Is there any way to parse the XML containing character ("<") in IIB? |
Yes, but only if the < is represented using the XML character entity <
Quote: |
I have read various posts/articles about this including accepting it as BLOB and then converting to CDATA. |
I don't see how that could work. The most obvious solution is to fix the application that is sending this invalid XML. Is there a reason why you are not doing that? |
|
Back to top |
|
 |
varunraot |
Posted: Sun Nov 13, 2016 8:51 pm Post subject: |
|
|
Acolyte
Joined: 01 Jun 2011 Posts: 63
|
@smdavies99 : Yes. Its an invalid XML and does not conform to the XML specification. Thatswhy my question was around this to check if there is any workaround.
@nelson: IIB is at receiving end of this XML message( perhaps invalid XML!) and there are many repeating structures of such segments ( SapMsel in below case). Since this kind of bad XML does not even get parsed completely at the beginning of the flow, there is no question of formatting the message with CDATA in ESQL in subsequent nodes.
It would be easier if its outgoing message from IIB where we can embedded with escape characters or with CDATA. However it is not the case here.
@timber : Good thought. Even I have the same opinion that converting to BLOB, converting to CDATA in a field and then converting back to XML does not work. However I just want to be sure that there are no other workaround.
Also, this bad XML comes from a manufacturing space involving SAP and seems like SAP has the limitation of not able to fix this bad formed XML at their end. |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 13, 2016 11:22 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
As you pointed out, this is a SAP bug and they must fix it.
That said,
if you can guarantee that the "<" will always be followed by a space then you could read the message as a BLOB and use ESQL Replace to find the "< " (cast as a blob) and replace it with a valid text that has the "<" escaped as described by Timber plus a space( all cast as a blob)
Sods law will dictate that two months down the line there will be some messages from SAP that don't always have the space and your 'Bodge' will blow up and you will get the blame.
That's why I call it a Bodge.
So get SAP to fix their XML. They are in the wrong. _________________ 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 |
|
 |
fjb_saper |
Posted: Mon Nov 14, 2016 5:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Depending on what the SAP Source is and how (fast) it is fixable, one possibility would be to get the SAP raw data, parse it using DFDL and then transform / map to XMLNSC.
This would most probably fix the problem.
Also make sure to always use the latest SAP adapter (lot of fixes).
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|