Search code examples
datastage

In DataStage, how do you extract an element together with a list of elements from an XML file


so I've spent hours trying to figure this out. I'm basically trying to read an xml document (using the Hierarchical Data stage). Then I need to output the contents of that document into a dataset with two columns.

The difficulty is that in the xml document I read from an element and then I need to read from a list of elements; Specifically productID and SubjectCode.

Content of XML file to read

The output I need is this

Output I'd like to get

But I'm getting the following error because DataStage doesn't want to associate a single element with a multiple list element .

Error from DataStage

I should mention that if subjectCode was a single element like productID, it works fine. Any ideas would be appreciated.


Solution

  • Apologies, I'm not at a computer to deliver screenshots but I recall having a similar issue and this answer is intended to give you some more options to try (if you haven't already done these!)

    I believe you can set subjectCode as the "top" element and then the mapping for productID would become ../productID

    Failing that, you can right click and set subjectCode element differently within the XML_Parser_step in order to create a repeater element there

    I believe the Datastage XML Integration Redbook covers off the above and is available from the IBM for free