Geeks With Blogs

Rui Machado Technologies and Information Systems

BizTalk Server 2010 Mapping Challenge

Many to One Looping

Imagine that you have a scenario where in the source schema you have a structure with three records with the same elements, however the first record is unbounded while the sencond and the third one as only one occurance. Now you need to map this three records into one single record in the destination schema.

Example:

Source Schema Records:
- Vendor (Unbounded)
- Client (Occurs once)
- Owner (Occurs once)

Destination Schema:
- Participants (unbounded)

Check out my two solutions for this challenge bellow.

Here is the XSLT Code:

01<Common>
02<ID>
03    <xsl:value-of select="//Personal/ID"/>
04</ID>
05 
06<xsl:for-each select="Personal">
07<!-- Process each vendor -->
08<xsl:for-each select="Vendor">
09    <xsl:variable name="fname" select="FName"/>
10    <xsl:variable name="lname" select="LName"/>
11    <xsl:variable name="addre" select="Address"/>
12    <xsl:variable name="city" select="City"/>
13 
14    <Participant>
15        <FName>
16            <xsl:value-of select="$fname"/>
17        </FName>
18        <LName>
19            <xsl:value-of select="$lname"/>
20        </LName>
21        <Address>
22            <xsl:value-of select="$addre"/>
23        </Address>
24        <City>
25            <xsl:value-of select="$city"/>
26        </City>
27    </Participant>
28</xsl:for-each>
29<!-- Process the client-->
30<Participant>
31    <FName>
32        <xsl:value-of select="Customer/FName"/>
33    </FName>
34    <LName>
35        <xsl:value-of select="Customer/LName"/>
36    </LName>
37    <Address>
38        <xsl:value-of select="Customer/Address"/>
39    </Address>
40    <City>
41        <xsl:value-of select="Customer/City"/>
42    </City>
43</Participant>
44<!-- Process the owner -->
45<Participant>
46    <FName>
47        <xsl:value-of select="Owner/FName"/>
48    </FName>
49    <LName>
50        <xsl:value-of select="Owner/LName"/>
51    </LName>
52    <Address>
53        <xsl:value-of select="Owner/Address"/>
54    </Address>
55    <City>
56        <xsl:value-of select="Owner/City"/>
57    </City>
58</Participant>
59</xsl:for-each>
60</Common>
Posted on Thursday, October 4, 2012 4:51 AM BizTalk | Back to top


Comments on this post: BizTalk Mapping Challenge – Many To One Looping

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © ruimachado | Powered by: GeeksWithBlogs.net | Join free