Reading XML files - Repetition elements

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Reading XML files - Repetition elements

Post by aluthra48 »

Can anyone explain what the following error means:

Error: No repetition element specified for link datastage

and perhaps provide an example of a repetition element (occurs) and how to interpret it in the xml input stage design?

Thanks
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Go to XMLInput stage's Output-->Columns-->Key, then set "yes" on one of the columns.
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Correct, but I am trying to understand what column to set the key to yes, and why. Thanks
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I try to describe it as "one of the elements at the lowest level node you are interested in retrieving." You can pick any of them.... but it should be a column defined by an element at the lowest level repeating group --- the repeating node for which you want "n" rows to be returned.

The reason you want it at the "lowest level you are interested in" will become more clear once you have a situation where the node may not actually exist (imagine a purchase order with no line items, and the repeating element in the metadata is the line item number). Then the "Repeating Element Required" setting comes into play. If you have it checked, then the repeating element has to be in the current node being retrieved or you won't receive the parent or grandparent nodes. If you have it un-checked, then everything at the level of the "repeating element" will be returned with nulls.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Thanks Ernie,

I have checked the "Repeating Element required" in the transformation settings of the output tab. What I am trying to figure out is the Yes/No option in the Columns tab for the Key value of the element listed.
Here is an example:
The source is <QVResponse><Response><Error><ErrorCode>value</ErrorCode></Error></Response></QVResponse>
where the Error node is unbounded. Similarly there are other lower level nodes below QVResponse along a different path where one of the nodes is also unbounded.
How do I translate this information to selecting the above Yes/No option? I have set some of the column names to Yes based on what understanding I have, and it now gives me an error "The link contains more than one repetition rule"
Thanks
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

ah. Next lesson. DataStage is normalizing your xml into rows and columns... for each set of nodes that is "along a different path" (nested deeply is fine), you will be using a separate Link...each with its own set of elements/columns and particular "lowest level node that you are interested in".......

For any given document, as you are moving it (typically) into a rdbms, you may have many many links....depending on how many normalized relationships you are trying to extract.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

I get it. Right now, I have an external source stage -----> xml stage-----> peek stage. This was set up for purposes of experimentation.

What I would need is an external source stage---->copy stage with several output links, each to an xml input stage, and each of these xml input stages having an output link to an ODBC stage. Each of these ODBC stages and the corresponding setting in the output/columns tab of the xml input stage would reference a single normalized relationship that I am trying to extract.

Correct?

Thanks
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

If i remember correctly, You could cascade Multiple XML stages also

Something like this:

Code: Select all

<Cust>
        <Name>

        </Name>
        <AddressList>
                <Address>
                        Address1
                </Address>
        </AddressList>
        <PhoneList>
                <Phone>
                        Phone1
                </Phone>
        </PhoneList>
</Cust>

Code: Select all


external source stage -----> xml stage1---(Get Name/AddressChunk) -----> xml stage(Get Address+Prev name)-----> peek stage
                                    |
                          (Get Name/PhoneChunk)
                                    |
                                    -----> xml stage(Get Phone+Prev name)-----> peek stage
Prev name stands for the previously extracted name information in XMl Stage 1

Based on the number of repeating elements you have, you can use the first stage to extract XML chunks for that repeating element with some of the higher level columns and send each chunk/extracted column down a separate link where a downstream XML Input stage processes the specific chunk.

I've done this around a year ago so may not have described this accurately.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You have the right idea....but you can put all the output links on a single XMLInput Stage.......so you don't need the copy....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Thank you all, I will try it. I have been busy with some other issues, and will get back to this and try it out as soon as I can.

Thanks once again
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Thank you, I have it working now.
Post Reply