0

I have a source schema with less elements than the destination schema. When I run the map only mapped elements in destination schema shows up. I want all the elements in destination schema to show up, even they are empty. How to do this?

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
g_eduard
  • 79
  • 1
  • 1
  • 8

2 Answers2

1

Set the "Default Value" of the output schema. This will create empty nodes.

Marvin Smit
  • 4,088
  • 1
  • 22
  • 21
  • Sorry for late answer, but there is no Default Value for schema! When I go into into output schema (xsd file) and then select "schema", there is no such property for the whole schema. – g_eduard Jul 14 '13 at 22:37
  • There's a 'default value' option in the BizTalk mapper. Select the target node, goto properties and find 'default value'. – Marvin Smit Sep 15 '13 at 11:56
0

The most convenient way is to use Inline C# Scripting functoid for this.

Scripting functoid:

public string GetEmptyString()
{
    return System.String.Empty;
}

You can just link this functoid to all output nodes where you wish to see empty node.

Example:

Input schema:

<xs:schema xmlns="http://person" targetNamespace="http://person" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Person">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name" type="xs:string" />
                <xs:element name="Surname" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Output schema:

<xs:schema xmlns="http://employee" 
           targetNamespace="http://employee" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Employee">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="FirstName" type="xs:string" />
        <xs:element name="MidName" type="xs:string" />
        <xs:element name="LastName" type="xs:string" />
        <xs:element name="Age" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Input message:

<ns0:Person xmlns:ns0="http://person">
  <Name>John</Name>
  <Surname>Snow</Surname>
</ns0:Person>

Expected output message:

<ns0:Employee xmlns:ns0="http://employee">
  <FirstName>John</FirstName> 
  <MidName /> 
  <LastName>Snow</LastName> 
  <Age /> 
</ns0:Employee>

Solution:

  • Link Person.Name to Employee.FirstName
  • Link Person.Surname to Employee.LastName
  • Create Scripting functoid that returns empty string
  • Link Scripting functoid to Employee.MidName
  • Link Scripting functoid to Employee.Age
kletnoe
  • 397
  • 3
  • 18