Author |
Message
|
neo_revolution |
Posted: Thu Apr 15, 2004 4:42 am Post subject: Handling Invalid XML |
|
|
Voyager
Joined: 21 Oct 2003 Posts: 80 Location: NJ
|
Hi All,
I am trying to handle Invalid XML coming to the MQInputNode. If the XML is not well formed it is going to the catch terminal of the InputNode.
There I have a compute node where I create XML and I would like to include request in the XML I am creating. As the XML is invalid I can't attach to a child in the newly created XML.
What I wish to do is take the entire xml 'InputRoot.XML' and attach it to a XML element with CDataSection using ESQL. Something like this
SET Error.value.(XML.CDataSection) = InputRoot.XML;
But this is not working. Is there a way to take the invalid xml and attach it to a xml tag...
Thanks in advance. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 15, 2004 4:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Even CDATA sections have to match certain requirements in order to be valid and "parseable" by the parser.
You could do something like replace all of the <, >, and etc (per the XML standard for CDATA sections) with the entity representation (< for example).
Or you could cast the bad XML data to a BLOB field, and then put this into the CData section. That will give you a hex character representation of the bitstream. (X'0FA422' for example). _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
neo_revolution |
Posted: Thu Apr 15, 2004 4:55 am Post subject: |
|
|
Voyager
Joined: 21 Oct 2003 Posts: 80 Location: NJ
|
jeff,
can't I cast XML into something String or Char? because I would like to have the XML representation instead of Bitstream. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 15, 2004 5:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes, if you replace the needed characters with entities or something, so that the contents of the CDATA section meet the standards for CDATA content.
On the other hand, XML should only be read and seen by machines and not by people, in my opinion. So designing XML to be human readable is a waste of time. It should be meaningful to people to describe the data, but that's not the same thing as readable to people.
But that's just my opinion. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wendy |
Posted: Thu Apr 15, 2004 5:25 am Post subject: |
|
|
Apprentice
Joined: 10 Dec 2001 Posts: 47
|
Try this :
Set OutputRoot.XML.Element1 =
CAST(BITSTREAM(InputRoot.MRM) AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
I'm assuming that the inputnode has a Message Set defined(based on an XSD) |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 15, 2004 5:29 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Wendy -
That code will indeed assign the contents of an entire XML tree into the contents of a single XML field.
But if the XML is not parseable because, for instance, it has mismatched >'s, then the resulting XML field will not be valid.
Even IF the XML field is set up as a CDATA section (which your code doesn't do). There are some parser errors that can be encapsulated this way, and some that can't. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
neo_revolution |
Posted: Thu Apr 15, 2004 6:15 am Post subject: |
|
|
Voyager
Joined: 21 Oct 2003 Posts: 80 Location: NJ
|
yeah I understand... But there are some fields based on which the request and response are correlated. And the process is a manual activity. So need to do this way. |
|
Back to top |
|
 |
neo_revolution |
Posted: Thu Apr 15, 2004 7:38 am Post subject: |
|
|
Voyager
Joined: 21 Oct 2003 Posts: 80 Location: NJ
|
Thanks Wendy,
It worked for me this way ....
Set OutputRoot.XML.Element1.(XML.CDataSection) =
CAST(ASBITSTREAM(InputRoot.XML OPTIONS FolderBitStream) AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
Thanks a lot guys. |
|
Back to top |
|
 |
|