Author |
Message
|
tank_n_spank |
Posted: Mon Sep 29, 2014 4:16 am Post subject: XML to FLAT FILE |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
Hello,
So I have converted a flat file to XML by reading the entire file and getting it parsed against the message set and then sending the data to the queue in XML format. However, what would the reverse steps be to achieve that - XML file or message in queue to a flat file? Do I need to change/create my message set to run against the XML file and display the values in a file using FILE Output node? I presume it will be simply mapping the raw values and just creating the file?
Kind regards, |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 29, 2014 4:34 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you thought about using DFDL?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
tank_n_spank |
Posted: Mon Sep 29, 2014 4:36 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
I am using it for FLAT File to XML. Should I use it again for XML to FLAT FILE? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 29, 2014 4:39 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you should. _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Mon Sep 29, 2014 5:06 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
DFDL is both a parser and a writer. The DFDL schema defines the physical format and the logical structure. The DFDL parser can convert from bitstream to tree, or from tree to bitstream using the same model. _________________ 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 |
|
 |
tank_n_spank |
Posted: Mon Sep 29, 2014 5:55 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
|
Back to top |
|
 |
tank_n_spank |
Posted: Tue Sep 30, 2014 1:57 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
So,
It is not picking up my value now. But I do get the text file with the test values, just not my actual values.
Can someone please ELI5?
Code: |
SET OutputRoot.DFDL.MyDFDLMessage.*:body.*:body_elem1 = COALESCE(NULLIF(RefInput.body_elem1,'No String Available'), 'test1');
SET OutputRoot.DFDL.MyDFDLMessage.*:body.*:body_elem2 = COALESCE(NULLIF(RefInput.body_elem2,'No String Available'), 'test_value');
SET OutputRoot.DFDL.MyDFDLMessage.*:body.*:body_elem3 = COALESCE(NULLIF(RefInput.body_elem3,'No String Available'), 'test_value3');
SET FILE_NAME = 'Local Test' ||'.txt';
SET OutputLocalEnvironment.Destination.File.Name = FILE_NAME;
PROPAGATE TO TERMINAL 'out' ENVIRONMENT OutputLocalEnvironment;
SET OutputLocalEnvironment.Destination.File.Name = FILE_NAME;
PROPAGATE TO TERMINAL 'out1' ENVIRONMENT OutputLocalEnvironment;
END;
|
If you spot anything that could be optimized/improved, please do share your thoughts, thank you.
Edit; This is the error I am getting now:
CTDP3000E: Unexpected end of data at byte offset '<MISSING INSERT 0>' while parsing element '<MISSING INSERT 1>'. The parser encountered the end of the data stream or the end of a parent element. |
|
Back to top |
|
 |
tank_n_spank |
Posted: Tue Sep 30, 2014 7:23 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
Do I have to use
Code: |
SET OutputRoot.XMLNSC.MyDFDLMessage.*:body.*:body_elem1 = COALESCE(NULLIF(RefInput.body_elem1,'Strin'), 'test1'); |
if I want to get the variable from the xml file? It doesn't work, as I get an exception - The root element is required in a well-formed document.[/code] |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 30, 2014 1:00 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Don't know why you're using a NULLIF. Isn't that just about the same as using COALESCE? ...
And when using the DFDL parser on the output make sure you set the right values on OutputRoot.Properties... (message format, message type, etc...)
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Sep 30, 2014 1:06 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'm confused.
The error is a parsing error, meaning it's an error trying to read or work with the input message.
So the code is failing because the input tree is not parsed correctly, not because the code is doing something wrong. |
|
Back to top |
|
 |
tank_n_spank |
Posted: Wed Oct 01, 2014 12:13 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
|
Back to top |
|
 |
|