Page 1 of 1

Extracting XML input with multiple repetative key elements

Posted: Thu Mar 15, 2012 12:42 am
by Narayan Reddy
Hi,

I have requirement to extract the xml file which looks like

<Start>
<SeqNo>12</SeqNo>
<DocRef>
<Eur_DocRef>A</Eur_DocRef>
<Eur_DocIdent>1</Eur_DocIdent>
<Eur_DocRef>B</Eur_DocRef>
<Eur_DocIdent>2</Eur_DocIdent>
<Eur_DocRef>C</Eur_DocRef>
<Eur_DocIdent>3</Eur_Docdent>
</DocRef>
</Start>


We have taken Eur_DocRef and Eur_DocIdent in separate link with a single key as repetative key element in XML input stage
and funneling all the data and remove duplicate based on all elements.

External_Source--->XML Input--(2 links for each repetitive key element)--> funnel-->remove duplicate--->sequential file

The output we got looks like

SeqNo Eur_Docref Eur_DocIdent
12 A 1
12 A 2
12 A 3
12 B 1
12 C 1

What we are expecting is

SeqNo Eur_Docref Eur_DocIdent
12 A 1
12 A 1
12 A 1
12 B 2
12 C 3


please help us on this


Regards,
Reddy

Posted: Thu Mar 15, 2012 1:03 am
by ray.wurlod
Do you know how to specify xpath and repeating elements? If not, a search here and in Ernie's blog will be an excellent learning experience.

Posted: Thu Mar 15, 2012 3:22 am
by Narayan Reddy
I have tried with repetitive key element but i am not getting the expected output.

I have gone through blogs and tried but no use.

Regards,
Reddy

Posted: Thu Mar 15, 2012 3:39 pm
by eostic
I see nothing natural in that xml that would produce the output that you say you are expecting.

"A" has no priority or parentage in that structure...it's simply another instance of docref.

I would hope and expect that you should get:

for the docref link:

12 A
12 B
12 C

...three rows.


and for the other link:

12 1
12 2
12 3


....then the rest is up to you. Pretend it was just two relational tables with 3 rows each. how do you want to combine them? There is nothing inherent in that xml structure that defines their relationship....and if there "should be" then it's a fairly poor xml structure.

Ernie

Posted: Thu Mar 15, 2012 5:39 pm
by djbarham
eostic wrote:I see nothing natural in that xml that would produce the output that you say you are expecting.
I agree with Ernie. The XML does not look right. Can you post the XSD?

Posted: Sun Mar 18, 2012 6:37 am
by eostic
at quick glance, it looks like your example. The xml is perfectly valid, and probably the xsd is too.

replaced by, ammended by, corrected by (others also)--- each of these are simply independent repeating elements.....

retreive them as I noted above in your original example. On separate links.... then decide (perhaps there are other keys or higher level element and attribute info on each row to help your decision?) how to combine them downstream.

The parsing is simple. multiple output links.

Ernie