Few days ago, I had this problem: I want to map a source schema to a destination schema, wich one of his elements has a fixed attribute (an attribute with a value in Fixed property). This element hadn't any input value and had minOccurs=0, but the mapper generates it. Here is an example:
- Source Schema
- Destination Schema
- Map
- XML Result
<ns0:Root xmlns:ns0="http://MappingError.DestinationSchema" />
<element1>
<field11>element1_0</field11>
<field12>element2_0</field12>
</element1>
<element2 fixedattribute="FixedValue"/>
<element3>
<field31>element3_0</field31>
</element3>
</ns0:root>
One solution is set for this element, an constant input value false, but my problem was that I had a lot elements with fixed attributes that mustn't be generated.
A solution for this is edit the map with notepad (because we can't edit in Visual Studio Properties Window) and set GenerateDefaultFixedNodes property to "No" (default is "Yes").
If we set this property to "No" the result XML is the correct:
<ns0:Root xmlns:ns0="http://MappingError.DestinationSchema" />
<element1>
<field11>element1_0</field11>
<field12>element2_0</field12>
</element1>
<element3>
<field31>element3_0</field31>
</element3>
</ns0:root>
1 comment:
This is the right solution that I searched for.
Thanks
Post a Comment