XML Write

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
semja0
Participant
Posts: 7
Joined: Thu Nov 21, 2002 8:38 am
Location: Sweden

XML Write

Post by semja0 »

How do I get a comma separated file like this
221,AAAAAA
221,BBBBBB
222,CCCCCC

To look like this

{InvoiceRow}
{RowIdentifier}221{/RowIdentifier}
{RowFreeText}AAAAAA{/RowFreeText}
{RowFreeText}BBBBBB{/RowFreeText}
{/InvoiceRow}
{InvoiceRow}
{RowIdentifier}222{/RowIdentifier}
{RowFreeText}CCCCCC{/RowFreeText}
{/InvoiceRow}


I am only able to get this

{InvoiceRow}
{RowIdentifier}221{/RowIdentifier}
{RowFreeText}AAAAAA{/RowFreeText}
{/InvoiceRow}
{InvoiceRow}
{RowIdentifier}222{/RowIdentifier}
{RowFreeText}CCCCCC{/RowFreeText}
{/InvoiceRow}


I am sure i am doing it wrong but please help me to get it right.

Please read
{ as <
and
} as >

Of some reason XML does not look well on this page
Paul Preston
Participant
Posts: 24
Joined: Wed Apr 02, 2003 7:09 am
Location: United Kingdom

Post by Paul Preston »

assuming your flat csv file input is read into two fields put the following in the description fields of the XML writer stage and you should get what you want:

/InvoiceRow/RowIdentifier/#PCDATA
/InvoiceRow/RowIdentifier/RowFreeText/#PCDATA

in the following output I have replaed the less than and greater than brackets with { and } so that it appears formatted correctly sorry that the posting also removes the nice indentation produced by the XML writer:

{InvoiceRow}
{RowIdentifier}221{/RowIdentifier}
{RowIdentifier}
{RowFreeText}AAAAAA{/RowFreeText}
{/RowIdentifier}
{RowIdentifier}
{RowFreeText}BBBBBB{/RowFreeText}
{/RowIdentifier}
{/InvoiceRow}
{InvoiceRow}
{RowIdentifier}222{/RowIdentifier}
{RowIdentifier}
{RowFreeText}CCCCCC{/RowFreeText}
{/RowIdentifier}
{/InvoiceRow}
semja0
Participant
Posts: 7
Joined: Thu Nov 21, 2002 8:38 am
Location: Sweden

Post by semja0 »

Hi Paul,

Thanks for your reply.
From what I can se from your reply it does not completely match what I am looking for. {RowFreeText} is not a sub element to {RowIdentifier}. They exist on the same level under the complex type {InvoiceRow}. The difference is that {RowFreeText} can be repeated infinite times.
Do you think you can adjust your reply according to that relation?

Regards

Jan
Paul Preston
Participant
Posts: 24
Joined: Wed Apr 02, 2003 7:09 am
Location: United Kingdom

Post by Paul Preston »

Hello Jan

yes. Use the following but make sure that the first column is marked as a key on the column definitions tab and use the following in column descriptions field AND NOTE THE USE THE DOUBLE SLASH in the second column description:

/InvoiceRow/RowIdentifier/#PCDATA
/InvoiceRow//RowFreeText/#PCDATA

On datastage 5.2 on Solaris gave me the following:

{InvoiceRow}
{RowIdentifier}221{/RowIdentifier}
{RowFreeText}AAAAAA{/RowFreeText}
{RowFreeText}BBBBBB{/RowFreeText}
{/InvoiceRow}
{InvoiceRow}
{RowIdentifier}222{/RowIdentifier}
{RowFreeText}CCCCCC{/RowFreeText}
{/InvoiceRow}
Post Reply