Transformations in BizTalk Mapper

Defining models for the data you will be working with is a huge step toward implementing your integration, but it's only the first piece. Because you might need to support different models and structures that come from partners, customers, and so forth, you will want to map their models to your internally supported ones. The BizTalk Mapper, shown in Figure 15-3, is used for this task. It allows you to import two specifications and draw the necessary lines between them to map from one to the other. The result is an XSLT style sheet that can be used by the server during processing.

Figure 15-3 The BizTalk Mapper.

Now launch BizTalk Mapper and we will step through mapping the partner.xml schema to our support.xml schema to show you how the application works. Once it's open start a new mapping (from the File menu). When the Select Source Specification Type dialog appears, click the Local Files option and browse to the partner.xml file. Once you have it selected you will see the Select Destination Specification Type dialog. Follow the same steps and select the support.xml specification.

Instead of starting at the top and addressing the "name" formatting problem, let's take care of the <phone>, <email>, and <issue> mappings. To map these elements in the partner.xml specification to the support.xml specification, simply drag one to the corresponding other. Figure 15-4 shows us mapping the <issue> elements together after we have already mapped the <phone> and <email> elements.

Figure 15-4 Mapping elements by dragging from one side to the other.

Figure 15-5 Our completed mapping between the partner.xml and support.xml specifications.

To handle the mapping for the customer name we are going to use a functoid to concatenate the <first> and <last> elements together into a single <name>. To apply a functoid you need to open the Functoid Palette from the View menu. When the palette opens you will notice it is already populated with items for basic String, Mathematical, Logical, Date/Time, Conversion, Scientific, Cumulative, Database, and Advanced operations. This option can be extremely powerful because it allows you to, for instance, combine or simply use the results of functions like a database query in your mapping.

For our example you will need to drag the Concatenate String operator to your workspace. Once you have it placed you can draw a line from the <first> element to this functoid and then a line from the <last> element to it. Finally you can connect the functoid to the <name> element on our support.xml destination specification. Once complete, the results, which can be seen in Figure 15-5, are stored in an XML file we will call mapping.xml (Listing 15-5). As you can see, it contains all the information about the specifications, their mapping, even the script needed to perform the functoid Concatenate operation.

Listing 15-5 mapping.xml: Result of mapping our partner.xml specification to our support.xml specification.

 <?xml version="1.0"?> <!-- Generated using BizTalk Mapper on Thu, Aug 02 2001 11:24:20 PM --> <!-- Microsoft Corporation (c) 2000 (http://www.microsoft.com) --> <mapsource name="mapping"   BizTalkServerMapperTool_Version="1.0"   version="1"   xrange="100"   yrange="420"> <srctree> <Schema name="support"  b:BizTalkServerEditorTool_Version="1.0"  b:root_reference="support"  b:standard="XML"  xmlns="urn:schemas-microsoft-com:xml-data"  xmlns:b="urn:schemas-microsoft-com:BizTalkServer"  xmlns:d="urn:schemas-microsoft-com:datatypes"> <b:SelectionFields/> <ElementType name="support" content="eltOnly" model="closed"> <b:RecordInfo/> <element type="name" maxOccurs="*" minOccurs="0"/> <element type="phone" maxOccurs="*" minOccurs="0"/> <element type="email" maxOccurs="*" minOccurs="0"/> <element type="issue" maxOccurs="*" minOccurs="0"/> </ElementType> <ElementType name="phone" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="name" content="eltOnly" model="closed"> <b:RecordInfo/> <element type="first" maxOccurs="*" minOccurs="0"/> <element type="last" maxOccurs="*" minOccurs="0"/> </ElementType> <ElementType name="last" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="issue" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="first" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="email" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> </Schema> </srctree> <Values> <TestValues/> <ConstantValues/> </Values> <sinktree> <Schema name="support"  b:BizTalkServerEditorTool_Version="1.0"  b:root_reference="support"  b:standard="XML"  xmlns="urn:schemas-microsoft-com:xml-data"  xmlns:b="urn:schemas-microsoft-com:BizTalkServer"  xmlns:d="urn:schemas-microsoft-com:datatypes"> <b:SelectionFields/> <ElementType name="support" content="eltOnly" model="closed"> <b:RecordInfo/> <element type="name" maxOccurs="*" minOccurs="0"/> <element type="phone" maxOccurs="*" minOccurs="0"/> <element type="email" maxOccurs="*" minOccurs="0"/> <element type="issue" maxOccurs="*" minOccurs="0"/> </ElementType> <ElementType name="phone" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="name" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="issue" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> <ElementType name="email" content="textOnly" model="closed"> <b:FieldInfo/> </ElementType> </Schema> </sinktree> <links> <link link linkfrom="1" linkto="/support/name"/> <link link linkfrom="/support/name/last" linkto="1"/> <link link linkfrom="/support/name/first" linkto="1"/> <link link linkfrom="/support/issue" linkto="/support/issue"/> <link link linkfrom="/support/email" linkto="/support/email"/> <link link linkfrom="/support/phone" linkto="/support/phone"/> </links> <functions> <function function xcell="56" ycell="212" funcfunc 
funcversion="1" isscripter="no"> <inputparams> <param type="link" value="3"/> <param type="link" value="2"/> </inputparams> </function> </functions> <CompiledXSL> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="urn:var" xmlns:user="urn:user" exclude-result-prefixes="msxsl var user" version="1.0"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:apply-templates select="support"/> </xsl:template> <xsl:template match="support"> <support> <xsl:variable name="var:v1" select="user:fctstringconcat2(string(name/first/text()),string(name/last/text()))"/> <name> <xsl:value-of select="$var:v1"/> </name> <!-- Connection from source node "phone" to destination node "phone" --> <phone> <xsl:value-of select="phone/text()"/> </phone> <!-- Connection from source node "email" to destination node "email" --> <email> <xsl:value-of select="email/text()"/> </email> <!-- Connection from source node "issue" to destination node "issue" --> <issue> <xsl:value-of select="issue/text()"/> </issue> </support> </xsl:template> <msxsl:script language="VBScript" implements-prefix="user"> <![CDATA[ Function FctStringConcat2( p_strParm0, p_strParm1 ) FctStringConcat2 = p_strParm0 + p_strParm1 End Function ]]> </msxsl:script> </xsl:stylesheet> </CompiledXSL> </mapsource>

The BizTalk Mapper can be an extremely useful and time-saving application when it comes to supporting new document formats in any BizTalk system you might be building. Be sure to check out the Help files for more information on the many features it offers.



XML Programming
XML Programming Bible
ISBN: 0764538292
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net