Unable to combine repetition attribues in xml file

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
ujala
Participant
Posts: 45
Joined: Mon Jun 21, 2010 2:51 pm
Location: Chennai

Unable to combine repetition attribues in xml file

Post by ujala »

Hello All,
I have a problem to combine all the attributes which have different terms into one.

Job design : oracle connector - > Transformer - > xml output stage

Obtained target data from the Parallel job :
<Attributes>
<Attributes rid="6662c0f2.ee6a64fe.l24jqigsp.covj0co.drb6tl.jfop11sr6p7jecls0aoe4" name="casd">
<parentAttributes identity="cas" rid="6662c0f2.ee6a64fe.l24jqigsg.9nl3ohv.2tvhev.vc087jfjmmm1gu529g2hj"/>
<referencedTerms>
<termRef identity="term1" rid="6662c0f2.e1b1ec6c.l24jqh6sb.s9vjv3o.59nikr.piqs04lp4q4gt5ue6q8m4"/>
</referencedTerms>
</Attributes>


<Attributes rid="6662c0f2.ee6a64fe.l24jqigsp.covj0co.drb6tl.jfop11sr6p7jecls0aoe4" name="casd">
<parentAttributes identity="cas" rid="6662c0f2.ee6a64fe.l24jqigsg.9nl3ohv.2tvhev.vc087jfjmmm1gu529g2hj"/>
<referencedTerms>
<termRef identity="Term5_null" rid="6662c0f2.e1b1ec6c.l24jqh6te.l4jtt5b.136ghj.cmcgds8veqt83oea3594f"/>
</referencedTerms>
</Attributes>
<Attributes>

Requried output =

<Attributes>
<Attributes rid="6662c0f2.ee6a64fe.l24jqigsp.covj0co.drb6tl.jfop11sr6p7jecls0aoe4" name="casd">
<parentAttributes identity="cas" rid="6662c0f2.ee6a64fe.l24jqigsg.9nl3ohv.2tvhev.vc087jfjmmm1gu529g2hj"/>
<referencedTerms>
<termRef identity="term1" rid="6662c0f2.e1b1ec6c.l24jqh6sb.s9vjv3o.59nikr.piqs04lp4q4gt5ue6q8m4"/>
<termRef identity="Term5_null" rid="6662c0f2.e1b1ec6c.l24jqh6te.l4jtt5b.136ghj.cmcgds8veqt83oea3594f"/>
</referencedTerms>
</Attributes>


Let me know how to get the desired output.
Thanks in advance
prasannakumarkk
Participant
Posts: 117
Joined: Wed Feb 06, 2013 9:24 am
Location: Chennai,TN, India

Post by prasannakumarkk »

Please post the Xpath and key column defined
Thanks,
Prasanna
ujala
Participant
Posts: 45
Joined: Mon Jun 21, 2010 2:51 pm
Location: Chennai

Post by ujala »

Key column is the "rid"

And the XPATH defined for
rid - /Attributes/@rid
referencedTerms - /Attributes/parentAttributes/referencedTerms/termRef/@identity
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Hard to say, but this looks like a the scenario we've seen happen when there is only one innermost element of the repeating node. As a test, see what happens if you add several dummy columns.... create them upstream in a transformer, and give them a unique counter value (use a Stage variable or @INROWNUM).

Then give them xpath that looks like:

/Attributes/parentAttributes/referencedTerms/dummy1/text()

[so that they are at the same "level" as termRef]

Make this new column the key INSTEAD of what you had before.

Hopefully you will only need one, but go up to three additional ones, just in case. Let us know if that impacts the behavior of this inner node...then we can talk about removing it.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
prasannakumarkk
Participant
Posts: 117
Joined: Wed Feb 06, 2013 9:24 am
Location: Chennai,TN, India

Post by prasannakumarkk »

what is the xpath for termRef
Thanks,
Prasanna
ujala
Participant
Posts: 45
Joined: Mon Jun 21, 2010 2:51 pm
Location: Chennai

Post by ujala »

Thank you all for your reply.

I found a solution..
- I used xml stage instead of xml output stage and mapped the required fields accordingly to get the required results and it works perfect.

Thanks again!!!
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Congrats!

For future readers who might find this via search, there are multiple stages that can be used to "write" xml documents. The xmlOutput Stage, which is available in releases 7.x and above, and the XML Stage, which arrived in 8.5. Both Stages can be used, but the XML Stage, which is newer, is far more powerful in features and capabilities, especially where complex multi-node structures are concerned. The XML Stage, however, requires at least "some" working knowledge of xsd's, and requires that you "have" an xsd to work from.

Glad it worked out!

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply