Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Myself1
Contributor III
Contributor III

XML File output format

Hi,

First of all, I'm not a Talend Studio expert, that's the reason why I post this before to search really how to do it

One of our jobs is extracting data from an Oracle Autonomous db to generate several XML files as output for internal tools and usage.

Currently the output format of those xml files is :

<?xml version="1.0" encoding="UTF-8"?>

<time_slots>

   <time_slot>

      <tsid>1</tsid>

      <tsname>07-09</tsname>

      <tslabel>07-09</tslabel>

      <tsstatus>inactive</tsstatus>

      <tstime_from>07:00:00</tstime_from>

      <tstime_to>09:00:00</tstime_to>

   </time_slot>

   <time_slot>

      <tsid>2</tsid>

      <tsname>08-12h30</tsname>

      <tslabel>080000130000</tslabel>

      <tsstatus>active</tsstatus>

      <tstime_from>08:00:00</tstime_from>

      <tstime_to>12:30:00</tstime_to>

   </time_slot>

</time_slots>

The expected output format is:

<?xml version="1.0" encoding="UTF-8"?>

<time_slots>

 <time_slot>

   <Field name="tsid">1</Field>

   <Field name="tsname">07-09</Field>

   <Field name="tslabel">07-09</Field>

   <Field name="tsstatus">inactive</Field>

   <Field name="tstime_from">07:00:00</Field>

   <Field name="tstime_to">09:00:00</Field>

 </time_slot>

 <time_slot>

   <Field name="tsid">2</Field>

   <Field name="tsname">08-12h30</Field>

   <Field name="tslabel">080000130000</Field>

   <Field name="tsstatus">active</Field>

   <Field name="tstime_from">08:00:00</Field>

   <Field name="tstime_to">12:30:00</Field>

 </time_slot>

 </time_slots>

What's the best way to reformat the XML output file ?

tMap, ... ?

Examples will be welcome.

Many Thanks for any suggestion.

Regards,

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi

Try with tAdvancedFileOutputXML component that allows you configure the XML tree structure through GUI.

 

0695b00000lw9gyAAA.png 

Regards

Shong

View solution in original post

9 Replies
Anonymous
Not applicable

Hi

Try with tAdvancedFileOutputXML component that allows you configure the XML tree structure through GUI.

 

0695b00000lw9gyAAA.png 

Regards

Shong

Myself1
Contributor III
Contributor III
Author

Hi Shong,

 

Great, it works.

Additional question : is there any way to import those configurations setting from file, ... because for some xml files, we have more than 300 tags and fill in manually will become tedious.

 

Regards,

Anonymous
Not applicable

Right click on the root node, then select 'import XML tree' item to import the XML tree from a file.

0695b00000lwauxAAA.png

Myself1
Contributor III
Contributor III
Author

Many thanks for this appropriate reply.

 

Regards,

Myself1
Contributor III
Contributor III
Author

Hi,

 

I'm back with the same job.

As suggested I used the component tAdvancedFileOutputXML to format the XML output file,.

The option Import XML Tree didn't work on my side, so I decided to fill in 'manually' but it seems that there's a limit to this component, after having created 99 Field\name, when I try to run my job, there's a compilation error, cf Error.jpg file attached.

 

Any idea to fix this ?

 

Regards,

Anonymous
Not applicable

About the compilation error, click the Code tab to open the job generated Java code, you will see which lines have the error and what are the error messages. I'm not sure if there is a limitation of fields' number on the component, I hope you can help to test and confirm it, try to reduce the fields and see if the error disappears.

 

 

 

Myself1
Contributor III
Contributor III
Author

Hi Shong,

 

Before posting, I already tried to reduce the number of fields, it works fine with 99 fields, and not with 100. So I supose there's a limit.

Because I'm a little bit huried, I'll add several components tAdvancedFileOutputXML and then concate all output xml files.

I'll see later for a more appropriate design.

 

Regards,

Anonymous
Not applicable

@JC JC​ , thanks for your confirmation, I think it would be best to have our developers check it out, can you please raise a jira issue on Talend Bugtracker with a sample job?

Myself1
Contributor III
Contributor III
Author

Hi,

 

issue ticket : https://jira.talendforge.org/browse/TBD-15508

 

Regards,