Krip
Krip

Reputation: 864

BizTalk Map Incorrectly Parsing Input XML

I've got a situation where my BizTalk map is not extracting data from input XML correctly.

The input schema looks like this:

Sequence

  A 

  B

All 3 of those nodes on the XSD have min 0, max unbounded.

So here's a sample input file fragment:

<A>1</A>
<B>hi</B>
<A>2</A>
<B>there</B>

Now my map takes this data and calls stored procs to insert data into a table. I'm getting "hi" for field B for both A of 1 and A of 2. That's incorrect.

I traced the problem to the map. The XSLT generated does a foreach on A, and then goes to grab value B but always grabs the first B.

So anyone have any tips for modifying either the input schema or the map to get this to work correctly?

Upvotes: 1

Views: 943

Answers (1)

Wagner Silveira
Wagner Silveira

Reputation: 1626

If you need to group A and B items togethers, you could change the schema is to create a wrapper element, so your schema would look like:

<xs:element name="wrapper">
  <xs:complextype>
    <xs:sequence>
      <xsl:element name="A" type="xs:string" minoccur="1" maxoccur="1"/>
      <xsl:element name="B" type="xs:string" minoccur="1" maxoccur="1" />
    </xs:sequence>
  </xs:complextype>
</xs:element>

Then you could loop through wrapper elements and get the A and B elements. But I'm not sure if that is what you're looking for.

The other option is to work within XSLT Call-templates. Using A and the current iteration of A, then when you get B you actually B[i], where i is the current iteration.

Upvotes: 2

Related Questions