Author |
Message
|
prasannanb |
Posted: Wed Mar 13, 2013 2:25 am Post subject: xml to csv space and quote |
|
|
Apprentice
Joined: 17 Apr 2009 Posts: 35
|
Hi,
I am converting xml to CSV using Message set.
Input
<Employee>
<name>John</name>
<empno></empno>
<location>US</location>
</Employee>
Expected Output:
"John"," ","US"
Note that for the empty xml tags(empno), I need to create output with a space in between quote.
How can I achieve this? Please help |
|
Back to top |
|
 |
kimbert |
Posted: Wed Mar 13, 2013 3:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Your post is not very clear. Do you mean
a):
or b):
Code tags are very useful when posting formatted data because they make the data easy to read.
The MRM parser will output whatever value is in the message tree, so if you mean a) then you will need to use some ESQL ( or Java/PHP/.Net/Mapping node) to modify the message tree and replace each occurrence of an empty string with exactly one space. |
|
Back to top |
|
 |
prasannanb |
Posted: Wed Mar 13, 2013 4:19 am Post subject: |
|
|
Apprentice
Joined: 17 Apr 2009 Posts: 35
|
I meant a)
<empno></empno>
I was looking if there is any other efficient way than coding in ESQL for each tag |
|
Back to top |
|
 |
tekt9 |
Posted: Wed Mar 13, 2013 4:25 am Post subject: User Message definition |
|
|
Novice
Joined: 13 Aug 2012 Posts: 15
|
Hi...
I belive you can set the default value in your message definition to " ". When you then convert to csv, missing elements will get converted to space. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 13, 2013 4:32 am Post subject: Re: User Message definition |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
tekt9 wrote: |
I belive you can set the default value in your message definition to " ". When you then convert to csv, missing elements will get converted to space. |
In the example quoted, is empno missing? Empty? Null?
WMB does not react the same way to all 3 cases. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Mar 13, 2013 7:05 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
tekt9 is correct - you can exploit standard XML Schema defaulting to do this automatically.
1. In the xsd for the *input* XML, ensure that you set the default value to " " ( a single space ) for every element that you want to treat in this way.
2. In your input node. set Validation to 'Content and Value'. Otherwise XMLNSC will not bother to look at the xsd, and will not therefore pick up the default values. |
|
Back to top |
|
 |
|