Author |
Message
|
harsha_sg |
Posted: Thu May 15, 2014 11:32 am Post subject: Multiple XML file creation at File output Node |
|
|
Newbie
Joined: 01 May 2014 Posts: 5
|
I've been working on XML based proj ..,where i need to Create 2 different files at file output node separating on an condition.
Something like guess my XML Input has 3 different fields Name,ID,Designation..,I need to create two different XML output files Separated upon the Designation's [Only one File output Node has to be used]
How Can i implement this,,??
Though am getting..,its not in well-formed XML format...Everytime i propagate the content thru compute node output..,the next message will be created in a new 'Root'
Message Flow
File_Input>>>Compute>>File_Output
I've Used DFDL parser for parsing the Pipe delimetted my input
Please Help me out in solving This
Thank You |
|
Back to top |
|
 |
Esa |
Posted: Thu May 15, 2014 11:16 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
|
Back to top |
|
 |
harsha_sg |
Posted: Fri May 16, 2014 12:48 am Post subject: |
|
|
Newbie
Joined: 01 May 2014 Posts: 5
|
Can u elaborate
I've this code
Code: |
DECLARE I INTEGER 1;
DECLARE J INTEGER;
DECLARE K INTEGER 1;
DECLARE L INTEGER 1;
SET J = CARDINALITY(InputRoot.DFDL.DFDL_Message.*[]);
WHILE I <= J DO
IF InputRoot.DFDL.DFDL_Message.body[I].Designation='Programmer' THEN
SET OutputLocalEnvironment.Destination.File.Directory='D:\DFDL_POC\OUT\PAT\';
SET OutputLocalEnvironment.Destination.File.Name ='PAT.xml';
SET OutputLocalEnvironment.Destination.File.Action='Append to existing file';
SET OutputLocalEnvironment.Destination.File.TimeStamp=CURRENT_TIMESTAMP;
SET OutputRoot.XMLNSC[1].Root.body[K]=InputRoot.DFDL.DFDL_Message.body[I];
ELSEIF InputRoot.DFDL.DFDL_Message.body[I].Designation='MANAGER' THEN
SET OutputLocalEnvironment.Destination.File.Directory='D:\DFDL_POC\OUT\MANAGER\';
SET OutputLocalEnvironment.Destination.File.Name ='MAG.xml';
SET OutputLocalEnvironment.Destination.File.Action='Append to existing file';
SET OutputLocalEnvironment.Destination.File.TimeStamp=CURRENT_TIMESTAMP;
SET OutputRoot.XMLNSC[2].Root.body[L]=InputRoot.DFDL.DFDL_Message.body[I];
END IF;
SET I = I + 1;
PROPAGATE TO TERMINAL 'out' delete NONE;
END WHILE; |
But Not in Well-Formed XML format |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 16, 2014 1:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
So you're not appending but getting a new file, every time?
I'd expect this would be because of this line:
Code: |
SET OutputLocalEnvironment.Destination.File.TimeStamp=CURRENT_TIMESTAMP; |
As to well formed XML.... well if your content is XML you have to write the declaration and opening tags down to the repeating element manually, then again all the closing tags manually...
For that I'd use the BLOB domain...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
harsha_sg |
Posted: Sun May 18, 2014 9:59 pm Post subject: |
|
|
Newbie
Joined: 01 May 2014 Posts: 5
|
fjb_saper wrote: |
So you're not appending but getting a new file, every time?
I'd expect this would be because of this line:
Code: |
SET OutputLocalEnvironment.Destination.File.TimeStamp=CURRENT_TIMESTAMP; |
As to well formed XML.... well if your content is XML you have to write the declaration and opening tags down to the repeating element manually, then again all the closing tags manually...
For that I'd use the BLOB domain...
Have fun  |
Am getting single file with mutiple Data as per requirement..,But for every XML data a new Root[Base tag] tag is created..,which is resulting in not a well formed XML file.
Please help me out in debugging this |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 19, 2014 12:48 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
for every XML data a new Root[Base tag] tag is created..,which is resulting in not a well formed XML file |
You have correctly identified the problem. The solution is simple : output the document start tag before the flow starts, and then output the closing tag after it ends. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
|