CSV to XML Issues

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Diya
Participant
Posts: 38
Joined: Fri Feb 17, 2006 7:02 am

CSV to XML Issues

Post by Diya »

Hi all,

We are converting CSV files(Input) to XML files(Output).

Input file format:

Empno, Ename, Job
1,X,A
2,Y,B
3,Z,C

Required Output file:

<ApplicationPrincipalAttributeValues>
<AppAttributeName>Empno</AppAttributeName>
<AppAttributeValue>1</AppAttributeValue>
</ApplicationPrincipalAttributeValues>

<ApplicationPrincipalAttributeValues>
<AppAttributeName>Ename</AppAttributeName>
<AppAttributeValue>X</AppAttributeValue>
</ApplicationPrincipalAttributeValues>

<ApplicationPrincipalAttributeValues>
<AppAttributeName>Job</AppAttributeName>
<AppAttributeValue>A</AppAttributeValue>
</ApplicationPrincipalAttributeValues>


To do this process, do we need to convert above input file to the following format shown below before converting to XML format..; or is there any other option which can convert directly to above XML output.

Empno, 1
Ename ,X
Job, A
Empno ,2
Ename, Y
Job, B
Empno ,3
Ename, Z
Job , C

Thanks,
anujgarg
Participant
Posts: 38
Joined: Sun Jun 26, 2005 11:17 pm

Re: CSV to XML Issues

Post by anujgarg »

Hi Diya,

You cannot have output like this.For that you need another root tag above your <ApplicationPrincipalAttributeValues> and use aggregate mode in setting . Then you can get this result.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do you have a sample of this output already generated or perhaps an xsd? Use it to import the metadata of the desired target format so that the proper XPath expressions can be generated for you for use in your job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Thanks ,I will try this way and let you know further
Thanx&Regards
scorpion
Post Reply