Author |
Message
|
MB Developer |
Posted: Mon Apr 21, 2014 1:43 am Post subject: CSV to XML Convertion |
|
|
 Disciple
Joined: 03 Feb 2014 Posts: 179
|
Hi All,
I want to convert CSV to XML .
I know how to convert XML to CSV.
The recommended way to do this is:
a) Create a message set for the CSV format, using the CSV sample as a guide.
b) Parse the input document using XMLNSC
c) In a Compute node ( or a Mapping node, if you prefer ) copy InputRoot.XMLNSC to Output.DFDL .
Message Set is already created.
I want to take FileInput,Compute and FileOutput nodes.
For XML to CSV conversion in Compute node I wrote code like below
SET OutputRoot.DFDL.CSV_MessageSet.header.Year = 'Year';
SET OutputRoot.DFDL.CSV_MessageSet.record[I].Year = InputRoot.XMLNSC.SubTotals.sub.Year;
but I don't know how to write code for CSV to XML please help me....
For XML to CSV conversion in Compute node I write code like below
SET OutputRoot.XMLNSC.CSV2XML_DFDL.header.firstname = 'firstname';
i dnt write code for record ... please help me....
and I already search for this and read in info center but I am not understand...
Thanks in Advance,
Suresh K |
|
Back to top |
|
 |
kimbert |
Posted: Mon Apr 21, 2014 2:13 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
a) Did you get the sample working?
b) Did you manage to change the sample to write your CSV format?
If you can *write* your format using DFDL then it should be trivial to *parse* the same format. _________________ 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 |
|
 |
MB Developer |
Posted: Mon Apr 21, 2014 2:26 am Post subject: |
|
|
 Disciple
Joined: 03 Feb 2014 Posts: 179
|
|
Back to top |
|
 |
kimbert |
Posted: Mon Apr 21, 2014 3:04 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I want to write code in compute node for all records... |
OK - so you want help with writing some ESQL. Is that correct?
Please quote the code that you have tried, and tell us what is wrong with the results that it produces. _________________ 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 |
|
 |
mqsiuser |
Posted: Mon Apr 21, 2014 3:24 am Post subject: Re: CSV to XML Convertion |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
MB Developer wrote: |
but I don't know how to write code for CSV to XML please help me... |
For Broker a CSV file is a flat file with an element-delimiter (which is ",") (and a line delimiter, e.g. <CR> or <CR><LF>)
So you create a message set to parse that flat file.
Which is really easy, since a CSV file is a simple flat file format
When reading-in Broker parser that into a "logical" message tree and put it under e.g. InputRoot.XMLNSC. ...
You can just output (write-out) that tree "as XML" (with e.g. XMLNSC) or ...
you can change the structure of that tree (e.g. with ESQL) and then output it as XML. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
kimbert |
Posted: Mon Apr 21, 2014 1:12 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
mqsiuser said:
Quote: |
For Broker a CSV file is a flat file with an element-delimiter (which is ",") (and a line delimiter, e.g. <CR> or <CR><LF>) |
Not just Broker. That definition is a pretty standard definition of 'a CSV file'. Some countries use | ( pipe ) instead of comma, which the DFDL CSV wizard supports. Sometimes the newline is different, which the DFDL wizard also supports.
mqsiuser said:
Quote: |
So you create a message set to parse that flat file |
Only if you're using message broker v7. From v8 onwards it would be better to create a DFDL schema using the CSV wizard. _________________ 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 |
|
 |
mqsiuser |
Posted: Mon Apr 21, 2014 3:16 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Whatever. SOA just vanished and nobody is missing it.
Why? There is no problem. There never was a problem.
WHAT is the problem?
Systems interchange msgs and the structure is different (and we must change it)
But thats it, everything else (routing, codepage convertion, reading&writing and (tree-)parsing, encryption, etc....): Everybody (language/platform) can do that and does that... Broker does it (a bit) better?
Everything else: You may (also) do it (or not): "GBO", "ASBO", "CBOM" (not so technology dependent, but who cares anyway (today) about that (any more)?) _________________ Just use REFERENCEs |
|
Back to top |
|
 |
|