XML o/p format

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

XML o/p format

Post by ankita »

Hi All,

We want to generate an XML file having format as below,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE system "catalog.dtd">
<root>
<catalog cid="@cid_1" member_id="&MEMBER_ID;" identifier="Company" description="Company"/>
<cgrpid cgrpid="@cgrpid_1" member_id="&MEMBER_ID;" identifier="Company_DIV_1" markfordelete="0" field1="-"/>
<cgrpid cgrpid="@cgrpid_2" member_id="&MEMBER_ID;" identifier="Company_DIV_2" markfordelete="0" field1="-"/>
<strgrp str_id="&str_id_3;" cgrpid="@cgrpid_id_1"/>
<strgrp str_id="&str_id_3;" cgrpid="@cgrpid_id_2"/>
</root>

It's not the complete o/p, just a sample. Most of the attributes are fixed, few will be variable, like Company will be replace by actual Company name, id s will be incremented as cgrpid_1, cgrpid_2 etc. How can I generate this type o/p using XML output stage ? More specifically,

Q1 > How to generate single tag as <tag/> without having separate opening, closing tag ?
Q2> Multiple tags are repeated within a root tag. So what should be the repeatation element ?

Please help !

Thanks,
Ankita
bakul
Participant
Posts: 60
Joined: Wed Nov 10, 2004 2:12 am

Post by bakul »

For <tag/>, there is an option in the XML output stage itself which lets you choose the format you desire for closing tags.
For your second requirement, unfortunately, XML stages do not allow multiple repeating tags at the same level.
So, you will need to create dummy tags to put the repeating tags in separate levels.
For e.g:
<note>
<cgrpid cgrpid="@cgrpid_1" member_id="&MEMBER_ID;" identifier="Company_DIV_1" markfordelete="0" field1="-"/>
<cgrpid cgrpid="@cgrpid_2" member_id="&MEMBER_ID;" identifier="Company_DIV_2" markfordelete="0" field1="-"/>
</note><note>
<strgrp str_id="&str_id_3;" cgrpid="@cgrpid_id_1"/>
<strgrp str_id="&str_id_3;" cgrpid="@cgrpid_id_2"/>
</note>

I have worked with XML stages in the version 7.5. Am not sure if this has been changed or upgraded after that.
Regards,
Bakul
Post Reply