<Address> <xsl:value-of select="Address/text()" /> </Address>
<
Address
>
xsl:value-of
select
=
"Address/text()"
/>
</
<xsl:variable name="var:v1" select="userCSharp:LogicalExistence(boolean(ZipCode))" /> <xsl:if test="string($var:v1)='true'"> <xsl:variable name="var:v2" select="ZipCode/text()" /> <ZipCode> <xsl:value-of select="$var:v2" /> </ZipCode> </xsl:if>
xsl:variable
name
"var:v1"
"userCSharp:LogicalExistence(boolean(ZipCode))"
xsl:if
test
"string($var:v1)='true'"
"var:v2"
"ZipCode/text()"
ZipCode
"$var:v2"
<xsl:variable name="var:v3" select="userCSharp:StringConcat(string(LastName/text()) , ", " , string(FirstName/text()))" /> <FullName> <xsl:value-of select="$var:v3" /> </FullName>
"var:v3"
"userCSharp:StringConcat(string(LastName/text()) , ", " , string(FirstName/text()))"
FullName
"$var:v3"
<xsl:variable name="var:v4" select="userCSharp:CalculateMyAge(string(DateOfBirth/text()))" /> <Age> <xsl:value-of select="$var:v4" /> </Age>
"var:v4"
"userCSharp:CalculateMyAge(string(DateOfBirth/text()))"
Age
"$var:v4"
<PhoneBilling> <xsl:variable name="var:v5" select="userCSharp:InitCumulativeSum(0)" /> <xsl:for-each select="/s0:PersonOrigin/PhoneCalls"> <xsl:variable name="var:v6" select="userCSharp:StringLeft(string(@PhoneNumber) , "4")" /> <xsl:variable name="var:v7" select="userCSharp:LogicalEq(string($var:v6) , "+351")" /> <xsl:variable name="var:v8" select="userCSharp:LogicalNot(string($var:v7))" /> <xsl:if test="string($var:v8)='true'"> <xsl:variable name="var:v9" select="@Cost" /> <xsl:variable name="var:v10" select="userCSharp:AddToCumulativeSum(0,string($var:v9),"1000")" /> </xsl:if> </xsl:for-each> <xsl:variable name="var:v11" select="userCSharp:GetCumulativeSum(0)" /> <TotalInternational> <xsl:value-of select="$var:v11" /> </TotalInternational> <xsl:variable name="var:v12" select="userCSharp:InitCumulativeSum(1)" /> <xsl:for-each select="/s0:PersonOrigin/PhoneCalls"> <xsl:variable name="var:v13" select="string(@PhoneNumber)" /> <xsl:variable name="var:v14" select="userCSharp:StringLeft($var:v13 , "4")" /> <xsl:variable name="var:v15" select="userCSharp:LogicalEq(string($var:v14) , "+351")" /> <xsl:if test="string($var:v15)='true'"> <xsl:variable name="var:v16" select="@Cost" /> <xsl:variable name="var:v17" select="userCSharp:AddToCumulativeSum(1,string($var:v16),"1000")" /> </xsl:if> </xsl:for-each> <xsl:variable name="var:v18" select="userCSharp:GetCumulativeSum(1)" /> <TotalNational> <xsl:value-of select="$var:v18" /> </TotalNational> </PhoneBilling>
PhoneBilling
"var:v5"
"userCSharp:InitCumulativeSum(0)"
xsl:for-each
"/s0:PersonOrigin/PhoneCalls"
"var:v6"
"userCSharp:StringLeft(string(@PhoneNumber) , "4")"
"var:v7"
"userCSharp:LogicalEq(string($var:v6) , "+351")"
"var:v8"
"userCSharp:LogicalNot(string($var:v7))"
"string($var:v8)='true'"
"var:v9"
"@Cost"
"var:v10"
"userCSharp:AddToCumulativeSum(0,string($var:v9),"1000")"
"var:v11"
"userCSharp:GetCumulativeSum(0)"
TotalInternational
"$var:v11"
"var:v12"
"userCSharp:InitCumulativeSum(1)"
"var:v13"
"string(@PhoneNumber)"
"var:v14"
"userCSharp:StringLeft($var:v13 , "4")"
"var:v15"
"userCSharp:LogicalEq(string($var:v14) , "+351")"
"string($var:v15)='true'"
"var:v16"
"var:v17"
"userCSharp:AddToCumulativeSum(1,string($var:v16),"1000")"
"var:v18"
"userCSharp:GetCumulativeSum(1)"
TotalNational
"$var:v18"
The functoids require certain input parameters that can vary according to the functoid that we are using, in this case the order with which we associate the link is extremely important, a practical example is the Value Mapping Functoid.
If we change the order in which we associate the links on the same element in the destination schema we can also have an impact on the desired final result.
"Client"
Person
Name
"Name/text()"
Sex
"Sex/text()"
"Employee"
In brief, the mapping engine, process the rules by going through the destination schema from the beginning to the end, processing the links in the order that he finds and in case of multiple links in a particular element or functoid, they are processed in the order in which they were associated.
…
ns0:PeopleTarget
"userCSharp:LogicalEq(string(Sex/text()) , "
F")" />
"$var:v1"
xmlns:ns0
"http://HowMapsWorks.PeopleTarget"
>Elsa Ligia</
>F</
However there is one important exception to this rule of Link Sequence, especially when using custom scripts in recursive records or elements.
int myCounter = 0; public void IncrementCounter() { myCounter += 1; }
int
myCounter = 0;
public
void
IncrementCounter()
{
myCounter += 1;
}
public int ReturnCounter() { return myCounter; }
ReturnCounter()
return
myCounter;
We would expect that in the first cycle the result of the second script was the value "1", in the second cycle we obtained the value "2" and so on. However, if we test the map, we will see that the reality is different:
><
LineNumber
>0</
></
>1</
>2</
"userCSharp:ReturnCounter()"
"userCSharp:IncrementCounter()"
All source code used in this article is available on MSDN Code Gallery to download: BizTalk Server – Basics principles of Maps
With this article, as we explore some of the common mappings scenarios, trying to dismantle the options that the BizTalk Map engine has taken to fulfill with the original intent of the visual map.
I hope this kind of hacking can help you to understand the behavior and debugging techniques for this type of elementary problems.
Sandro Pereira DevScope | MVP & MCTS BizTalk Server 2010 http://sandroaspbiztalkblog.wordpress.com/ | @sandro_asp
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki
Read suggested related topics:
This article is also available in the following languages