Author |
Message
|
bdaoust |
Posted: Thu Oct 15, 2015 10:21 am Post subject: XML to CSV without a CSV message set? |
|
|
Centurion
Joined: 23 Sep 2010 Posts: 130
|
Can you convert XML to CSV without creating a message definition for the CSV file?
I have a large XML with over 600 elements and was hoping I don't have to create a message definition for the CSV.
For instance, one thought I had was in ESQL. Loop though all XML elements, extract the element name and then build a comma delimited string as I go.
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 15, 2015 11:00 am Post subject: Re: XML to CSV without a CSV message set? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
bdaoust wrote: |
For instance, one thought I had was in ESQL. Loop though all XML elements, extract the element name and then build a comma delimited string as I go. |
It'd certainly work. Almost certainly run like a dog with three legs and asthma, given the efficiency of ESQL's string handling.
Bad luck for you if there's 6,000 elements not 600.
Bad luck for whoever you're sending the file to if the elements don't turn up in the same order every time. Or you go through the child elements in a tree fashion and they expect level 1 / level 2 / level n. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
bdaoust |
Posted: Thu Oct 15, 2015 11:17 am Post subject: |
|
|
Centurion
Joined: 23 Sep 2010 Posts: 130
|
Ok - thanks for that info.
Sounds like I just need to do the CSV message model.
Appreciate the feedback.
-Brian |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Oct 15, 2015 11:42 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The other advantage of the DFDL model is that you can verify data types - make sure that you don't put strings in place of numbers, that kind of thing.
You should likely have some kind of existing model thing that you can import to create the DFDL model - a copybook or some such. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
timber |
Posted: Thu Oct 15, 2015 2:38 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
one thought I had was in ESQL. Loop though all XML elements, extract the element name and then build a comma delimited string as I go. |
What will you do about element values that contain quote characters or newlines? This is something that's often forgotten when people 'just write a quick implementation'. But it matters, and DFDL will do it for you automatically and according to the accepted standard for CSV.
In fact, it's probably quicker to use the DFDL wizard to create the model than to code the ESQL.
btw, the term 'message set' does not apply to DFDL. It's a 'DFDL model'. Message sets cannot contain DFDL models. |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Oct 16, 2015 4:51 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
timber wrote: |
This is something that's often forgotten when people 'just write a quick implementation'. |
I get this all the time from business folks, "just create a 'quick' name or address parser". They greatly underestimate the variability of the data being asked to work with. |
|
Back to top |
|
 |
|