-1

I have an XML schema where there is a repeating inner node. There is a possibility that the Inner Node count can be 0. If the inner node value is not passed in the XML file, it is throwing a mapping exception. I need the count of inner node and map it only if the count is greater than 0. How can it be done in Biztalk Mapper?

Here is the sample XML file :

  <ns0:OrderDetails xmlns:ns0="http://OrderDetails.Input">
  <OrderNo>10</OrderNo>
  <OrderName>OrderName_0</OrderName>
  <Description>Description_0</Description>
  <TotalAmount>10</TotalAmount>
  <OrderItemDetails><!-- Repeating Node -->
    <ItemID>ItemID_0</ItemID>
    <ItemName>ItemName_0</ItemName>
    <ItemDescription>ItemDescription_0</ItemDescription>
    <Quantity>10</Quantity>
    <UnitPrice>10</UnitPrice>
    <TotalItemPrice>10</TotalItemPrice>
  </OrderItemDetails>
  <OrderItemDetails>
    <ItemID>ItemID_0</ItemID>
    <ItemName>ItemName_0</ItemName>
    <ItemDescription>ItemDescription_0</ItemDescription>
    <Quantity>10</Quantity>
    <UnitPrice>10</UnitPrice>
    <TotalItemPrice>10</TotalItemPrice>
  </OrderItemDetails>
  <OrderItemDetails>
    <ItemID>ItemID_0</ItemID>
    <ItemName>ItemName_0</ItemName>
    <ItemDescription>ItemDescription_0</ItemDescription>
    <Quantity>10</Quantity>
    <UnitPrice>10</UnitPrice>
    <TotalItemPrice>10</TotalItemPrice>
  </OrderItemDetails>
</ns0:OrderDetails>
Red Devil
  • 45
  • 3
  • 7
  • 1
    Can perhaps give us more information by adding the map you have so far and the target schema to your question? – Gruff May 05 '16 at 16:20
  • 1
    What you're describing should not happen so there is something else going on. You need to post the exact error message for us to help you. – Johns-305 May 05 '16 at 18:18
  • As others have said without both the target schema and your map we cannot reproduce the issue. Also we need the exception that you are getting. – Dijkgraaf Jun 02 '16 at 00:40
  • Have you set the both the OrderItemsDetails and the node that it is mapping too, to Min Occurs 0? – Dijkgraaf Jun 02 '16 at 00:53

1 Answers1

0

To get a count of a repeating node, use the Record Count Functoid under Advanced Functoids.

The below maps works both with your sample and an message with no OrderItemDetails.

Note: I have set the Min Occurs of OrderItemDetails to 0

enter image description here

Message with no OrderItemDetails

<ns0:OrderDetails xmlns:ns0="http://OrderDetails.Input">
    <OrderNo>10</OrderNo>
    <OrderName>OrderName_0</OrderName>
    <Description>Description_0</Description>
    <TotalAmount>10</TotalAmount>
</ns0:OrderDetails>

Output:

<ns0:OrderDetails xmlns:ns0="http://OrderDetails.Input">
    <OrderNo>10</OrderNo>
    <OrderName>OrderName_0</OrderName>
    <Description>Description_0</Description>
    <TotalAmount>10</TotalAmount>
    <ns0:Count>0</ns0:Count>
</ns0:OrderDetails>
Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54