Page 1 of 1

Unable to combine repetition attribues in xml file

Posted: Tue Mar 19, 2013 5:01 am
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

Posted: Tue Mar 19, 2013 5:12 am
by prasannakumarkk
Please post the Xpath and key column defined

Posted: Tue Mar 19, 2013 5:18 am
by ujala
Key column is the "rid"

And the XPATH defined for
rid - /Attributes/@rid
referencedTerms - /Attributes/parentAttributes/referencedTerms/termRef/@identity

Posted: Tue Mar 19, 2013 6:06 am
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

Posted: Tue Mar 19, 2013 8:01 am
by prasannakumarkk
what is the xpath for termRef

Posted: Wed Mar 20, 2013 7:55 am
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!!!

Posted: Wed Mar 20, 2013 10:31 am
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