BizTalk Server Orchestration - Mapping XML with Nested Loops to Flat XML

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > January 2006 > Mapping XML with Nested Loops to Flat XML





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Mapping XML with Nested Loops to Flat XML
Jeff Darlington

2006-01-27, 9:27 pm

Hello,

I am attempting to map an incoming xml message with a schema similar to the
following instance (in a restaurant context):

<checks>
<check>
<checknumber>1</checknumber>
<items>
<item>
<price>1.99</price>
<qty>1</qty>
<description>French Fries</description>
</item>
<item>
<price>4.99</price>
<qty>1</qty>
<description>Cheeseburger</description>
</item>
</items>
</check>
<check>
<checknumber>2</checknumber>
<items>
<item>
<price>0.99</price>
<qty>1</qty>
<description>Chips</description>
</item>
<item>
<price>4.99</price>
<qty>1</qty>
<description>Sandwich</description>
</item>
</items>
</check>
</checks>

I would like to end up with an XML file with the following structure:

<sales>
<sale description="French Fries" qty="1" price="1.99" checknumber="1" />
<sale description="Cheeseburger" qty="1" price="4.99" checknumber="1" />
<sale description="Chips" qty="1" price="0.99" checknumber="2" />
<sale description="Sandwich" qty="1" price="4.99" checknumber="2" />
</sales>

I have attempted to use the looping functoid on the <item> element and map
it to the <sales> element in the result, but I end up with every entry
having the same 'checknumber' attribute. i.e. Chips and Sandwich will have
an incorrect checknumber. I can't figure out how to make it loop through
both <checks> and <items> to produce the correct result.

Any help would be greatly appreciated.

Thanks,
Jeff Darlington
R7 Solutions


Pabba

2006-01-27, 9:27 pm

Hello Jeff,

1. Place a direct link (without looping functoid) from source <check>
node to target <sale> node
2. And use the looping functoid to link <item> and <sale> nodes and
3. Don't link/map anything to <sales> node

I tested this scenario and it worked.

Let me know if this helps.

Regards,
Kiran Pabba

Jeff Darlington

2006-01-27, 9:27 pm

Found the problem. It wasn't a problem with my map. It was farther up the
line before it even got here.

Jeff Darlington
R7 Solutions


"Jeff Darlington" <jdarlingtonR7@community.nospam> wrote in message
news:%23YXym9eIGHA.1124@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am attempting to map an incoming xml message with a schema similar to
> the following instance (in a restaurant context):
>
> <checks>
> <check>
> <checknumber>1</checknumber>
> <items>
> <item>
> <price>1.99</price>
> <qty>1</qty>
> <description>French Fries</description>
> </item>
> <item>
> <price>4.99</price>
> <qty>1</qty>
> <description>Cheeseburger</description>
> </item>
> </items>
> </check>
> <check>
> <checknumber>2</checknumber>
> <items>
> <item>
> <price>0.99</price>
> <qty>1</qty>
> <description>Chips</description>
> </item>
> <item>
> <price>4.99</price>
> <qty>1</qty>
> <description>Sandwich</description>
> </item>
> </items>
> </check>
> </checks>
>
> I would like to end up with an XML file with the following structure:
>
> <sales>
> <sale description="French Fries" qty="1" price="1.99" checknumber="1"
> />
> <sale description="Cheeseburger" qty="1" price="4.99" checknumber="1"
> />
> <sale description="Chips" qty="1" price="0.99" checknumber="2" />
> <sale description="Sandwich" qty="1" price="4.99" checknumber="2" />
> </sales>
>
> I have attempted to use the looping functoid on the <item> element and map
> it to the <sales> element in the result, but I end up with every entry
> having the same 'checknumber' attribute. i.e. Chips and Sandwich will
> have an incorrect checknumber. I can't figure out how to make it loop
> through both <checks> and <items> to produce the correct result.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Jeff Darlington
> R7 Solutions
>



WenJun Zhang[msft]

2006-01-27, 9:27 pm

Hi,

The key point here is the looping should be between item --> sale to
generate the <sale> records. Check number should be directly passed to the
destination structure.

Have a nice day!

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.

WenJun Zhang[msft]

2006-01-27, 9:27 pm

Hi,

The key point here is the looping should be between item --> sale to
generate the <sale> records. Check number should be directly passed to the
destination structure.

Have a nice day!

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com