Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
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
- BizTalk 2010 : WCF LOB SQL Adapter - Consuming ASDK SQL Adapter in Visual Studio (part 1)
- Microsoft Dynamics CRM 2011 : Using Advanced Find (part 1) - Performing Advanced Find Queries
- Microsoft Lync Server 2010 : Planning for Voice Deployment - Media Bypass
- Microsoft Dynamic GP 2010 : Providing clean vendor information by properly closing Purchase Orders, Protecting against information loss by printing Fixed Asset Reports
- Maintaining Desktop Health : Understanding Windows Error Reporting (part 1) - Error Reporting Cycle, Report Data Overview
- Windows Phone 8 : Designing for the Phone - Deciding on an Application Paradigm
- Using Micrsosft Outlook 2010 with SharePoint and OCS : Using the People Pane, Viewing Online Status
- Windows Server 2012 : Configuring IPv6/IPv4 interoperability (part 7) - ISATAP
- Microsoft PowerPoint 2010 : Creating New Slides (part 1) - Creating New Slides from the Outline Pane
- Adobe Fireworks CS5 : Adding a Flex skin
Top 10
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 3) - Creating IPv4 DHCP Scopes
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 2) - Installing DHCP Server and Server Tools
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 1)
- Windows Server 2012 : DHCP,IPv6 and IPAM - Understanding the Components of an Enterprise Network
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 3) - Translating Text with the Mini Translator
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 2) - Translating a Word or Phrase with the Research Pane
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 1) - Setting Options for the Research Task Pane, Searching with the Research Task Pane
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 2) - Ending a Linked Notes Session, Viewing Linked Notes
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 1) - Beginning a Linked Notes Session
- Microsoft OneNote 2010 : Doing Research with Side Notes (part 3) - Moving Side Notes to Your Existing Notes
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro