Page 1 of 1

xml repeating groups problem

Posted: Thu Nov 26, 2009 1:17 pm
by boxtoby
I am having a problem with repeating groups. I have read the various posts and the best practises document but I still cannot get it to work.

I have reduced the exercise to a simple example whereby Friend_Name and Friend_Number are the repeating group for the name.

The Friend_Number is defined as the key to identify the repeating group.

However, I get flat xml output, ie one Name for each Friend_Name

Any help would be greatly appreciated.

Bob.


SOURCE DATA

Pr_Key,Name,Friend_Number,Friend_Name,Status
001, Bob, 1, Friend 1, Open
001, Bob, 2, Friend 2, Closed
002, Dave, 3, Mate 1, Unknown
002, Dave, 4, Mate 2, Suspended

XSD:

/Friends/Owner/Pr_Key/text()
/Friends/Owner/Name/text()
/Friends/Owner/Contacts/Friend_Number/text()
/Friends/Owner/Contacts/Friend_Name/text()
/Friends/Owner/Status/text()


OUTPUT:

<Friends>
<Owner>
<Pr_Key>
1
</Pr_Key>
<Name>
Bob
</Name>
<Contacts>
<Friend_Number>
1
</Friend_Number>
<Friend_Name>
Friend 1
</Friend_Name>
</Contacts>
<Status>
Open
</Status>
</Owner>
<Owner>
<Pr_Key>
1
</Pr_Key>
<Name>
Bob
</Name>
<Contacts>
<Friend_Number>
2
</Friend_Number>
<Friend_Name>
Friend 2
</Friend_Name>
</Contacts>
<Status>
Closed
</Status>
</Owner>
<Owner>
<Pr_Key>
2
</Pr_Key>
<Name>
Dave
.
.
.
.
.
.

Posted: Thu Nov 26, 2009 1:32 pm
by chulett
It usually helps to post both the output you want versus the output you get, clearly labelling which is which.

I mean, helps us mere mortals, Ernie probably needs no such. :wink:

Posted: Thu Nov 26, 2009 2:16 pm
by boxtoby
Dear Mortals,

Sorry if my first post wasn't clear, hope this helps!

The output should look something like this,

<Friends>
<Owner>
<Pr_Key>
1
</Pr_Key>
<Name>
Bob
</Name>
<Contacts>
<Friend_Number>
1
</Friend_Number>
<Friend_Name>
Friend 1
</Friend_Name>
<Friend_Number>
2
</Friend_Number>
<Friend_Name>
Friend 2
</Friend_Name>
</Contacts>
<Status>
Closed
</Status>
</Owner>
<Owner>
<Pr_Key>
2
</Pr_Key>
<Name>
Dave