views:

233

answers:

4

I have this data (all the elements are optional):

<data>
<optionalElement1>...</optionalElement1>
<optionalElement2>...</optionalElement2>
<optionalElement3>...</optionalElement3>
</data>

I need to map this to another schema (all the elements are required):

<request> 
<Element1>...</Element1>
<Element2>...</Element2>
<Element3>...</Element3>
</request>

Since the elements in the original request are optional, the mapping will only generate the corresponding elements for the originally included elements. But the validation of the request will fail.

Example:

<data>
<optionalElement3>
<value1>1</value1>
<value2>2</value2>
</optionalElement3>
</data>

will be mapped to

<request>
<Element3>
<subelement1>1</subelement1>
<subelement2>2</subelement2>
</Element3>
</request>

And the validation will fail because i'm missing Element1 and Element2. The response should be (I think):

<request>
<Element1 xsi:nil="true" />
<Element2 xsi:nil="true" />
<Element3>
<subelement1>1</subelement1>
<subelement2>2<subelement2>
</Element3>
</request>

How can I do this in the mapping? How can I ensure that the element is created in the output message?

And, by the way, if a subelement is not present (let's say "data/optionalElement1/value1" how can I make sure that the destination subelement "request/Element1/subelement1" is created?

A: 

You can do all this in the mapper. I haven't been into Biztalk for a while and I don't have it near me, but I know there are functiods in the mapper that lets you check for the existence of the fields you need. Depending on the existence of these field, you can specify what the appropriate action for the mapper is.

You force the creation of fields by giving them default values in the target schema. This can also be done using the mapper, via the properties window.

Rik
Yes. That much i know. The problem is not with the third level elements ("request/Element1/subelement1") but the second level ones ("request/Element1"). What default value can i give to these elements since tey are complex types? I want to create these elements even if there are no child elements.
A: 

Yes. That much i know. The problem is not with the third level elements ("request/Element1/subelement1") but the second level ones ("request/Element1"). What default value can i give to these elements since tey are complex types? I want to create these elements even if there are no child elements.

A: 

Jose,

You'll want to look at the table looping functoid. Here's a post about it.

http://geekswithblogs.net/Chilberto/archive/2008/04/16/121274.aspx

Using this functoid with the table extraction should give you your solution. Also here's a good series on understadning the mapper.

http://www.bizbert.com/bizbert/2008/02/07/Understanding+The+BizTalk+Mapper+Part+1+Introduction.aspx

-Bryan

Bryan Corazza
A: 

Hi,

Make it very simple, Use the xlst file for mapping. Using simple if condition you can check for value exist for opetion element or not, if value exist then map that else map the null (Empty) value. So the complex element will get generated even if there is no value for opetional element.

Hope it will solve your problem.

Abhijeet

related questions