Hopefully simple XML question (Assembly Editor w/ 1:M rels)

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
smleonard
Participant
Posts: 23
Joined: Tue Apr 27, 2004 11:48 am
Location: Westfield Center, OH

Hopefully simple XML question (Assembly Editor w/ 1:M rels)

Post by smleonard »

I feel like I'm missing some small but crucial detail to work with the Assembly Editor screen in 8.5. Let's say I have an XML file that's in a format of:

<Person>
<Name>Sean</Name>
<Address>
<AddressType>Home</AddressType>
<Street>123 Main Street</Street>
</Address>
<Address>
<AddressType>Work</AddressType>
<Street>678 Industrial Parkway</Street>
</Address>
</Person>

And I want the output to be:

Sean, Home, 123 Main Street
Sean, Work, 678 Industrial Parkway

How do I do that? I know if I use a V-Pivot I can set it to be something like:
Name, HomeAddress, WorkAddress

But I really want them to output as separate rows. The problem I'm having is that Address is 1 to Many and I will never know how many there may be. In the Schema Library, it is defined as a List. It seems like I'm able to output any 1 particular List, but I cannot output across multiple lists. I've read the 5 examples in the IBM Help, but they did not show how to do this.

It seems like a very simple XML concept so I'm sure there's a way to work with it. I've only been in the Assembly Editor for a little over a day. Any help is appreciated.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Address "is" the list....so you should be fine. The default behavior is to do exactly what you are looking for...to get two rows, one for each address line, with the same parent info.

Hard to say without looking at your assembly, but it could be in your overall scope and mapping that is done at the output step.

In the xml parser step, you should have the normal document root, and in the output step at the mapping tab, map the address "list" to your output link first....then map the individual elements that make up the address, and then go up above and map the parent information.

One very important recommendation I make when teaching this Stage is to first determine the "lowest" level of the particular hierarchy path for which you want to retrieve multiple rows (in your case this is Address), and then, when at the output mapping step, BEFORE DOING ANYTHING ELSE, map this "list" (blue square-ish icon) to your Output Link. Then fill in the rest (details of the list and any parent or grandparent mappings).

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...by the way, I noticed you mentioned something about not being able to map across "multiple lists"... in the example above, there is only one list ...Address.

Do you have others?

If so, and they are unrelated, (perhaps, like if you had a list of multiple Dependents), then they would need their own Output Link, as they would likely have a completely different number of output rows.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
smleonard
Participant
Posts: 23
Joined: Tue Apr 27, 2004 11:48 am
Location: Westfield Center, OH

Post by smleonard »

Esotic,

Perfect! I had been trying to walk through the XML as it is presented: from top to bottom. That explains why I wasn't able to output across lists. The suggestion to start from the bottom child and then work up was exactly the missing link I needed. Now it's behaving as I would expect.

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

Post by eostic »

great! ....it took me a while to figure that one out also. Once I made it my mantra, things got much easier.

Ernie
Ernie Ostic

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