[resolved] XML output with dynamic schema

One Star

[resolved] XML output with dynamic schema

Hi guys, first post here.
I've been using TOS for a few days and I'm facing a problem that I can't solve. I've looked in the forums with no success.
For instance, imagine I have a csv like this (first column is a Property Name and second columns is Property Value):
weight; 100
height; 2
eyes; blue
hair; black
I need to generate an XML file like this:
<root>
<weight>100</weight>
<height>2</height>
<eyes>blue</eyes>
<hair>black</hair>
</root>
Basically I have to generate an xml and its schema depends on the data.
Has anyone succeeded in doing this? I couldn't do it with the Xml components and I don't know how to do it with the tJava component.
I don't mind having to develop a custom component but it would be nice to use one of the available components.
Thanks,
Tiago

Accepted Solutions
Community Manager

Re: [resolved] XML output with dynamic schema

Hi
It is impossible to define a element name base on the input data, in Talend, a XML tree is defined at the design time, not the run time. It is easy to generate the XML if you consider the following XML tree:
<root>
<info>
<property_name>weight</property_name>
<property_value>100</property_value>
</info>
<info>
<property_name>height</property_name>
<property_value>2</property_value>
</info>
...
</root>
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] XML output with dynamic schema

Hi
It is impossible to define a element name base on the input data, in Talend, a XML tree is defined at the design time, not the run time. It is easy to generate the XML if you consider the following XML tree:
<root>
<info>
<property_name>weight</property_name>
<property_value>100</property_value>
</info>
<info>
<property_name>height</property_name>
<property_value>2</property_value>
</info>
...
</root>
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] XML output with dynamic schema

Thanks for your help, Shong.