Author |
Message
|
ethirajesh |
Posted: Mon Jul 18, 2011 1:33 am Post subject: Embedding XML into Pipe delimited file |
|
|
Apprentice
Joined: 04 Oct 2010 Posts: 46
|
Hi I need to Generate a Pipe delimited in MB file as below :
Method|InputMessage|MsgFlowIdentfier|TimeStamp|Type etc.,
I am able to construct the above message as a String. In place of 'InputMessage' I need to place a XML file returned by a webservice. To do this I reset the response to BLOB using ResetContentdescriptor node. And In the COmpute node My code is as below :
SET Msg = ASBITSTREAM(InputRoot.BLOB.BLOB);
SET Environment.Variables.InputMessage = CAST(Msg AS CHARACTER CCSID 1208);
And concatenated this which produced as below :
Method|<?xml version="1.0" encoding="utf-8" ?>
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
<ParentTag>
<ChildTag>
<Data>
</ChildTag>
</ParentTag>
<Response> MsgFlowIdentfier|TimeStamp|Type
But I need the output as mentioned below, what should be done to acheive this :
Method|<?xml version="1.0" encoding="utf-8" ?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1"><ParentTag><ChildTag><Data></ChildTag></ParentTag><Response>MsgFlowIdentfier|TimeStamp|Type |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 18, 2011 4:46 am Post subject: Re: Embedding XML into Pipe delimited file |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ethirajesh wrote: |
But I need the output as mentioned below, what should be done to acheive this |
You've already got the desired output. The particular input xml you're using clearly has line break(s) between the tags. Tools like XMLSpy do this to aid readability for humans and whatever you're using to view the output message is honouring that. But the XML is the same; to an XML parser there's no difference between:
Code: |
<Parent>
<Child>42</Child>
</Parent>
|
and
Code: |
<Parent><Child>42</Child></Parent>
|
So whatever's consuming your message downstream will be fine, or they need a better XML parser. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
joebuckeye |
Posted: Mon Jul 18, 2011 4:46 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
You need to remove the white space from the XML that was received back from the web service.
How did the flow get this XML? And what XML parser was used in the flow? |
|
Back to top |
|
 |
joebuckeye |
Posted: Mon Jul 18, 2011 4:49 am Post subject: Re: Embedding XML into Pipe delimited file |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Vitor wrote: |
So whatever's consuming your message downstream will be fine, or they need a better XML parser. |
I think the downstream application is expecting a pipe delimited message and the line breaks in the XML are causing the problem in the file that is being created by the broker. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 18, 2011 4:53 am Post subject: Re: Embedding XML into Pipe delimited file |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
joebuckeye wrote: |
I think the downstream application is expecting a pipe delimited message and the line breaks in the XML are causing the problem in the file that is being created by the broker. |
I stand by my comment of "they need a better parser".
Though I do suspect you're right; they're using line feeds as an end-of-record marker so they're getting the message chopped up.
Which I further suspect is going to end up being fixed by the OP because it's "too hard" for the downstream app.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon Jul 18, 2011 5:22 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
You may use REPLACE function to remove the line breaks. Use it with BLOB datatype and correct BLOB-expression of the line breaks within you WS response. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 18, 2011 5:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
j.f.sorge wrote: |
You may use REPLACE function to remove the line breaks. Use it with BLOB datatype and correct BLOB-expression of the line breaks within you WS response. |
This may have unfortunate side effects if any of the tags legitimately contain line breaks; a formated address for instance.
Of course, if the data doesn't then you're fine. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
paintpot |
Posted: Mon Jul 18, 2011 7:52 am Post subject: |
|
|
Centurion
Joined: 19 Sep 2005 Posts: 112 Location: UK
|
Try using the XMLNSC domain for your web service response data |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 18, 2011 8:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
paintpot wrote: |
Try using the XMLNSC domain for your web service response data |
Doh - you threw a fish!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
rekarm01 |
Posted: Mon Jul 18, 2011 10:46 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Vitor wrote: |
This may have unfortunate side effects if any of the tags legitimately contain line breaks ... |
Not to mention what happens if the XML legitimately contains pipe characters, when embedding it in a pipe-delimited message ... |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 18, 2011 11:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
rekarm01 wrote: |
Vitor wrote: |
This may have unfortunate side effects if any of the tags legitimately contain line breaks ... |
Not to mention what happens if the XML legitimately contains pipe characters, when embedding it in a pipe-delimited message ... |
Less likely than line breaks, but yes indeed quite.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
ethirajesh |
Posted: Mon Jul 18, 2011 10:11 pm Post subject: |
|
|
Apprentice
Joined: 04 Oct 2010 Posts: 46
|
Basically our buisness will use this text file to update in the database in future.
So the end application will consider this as a String only. In this case the line feeds in my output will create problem?? |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 19, 2011 4:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ethirajesh wrote: |
So the end application will consider this as a String only. In this case the line feeds in my output will create problem?? |
Well, yes. The application thinks it's a string. Depending on how they define "string" their application could easily believe the first line feed is the end of the string and ignore the rest of the data. If however they're breaking the message up by pipe characters and feeding the XML payload to an XML parser then no it's not a problem. Unless the XML has pipe characters in it.
But this question is best directed at the team handling the end application. It's their opionion on line feeds that is the only important one here. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|