BizTalk Map looping not doing correctly

My requirement is in Source schema check if ItemID (under SerialNumber) = ItemID(Detail)

If equal, generate some fields from each of these Detail and SerialNumber

records into Output. When I used Equal Functoid, only its checking for 1

ItemID and skipping all others...I used Looping functoid too but not

getting required output. How should this be done ? Any inputs please

Source Schema : XML file <ns0:Detail> <ns0:ItemId>11000017040</ns0:ItemId> <ns0:QuantityShipped>2.00</ns0:QuantityShipped> <ns0:SiteId>US-01</ns0:SiteId> </ns0:Detail> <ns0:Detail> <ns0:ItemId>11000019912</ns0:ItemId> <ns0:QuantityShipped>1.00</ns0:QuantityShipped> <ns0:SiteId>US-01</ns0:SiteId> </ns0:Detail> <ns0:SerialNumbers> <ns0:ItemId>11000019912</ns0:ItemId> <ns0:IMEINumber>359893050780571</ns0:IMEINumber> </ns0:SerialNumbers> <ns0:SerialNumbers> <ns0:ItemId>11000017040</ns0:ItemId> <ns0:IMEINumber>359893050781868</ns0:IMEINumber> </ns0:SerialNumbers> <ns0:SerialNumbers> <ns0:ItemId>11000017040</ns0:ItemId> <ns0:IMEINumber>359893050841688</ns0:IMEINumber> </ns0:SerialNumbers> </ns0:Shipment> Destination schema : <?xml version="1.0" encoding="utf-16" ?> - <xs:schema xmlns="http://CompanyName.Integration.Test.Schema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://CompanyName.Integration.Test.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:element name="Shipment"> - <xs:complexType> - <xs:sequence> - <xs:element maxOccurs="unbounded" name="SNumbers"> - <xs:complexType> - <xs:sequence> <xs:element name="IMEINumber" type="xs:string" /> <xs:element name="PackingSlipID" type="xs:string" /> <xs:element name="QTY" type="xs:string" /> <xs:element name="ItemID" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

May 27th, 2015 12:15pm

I am receiving the below output, but I wanted output with records having only ItemId field in it. The record without matching ItemId should be ignored.

I applied a equalTo functoid and a loop functoid, but additional records are being populated. How can that be ignored ?

ns0:Shipments xmlns:ns0="http://Company.Integration.Test.Schemas">
 <ItemIdRecord>
  <WareHouse>14009</WareHouse> 
  <IMEINumber>359893050780571</IMEINumber> 
  </ItemIdRecord>

 <ItemIdRecord>
  <WareHouse>14009</WareHouse> 
  <IMEINumber>359893050780571</IMEINumber> 
  </ItemIdRecord>

 <ItemIdRecord>
  <WareHouse>14009</WareHouse> 
  <ItemId>11000019912</ItemId> 
  <IMEINumber>359893050780571</IMEINumber> 
  </ItemIdRecord>

 <ItemIdRecord>
  <WareHouse>14009</WareHouse> 
  <ItemId>11000017040</ItemId> 
  <IMEINumber>359893050781868</IMEINumber> 
  </ItemIdRecord>

 <ItemIdRecord>
  <WareHouse>14009</WareHouse> 
  <ItemId>11000017040</ItemId> 
  <IMEINumber>359893050841688</IMEINumber> 
  </ItemIdRecord>
  </ns0:Shipments>


Free Windows Admin Tool Kit Click here and download it now
May 27th, 2015 5:32pm

apart from XSLT, is there anyway this can be achieved with out of box functionality ?
May 27th, 2015 10:33pm

XSLT is efficient for this...Otherwise you can achieve this using a combination of functoids valuemapping,logicaleq and cumulative.

Cheers

Free Windows Admin Tool Kit Click here and download it now
May 27th, 2015 11:54pm

Can you please give an example for the above scenario ? First preference is using functoids you mentioned, how can I apply in my map for elements mentioned above in schema ? 2) also iam new to xslt, can you provide xslt code for the same to acheive ?
May 28th, 2015 4:09am

below is the Map, I want output xml if only ItemId element in Detail matches with ItemId element in SerialNumbers, else ignore the record.

Above is provided with source xml file also in previous converstion

when I do the above Map, receiving below output. The first and 2nd record does not have matching ItemId but is still populating. I want the

output only with records 3,4,5 and ignore 1 and 2.

<ns0:Shipments xmlns:ns0="http://Company.Integration.Test.Schemas"> <ItemIdRecord> <WareHouse>14009</WareHouse> <IMEINumber>359893050780571</IMEINumber> </ItemIdRecord> <ItemIdRecord> <WareHouse>14009</WareHouse> <IMEINumber>359893050780571</IMEINumber> </ItemIdRecord> <ItemIdRecord> <WareHouse>14009</WareHouse> <ItemId>11000019912</ItemId> <IMEINumber>359893050780571</IMEINumber> </ItemIdRecord> <ItemIdRecord> <WareHouse>14009</WareHouse> <ItemId>11000017040</ItemId> <IMEINumber>359893050781868</IMEINumber> </ItemIdRecord> <ItemIdRecord> <WareHouse>14009</WareHouse> <ItemId>11000017040</ItemId> <IMEINumber>359893050841688</IMEINumber> </ItemIdRecord> </ns0:Shipments>


Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 4:54am

Could you email me your schemas and map to ravindar.thati@gmail.com
May 28th, 2015 5:54am

Here you go. This should help you.

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:s0="http://Brightstar.Integration.LATAM.Shipments.Schemas.Shipment.1000" xmlns:ns0="http://Brightstar.Integration.LATAM.SamsungCollaboration.ItemIDs">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:Shipment" />
  </xsl:template>
  <xsl:template match="/s0:Shipment">
    <ns0:Shipments>
      <xsl:for-each select="s0:Detail">
        <xsl:variable name="itemId" select="s0:ItemId/text()"></xsl:variable>
        <xsl:variable name="Warehouse" select="s0:Warehouse/text()"></xsl:variable>
        <xsl:for-each select="../s0:SerialNumbers">
          
          <xsl:if test="$itemId=s0:ItemId/text()">
            <ItemIdRecord>
              <WareHouse>
                <xsl:value-of select="$Warehouse" />
              </WareHouse>
              <ItemId>
              <xsl:value-of select="s0:ItemId"/>
              </ItemId>
              <IMEINumber>
                <xsl:value-of select="s0:IMEINumber/text()" />
              </IMEINumber>
            </ItemIdRecord>
          </xsl:if>
          
        </xsl:for-each>
      </xsl:for-each>
    </ns0:Shipments>
  </xsl:template>
</xsl:stylesheet>

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 12:20pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics