Repeating tags in XML

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
midmaxds
Premium Member
Premium Member
Posts: 71
Joined: Mon Oct 26, 2015 11:44 am

Repeating tags in XML

Post by midmaxds »

Hi
We have a requirement to generate an XML file from a table input data.
We have four fields coming from my table input out of which three fields should be mapped to one and the same XML tag in the generated XML.


Eg:
The three input fields are Phone_No, Mob_No and Fax_No.
The output tag is 'ContactNumber'.
The XML should look like

Code: Select all

<Person>
    <ContactID>ABCD</ContactID>
       <ContactMethod>
          <ContactNumber>1234</ContactNumber>
                  <ContactType>Phone</ContactType>
         <ContactNumber>4567</ContactNumber>
                  <ContactType>Mob</ContactType>
         <ContactNumber>9876</ContactNumber>
                <ContactType>Fax</ContactType>
  </ContactMethod>
</Person>

Hierarchical stage is being used. Could you please help?
Please let me know if more information is needed.
Midhun
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Some things to consider:

1) do you have an xsd for this structure?

2) this has three repeating nodes of "contact info"....you need to turn your existing 3 columns into 3 "rows" of information coming in.

3) rows are "lists" in the xml Stage, and as such, can be mapped to a repeating node in your xsd that corresponds to an occuring complex type in the schema.

....or.....it may be simpler in the xmlOutput Stage, although I would prefer seeing a containment node (like <contactMethods><contactMethod> surrounding your individual contact type and contact number elements.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
midmaxds
Premium Member
Premium Member
Posts: 71
Joined: Mon Oct 26, 2015 11:44 am

Post by midmaxds »

Thanks, Ernie.
We tried the pivot option for 3 fields alone and did some tweaking to get it working :)
Midhun
Post Reply