我有一个源模式,其元素少于目标模式。当我运行地图时,只显示目标模式中的映射元素。我希望目标模式中的所有元素都显示出来,即使它们是空的。怎么做?
答案 0 :(得分:1)
设置"默认值"输出模式。这将创建空节点。
答案 1 :(得分:0)
最方便的方法是使用Inline C#Scripting functoid。
脚本functoid:
public string GetEmptyString()
{
return System.String.Empty;
}
您可以将此functoid链接到您希望看到空节点的所有输出节点。
示例:强>
输入架构:
<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>
输出架构:
<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>
输入讯息:
<ns0:Person xmlns:ns0="http://person">
<Name>John</Name>
<Surname>Snow</Surname>
</ns0:Person>
预期输出消息:
<ns0:Employee xmlns:ns0="http://employee">
<FirstName>John</FirstName>
<MidName />
<LastName>Snow</LastName>
<Age />
</ns0:Employee>
解决方案: