Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows Server

BizTalk 2010 Recipes : Document Mapping - Mapping Any Element Nodes

3/27/2011 8:40:02 PM

1. Problem

You need to create a mapping between two schemas containing elements and attributes that are unknown when building the map, and you must include the unknown schema structures in your mapping.

2. Solution

You can include unknown schema structures in a map by using the <Any> element.

  1. Build a source message schema containing an <Any> element. This can be done by right-clicking the record in the schema and selecting Insert Schema Node => Any Element, as shown in Figure 1.

    Figure 1. Creating a source message with an Any element
  2. Build a destination schema containing an <Any> element, as shown in Figure 2.

    Figure 2. Creating a destination message
  3. Add a new map to the solution. Set the source and target schemas appropriately.

  4. Click the Toolbox, and then click the Advanced Functoids tab. Drag a Mass Copy functoid onto the map surface. Connect the Address element from the source message to the Mass Copy functoid, and connect the Mass Copy functoid to the Address field of the destination message.

  5. Create other desired mapping links normally, as shown in Figure 3.

    Figure 3. Configuring the Mass Copy functoid

3. How It Works

An <Any> element in a schema designates a specific location in the schema where new elements or attributes can be added. When BizTalk uses the schema to process a message containing unknown elements or attributes in the designated location, the schema will still consider the message valid. If this source message is mapped into a different schema that also has a location designated for extensibility with an <Any> element, then the information must be copied to that location with the Mass Copy functoid.

NOTE

By default, BizTalk will examine only the namespace and root node name of a message to identify the schema, and will not detect extra elements in the message body. To perform a deep validation of a message format, create a receive pipeline with the XML disassembler, specify the schema to validate messages against, and set Validate Document Structure to true. 

The contents of an <Any> element cannot be mapped with most of the default BizTalk functoids. Other functoids require establishing an explicit link from a source field, and that is not possible if the source field is not known at design time. The Mass Copy functoid can be linked only directly to an ancestor of the <Any> element, which may not give the granularity of control desired. Consider using an XSLT script with the Scripting functoid to achieve finer control. For example, if you know some element will be present at runtime but cannot predict the element name of its parent, an XSLT script can still perform the mapping.

Note that you can override the mapping of the mass copy on a line by line basis. For instance, if the Zip field needs to be mapped differently, simply add the appropriate functoid(s) and map it; this will override whatever the Mass Copy functoid has created (see Figure 4).

Figure 4. Overriding AddrLine2 within a Mass Copy functoid

Sometimes, the BizTalk development environment has difficulty validating schemas containing <Any> elements. It can incorrectly determine that elements and attributes appearing in the location designated by the schema should not be there, causing validation for the schema to fail. This complicates schema development because the developer must deploy the schema with a pipeline capable of validating the document structure to check if the schema is correct according to a sample source message. To avoid this deployment effort while developing the schema, wait to add <Any> elements until the rest of the schema is developed and verify that those other elements are defined correctly. Then, when adding the <Any> elements to the schema, there will be a baseline of what is working correctly.

The Mass Copy functoid allows source records and containing elements and attributes to be copied and mapped across to the destination schema. This in turn, allows large structures to be mapped quickly in design time, without the need of performing 1:1 detailed mapping on all subsequent schema nodes. The Mass Copy functoid performs the recursive copying by applying a wildcard (/*) XSLT template match on source to destination XML elements. This is of particular benefit when the destination is defined as an <xs:any> type.

When mapping from source to destination, only the structure under the destination parent XML record will be copied. This often results in having to re-create the parent record element to allow all subsequent children nodes to be mapped to the destination schema. For example, consider the following two schemas, CustomerCustomers: and

<Customer>
<Name> </Name>
<AccountID> </AccountId>
<DOB> </DOB>
</Customer>


<Customers>
<Customer>
<Name> </Name>
<AccountID> </AccountId>
<DOB> </DOB>
</Customer>
</Customers>

In this instance, the <Customers> record cannot be mapped to the <Customer> record on the destination schema. A containing element <Customer> will need to be defined on the destination schema to enable the correct operation of the Mass Copy functoid mapping.

When mapping source to destination elements, always be cautious of underlying XSD schema rules, such as cardinality, order, and data types. For example, the Mass Copy functoid will "blindly" copy all child elements specified to the destination schema. It will not copy elements out of order or check for required values in the destination schema.

Changes to the source and destination schema may result in the need to update your impacted maps leveraging the Mass Copy functoid. This, in turn, will mandate a recompile and deployment of your BizTalk solution.

Using the Mass Copy functoid within the BizTalk Mapper is one of a variety of ways to recursively copy elements. The following are three key approaches to recursively copy XML structures:

Mass Copy functoid: Creates a wildcard XSLT template match to recursively copy elements. This approach may provide a performance benefit, as each source and destination element does not require a 1:1: XSLT template match. This, in turn, requires fewer XSLT code instructions to be interpreted and executed at runtime.

Recursive mapping: This is achieved by holding down the Shift key and mapping from a source to destination record element. This is a usability design feature that enables a developer to perform recursive mapping via one keystroke. This approach implements 1:1 XSLT template matches on all source and destination elements.

Straight-through mapping: This approach is to manually link all source and associated destination elements within the BizTalk Mapper tool. This method does 1:1 template matches on all source and destination elements.
Other -----------------
- BizTalk 2010 Recipes : Document Mapping - Adding and Configuring Mapping Constants
- Windows Server 2003 : Troubleshooting Server Services (part 2) - Using Service Recovery Options to Diagnose and Resolve Service-Related Issues
- Windows Server 2003 : Troubleshooting Server Services (part 1) - Diagnosing and Resolving Issues Related to Service Dependency
- Windows Server 2008 Server Core : Virus and External Intrusion Protection (part 4) - Configuring Local Security Policies with the SecEdit Utility
- Windows Server 2008 Server Core : Virus and External Intrusion Protection (part 3) - Verifying Drivers with the Verifier Utility
- Windows Server 2008 Server Core : Virus and External Intrusion Protection (part 2) - Verifying System Files with the SFC Utility
- Windows Server 2008 Server Core : Virus and External Intrusion Protection (part 1)
- Windows Server 2008 Server Core : Managing System Users - Discovering User Identity with the WhoAmI Utility
- Exchange Server 2010 : Installing a Windows Certification Authority Server
- Exchange Server 2010 : Understanding Public Key Infrastructure (part 2) - Manual Encrypted Communications Using Outlook
- Exchange Server 2010 : Understanding Public Key Infrastructure (part 1)
- BizTalk 2010 Recipes : Document Mapping - Organizing Maps
- BizTalk 2010 Recipes : Document Mapping - Creating Simple Maps
- BizTalk 2010 Recipes : Creating SOAP Header Schemas
- Windows Server 2008 R2 : Managing Active Directory with Policies (part 5)
- Windows Server 2008 R2 : Managing Active Directory with Policies (part 4) - Deploying Software Packages Using Domain Group Policy Objects
- Windows Server 2008 R2 : Managing Active Directory with Policies (part 3) - Extending Group Policy Functionality
- Windows Server 2008 R2 : Managing Active Directory with Policies (part 2) - Configuring Restricted Groups for Domain Security Groups
- Windows Server 2008 R2 : Managing Active Directory with Policies (part 1) - Fine-Grained Password Policies
- Windows Server 2008 R2 : Managing Users with Policies
 
 
Most view of day
- Windows Server 2008 R2 file and print services : Administering Print and Document Services (part 2) - Distributed scan server
- Sharepoint 2013 : Backup and Restore (part 6) - Farm Backup and Restore - Performing a Restore, Using PowerShell
- SharePoint 2010 : Farm Governance - Restricting web part access in the farm
- Nginx HTTP Server : Basic Nginx Configuration - Base module directives
- Microsoft Dynamics CRM 2011 : Using Advanced Find (part 4) - Using Advanced Filter Criteria
- Windows Server 2012 Requirements and Installation : Installing Server 2012 (part 1) - Server Core Install
- Microsoft Visio 2010 : Working with Individual Shapes - Resizing and Rotating Shapes
- Microsoft Lync Server 2010 : Planning for Voice Deployment - Media Bypass
- Sharepoint 2013 : Managing Security - See What Permissions Are Set (part 2) - Read the Permissions Page, Check the Permissions for a Specific User or Group
- Microsoft Systems Management Server 2003 : Configuring Software Metering (part 2) - Creating a Software Metering Rule
Top 10
- Microsoft Project 2010 : Linking Tasks (part 8) - Auditing Task Links,Using the Task Inspector
- Microsoft Project 2010 : Linking Tasks (part 7) - Creating Links by Using the Mouse,Working with Automatic Linking Options
- Microsoft Project 2010 : Linking Tasks (part 6) - Creating Links by Using the Entry Table
- Microsoft Project 2010 : Linking Tasks (part 5) - Creating Links by Using the Task Information Dialog Box
- Microsoft Project 2010 : Linking Tasks (part 4) - Entering Leads and Lags, Creating Links by Using the Menu or Toolbar
- Microsoft Project 2010 : Linking Tasks (part 3) - Using the Start-to-Start Relationship,Using the Finish-to-Finish Relationship
- Microsoft Project 2010 : Linking Tasks (part 2) - Using the Start-to-Start Relationship,Using the Finish-to-Finish Relationship
- Microsoft Project 2010 : Linking Tasks (part 1) - Defining Dependency Links
- Microsoft Project 2010 : Defining Task Logic - Manipulating Your Schedule
- Microsoft Lync Server 2013 : Director Troubleshooting (part 3) - Synthetic Transactions,Telnet
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro