Skip to content

Commit 06f46e3

Browse files
committed
TreatElementsAsRecords attribute of the mapsource element
1 parent 990c5fd commit 06f46e3

File tree

14 files changed

+294
-10
lines changed

14 files changed

+294
-10
lines changed

Testing-Deploying-and-Managing-BizTalk-Applications/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Testing is an important aspect of (BizTalk) application life cycle. Before a dev
55

66
A BizTalk developer has a couple of options when it comes to unit testing BizTalk artifacts. Testing of each can be done using a framework like BizUnit, or some of the other available tools offered through CodePlex, or Visual Studio. With BizTalk Server 2009 the unit test feature was introduced, which offered built-in developer support for testing schemas, maps and pipelines in Visual Studio.
77

8+
## BizTalk Server 2013: Using the Unit Testing Feature with Schemas and Maps
9+
Testing is an important aspect of (BizTalk) application life cycle. Before a developer deploys his solution he needs to be confident that it will perform, and do the task(s) it is intended to do. It is a developer responsibility that he creates a robust application. Therefore he needs to unit test his BizTalk application artifacts before he deploys them for further testing.
10+
11+
A BizTalk developer has a couple of options when it comes to unit testing BizTalk artifacts. Testing of each can be done using a framework like BizUnit, or some of the other available tools offered through CodePlex, or Visual Studio. With BizTalk Server 2009 the unit test feature was introduced, which offered built-in developer support for testing schemas, maps and pipelines in Visual Studio.
12+
13+
814
# About Me
915
**Sandro Pereira** | [DevScope](http://www.devscope.net/) | MVP & MCTS BizTalk Server 2010 | [https://blog.sandro-pereira.com/](https://blog.sandro-pereira.com/) | [@sandro_asp](https://twitter.com/sandro_asp)
1016

Working-with-Maps/README.md

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
# Working with Maps
22

3-
## Muenchian Grouping and Sorting in BizTalk Maps without losing Map functionalities
3+
## Mapping Patterns
4+
5+
### Muenchian Grouping and Sorting in BizTalk Maps without losing Map functionalities
46
Project explaining how to use Muenchian Method to handle grouping and sorting in BizTalk Maps without losing Map functionalities. The Muenchian Method is a method developed by Steve Muench for performing grouping and sorting functionalities in a more efficient way using keys.
57

6-
## How to create a Global Inline C# Function
8+
## Working with Functoids
9+
10+
### BizTalk Mapper: Built-in Functoids, Scripting Functoid and Custom Functoids
11+
One question that we always try to answer or explain is when to use the Built-in Functoids (or basic/standard Functoids), Scripting Functoids or when to developer Custom Functoids. Well there isn’t a correct answer to this question and we only can suggest some best practices for you to use.
12+
13+
You need to remember and learn that there’s never only a single way and there are no right or wrong way method to solve a mapping problem, we can find more effective ways (performances) than others or easiest ways to solve the problem, yet the output generated will be the same. Quite often, deciding which way is the best approach to use or have the right balance between the easier and effective way can be difficult and often the approach used depend on the expertise and personal choice of the developers or company guidelines
14+
15+
### How to create a Global Inline C# Function
716
The Scripting functoid enables you to use Inline Custom Script (C# .NET, JScript .NET, Visual Basic .NET, Extensible Stylesheet Language Transformations (XSLT) or XSLT Call Template) or call code from an external assembly at run time to perform operation otherwise not available
817

9-
## How To Reuse Scripting Functoids with Inline C#
18+
### How To Reuse Scripting Functoids with Inline C#
1019
Inline scripts are convenient for custom code that you are unlikely to use elsewhere in your application or other maps. In addition to being convenient for one-time scripts, inline scripts are also useful for declaring global variables for use among a number of scripts and to use
1120

12-
## How to create a custom If-Then-Else Functoid
21+
### How to create a custom If-Then-Else Functoid
1322
Sometimes I ask myself: Why is so hard to make a simple If-Then-Else Functoid, or even so painful to do an If-Then-Else operation, using BizTalk mapper?I don't mean to say that it is complicated, quite the opposite, is quite easy to make If…Then…Else statements using the Mapper.
1423

15-
## How to use Database Lookup Functoid
24+
### How to use Database Lookup Functoid
1625
We can use the Database Lookup functoid to extract information from a database and store it as a Microsoft® ActiveX® Data Objects (ADO) recordset. This functoid requires four input parameters in the following order:
1726
* Parameter 1: A value for which to search in the specified database, table, and column.
1827
* Parameter 2: The full connection string for the database with a provider, machine name, database and authentication (an ActiveX Data Objects .NET (ADO.NET) connection string)
@@ -23,16 +32,17 @@ The functoid is actually quite simple to use, however, the main problem that dev
2332

2433
in this sample we will address this issue and how can you handle.
2534

26-
## BizTalk Mapper: Omit XML Declaration (Grid Property) explained
35+
## Advance Properties
36+
37+
### BizTalk Mapper: Omit XML Declaration (Grid Property) explained
2738
The official documentation states that you should use the Omit XML Declaration property to specify whether the transformation output should include an XML declaration.
2839

2940
In this sample we will address and explain this property and when you should use it.
3041

31-
## BizTalk Mapper: Built-in Functoids, Scripting Functoid and Custom Functoids
32-
One question that we always try to answer or explain is when to use the Built-in Functoids (or basic/standard Functoids), Scripting Functoids or when to developer Custom Functoids. Well there isn’t a correct answer to this question and we only can suggest some best practices for you to use.
33-
34-
You need to remember and learn that there’s never only a single way and there are no right or wrong way method to solve a mapping problem, we can find more effective ways (performances) than others or easiest ways to solve the problem, yet the output generated will be the same. Quite often, deciding which way is the best approach to use or have the right balance between the easier and effective way can be difficult and often the approach used depend on the expertise and personal choice of the developers or company guidelines
42+
### BizTalk Mapper: TreatElementsAsRecords attribute of the mapsource element
43+
This is probably one of the most undocumented attributes, and the most difficult to explain and understand, present in the BizTalk Mapper. The official documentation states that when you use a Looping functoid, a Conditional functoid, or a Value Mapping functoid, an <xsl:for-each> statement is generated in the compiled map. If the child field of the destination schema has unbounded maximum occurrences, the <xsl:for-each> statement is put at the child field. If the child field does not have unbounded maximum occurrences, the <xsl:for-each> statement is put at the parent field of the child field.
3544

45+
In this sample we will address and explain this property and when you should use it.
3646

3747
# About Me
3848
**Sandro Pereira** | [DevScope](http://www.devscope.net/) | MVP & MCTS BizTalk Server 2010 | [https://blog.sandro-pereira.com/](https://blog.sandro-pereira.com/) | [@sandro_asp](https://twitter.com/sandro_asp)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# BizTalk Mapper: TreatElementsAsRecords attribute of the mapsource element
2+
3+
# Introduction
4+
This is probably one of the most undocumented attributes, and the most difficult to explain and understand, present in the BizTalk Mapper. The official documentation states that when you use a Looping functoid, a Conditional functoid, or a Value Mapping functoid, an <xsl:for-each> statement is generated in the compiled map. If the child field of the destination schema has unbounded maximum occurrences, the <xsl:for-each> statement is put at the child field. If the child field does not have unbounded maximum occurrences, the <xsl:for-each> statement is put at the parent field of the child field.
5+
6+
However, because the location of the <xsl:for-each> statement affects the map result, you may want the <xsl:for-each> statement to be put at the child field of the destination schema, regardless of whether the maximum occurrence of the child field is set to 1.
7+
8+
You can control the placement of the <xsl:for-each> statement by modifying the value of the TreatElementsAsRecords attribute in the map (.btm) file.
9+
10+
When this attribute is set to **Yes**, the <xsl:for-each> statement is put at the child field of the destination schema, regardless of whether the maximum occurrence of the child field is set to **1**.
11+
12+
![TreatElementsAsRecords attribute](media/BizTalk-Mapper-TreatElementsAsRecords-attribute.png)
13+
14+
With the TreatElementsAsRecords attribute set to **No** will generate a valid output as we can see:
15+
16+
17+
<Parent>
18+
<Child>RChild_1</Child>
19+
</Parent>
20+
<Parent>
21+
<Child>RChild_2</Child>
22+
</Parent>
23+
<Parent>
24+
<Child>RChild_3</Child>
25+
</Parent>
26+
27+
28+
However if we set the TreatElementsAsRecords attribute as **Yes** it will generate multiple child elements, which will translate to an invalid message:
29+
30+
31+
<Parent>
32+
<Child>RChild_1</Child>
33+
<Child>RChild_2</Child>
34+
<Child>RChild_3</Child>
35+
</Parent>
36+
37+
38+
# Read more about it
39+
You can read more about this topic here: [BizTalk Mapping Patterns and Best Practices book [Free] released](https://blog.sandro-pereira.com/2014/09/28/biztalk-mapping-patterns-and-best-practices-book-free-released/)
40+
41+
# About Me
42+
**Sandro Pereira** | [DevScope](http://www.devscope.net/) | MVP & MCTS BizTalk Server 2010 | [https://blog.sandro-pereira.com/](https://blog.sandro-pereira.com/) | [@sandro_asp](https://twitter.com/sandro_asp)
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreatElementsAsRecords", "TreatElementsAsRecords\TreatElementsAsRecords.btproj", "{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
15+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}.Release|Any CPU.Deploy.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Microsoft.XLANGs.BaseTypes;
5+
using Microsoft.BizTalk.XLANGs.BTXEngine;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("TreatElementsAsRecords")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("TreatElementsAsRecords")]
15+
[assembly: AssemblyCopyright("Copyright © 2014")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
[assembly: Microsoft.XLANGs.BaseTypes.BizTalkAssemblyAttribute(typeof(BTXService))]
19+
20+
// Setting ComVisible to false makes the types in this assembly not visible
21+
// to COM components. If you need to access a type in this assembly from
22+
// COM, set the ComVisible attribute to true on that type.
23+
[assembly: ComVisible(false)]
24+
25+
// The following GUID is for the ID of the typelib if this project is exposed to COM
26+
[assembly: Guid("037424f9-387d-48c3-8e4d-7ae9a6c79733")]
27+
28+
// Version information for an assembly consists of the following four values:
29+
//
30+
// Major Version
31+
// Minor Version
32+
// Build Number
33+
// Revision
34+
//
35+
// You can specify all the values or you can default the Build and Revision Numbers
36+
// by using the '*' as shown below:
37+
// [assembly: AssemblyVersion("1.0.*")]
38+
[assembly: AssemblyVersion("1.0.0.0")]
39+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<SchemaVersion>2.0</SchemaVersion>
7+
<ProjectGuid>{AED20ADF-E6E6-4B8A-AEBF-FA4EBEF2F7C8}</ProjectGuid>
8+
<ProjectTypeGuids>{EF7E3281-CD33-11D4-8326-00C04FA0CE8D};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
9+
<OutputType>library</OutputType>
10+
<GenericProcessing>true</GenericProcessing>
11+
<RootNamespace>TreatElementsAsRecords</RootNamespace>
12+
<AssemblyName>TreatElementsAsRecords</AssemblyName>
13+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14+
<BpelCompliance>True</BpelCompliance>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System">
37+
<Name>System</Name>
38+
</Reference>
39+
<Reference Include="System.Xml">
40+
<Name>System.XML</Name>
41+
</Reference>
42+
<Reference Include="System.Configuration">
43+
<Name>System.Configuration</Name>
44+
</Reference>
45+
<Reference Include="Microsoft.BizTalk.Pipeline">
46+
<SpecificVersion>False</SpecificVersion>
47+
</Reference>
48+
<Reference Include="Microsoft.BizTalk.DefaultPipelines">
49+
<Name>Microsoft.BizTalk.DefaultPipelines</Name>
50+
</Reference>
51+
<Reference Include="Microsoft.BizTalk.GlobalPropertySchemas">
52+
<Name>Microsoft.BizTalk.GlobalPropertySchemas</Name>
53+
</Reference>
54+
<Reference Include="Microsoft.BizTalk.TestTools">
55+
<Name>Microsoft.BizTalk.TestTools</Name>
56+
</Reference>
57+
<Reference Include="Microsoft.XLANGs.BaseTypes">
58+
<Name>Microsoft.XLANGs.BaseTypes</Name>
59+
</Reference>
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="Properties\AssemblyInfo.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<Schema Include="Input.xsd">
66+
<TypeName>Input</TypeName>
67+
<Namespace>TreatElementsAsRecords</Namespace>
68+
<SubType>Task</SubType>
69+
</Schema>
70+
</ItemGroup>
71+
<ItemGroup>
72+
<Schema Include="Output.xsd">
73+
<TypeName>Output</TypeName>
74+
<Namespace>TreatElementsAsRecords</Namespace>
75+
<SubType>Task</SubType>
76+
</Schema>
77+
</ItemGroup>
78+
<ItemGroup>
79+
<Map Include="TreatElementsAsRecordsMap.btm">
80+
<TypeName>TreatElementsAsRecordsMap</TypeName>
81+
<Namespace>TreatElementsAsRecords</Namespace>
82+
<SubType>Designer</SubType>
83+
</Map>
84+
</ItemGroup>
85+
<ItemGroup>
86+
<Map Include="TreatElementsAsRecordsMapYes.btm">
87+
<TypeName>TreatElementsAsRecordsMapYes</TypeName>
88+
<Namespace>TreatElementsAsRecords</Namespace>
89+
<SubType>Designer</SubType>
90+
</Map>
91+
</ItemGroup>
92+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
93+
<Import Project="$(MSBuildExtensionsPath)\Microsoft\BizTalk\BizTalkC.targets" />
94+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ProjectView>ProjectFiles</ProjectView>
5+
</PropertyGroup>
6+
<ProjectExtensions>
7+
<VisualStudio>
8+
<FlavorProperties GUID="{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}">
9+
<Files>
10+
<File Path="Input.xsd">
11+
<ValidateTestMapInput>True</ValidateTestMapInput>
12+
<ValidateTestMapOutput>True</ValidateTestMapOutput>
13+
<TestMapInputInstanceFilename></TestMapInputInstanceFilename>
14+
<TestMapOutputInstanceFilename></TestMapOutputInstanceFilename>
15+
<TestMapSourceType>0</TestMapSourceType>
16+
<TestMapTargetType>0</TestMapTargetType>
17+
<EditorOutputInstanceFilename></EditorOutputInstanceFilename>
18+
<EditorInputInstanceFilename></EditorInputInstanceFilename>
19+
<GenerateInstanceOutputType>0</GenerateInstanceOutputType>
20+
<ValidateInstanceInputType>0</ValidateInstanceInputType>
21+
<PropertySchemaFileName>PropertySchema.xsd</PropertySchemaFileName>
22+
<AutoRefreshSchema>0</AutoRefreshSchema>
23+
</File>
24+
<File Path="Output.xsd">
25+
<ValidateTestMapInput>True</ValidateTestMapInput>
26+
<ValidateTestMapOutput>True</ValidateTestMapOutput>
27+
<TestMapInputInstanceFilename></TestMapInputInstanceFilename>
28+
<TestMapOutputInstanceFilename></TestMapOutputInstanceFilename>
29+
<TestMapSourceType>0</TestMapSourceType>
30+
<TestMapTargetType>0</TestMapTargetType>
31+
<EditorOutputInstanceFilename></EditorOutputInstanceFilename>
32+
<EditorInputInstanceFilename></EditorInputInstanceFilename>
33+
<GenerateInstanceOutputType>0</GenerateInstanceOutputType>
34+
<ValidateInstanceInputType>0</ValidateInstanceInputType>
35+
<PropertySchemaFileName>PropertySchema.xsd</PropertySchemaFileName>
36+
<AutoRefreshSchema>0</AutoRefreshSchema>
37+
</File>
38+
<File Path="TreatElementsAsRecordsMap.btm">
39+
<ValidateTestMapInput>True</ValidateTestMapInput>
40+
<ValidateTestMapOutput>True</ValidateTestMapOutput>
41+
<TestMapInputInstanceFilename>C:\Development\TreatElementsAsRecords\Files\Input_output.xml</TestMapInputInstanceFilename>
42+
<TestMapOutputInstanceFilename></TestMapOutputInstanceFilename>
43+
<TestMapSourceType>1</TestMapSourceType>
44+
<TestMapTargetType>0</TestMapTargetType>
45+
<EditorOutputInstanceFilename></EditorOutputInstanceFilename>
46+
<EditorInputInstanceFilename></EditorInputInstanceFilename>
47+
<GenerateInstanceOutputType>0</GenerateInstanceOutputType>
48+
<ValidateInstanceInputType>0</ValidateInstanceInputType>
49+
<PropertySchemaFileName>PropertySchema.xsd</PropertySchemaFileName>
50+
<AutoRefreshSchema>0</AutoRefreshSchema>
51+
</File>
52+
<File Path="TreatElementsAsRecordsMapYes.btm">
53+
<ValidateTestMapInput>True</ValidateTestMapInput>
54+
<ValidateTestMapOutput>True</ValidateTestMapOutput>
55+
<TestMapInputInstanceFilename>C:\Development\TreatElementsAsRecords\Files\Input_output.xml</TestMapInputInstanceFilename>
56+
<TestMapOutputInstanceFilename></TestMapOutputInstanceFilename>
57+
<TestMapSourceType>1</TestMapSourceType>
58+
<TestMapTargetType>0</TestMapTargetType>
59+
<EditorOutputInstanceFilename></EditorOutputInstanceFilename>
60+
<EditorInputInstanceFilename></EditorInputInstanceFilename>
61+
<GenerateInstanceOutputType>0</GenerateInstanceOutputType>
62+
<ValidateInstanceInputType>0</ValidateInstanceInputType>
63+
<PropertySchemaFileName>PropertySchema.xsd</PropertySchemaFileName>
64+
<AutoRefreshSchema>0</AutoRefreshSchema>
65+
</File>
66+
</Files>
67+
</FlavorProperties>
68+
</VisualStudio>
69+
</ProjectExtensions>
70+
</Project>

0 commit comments

Comments
 (0)