none
BizTalk Map XSLT - Seperate record not producing output RRS feed

  • Question

  • I am using below XSLT. I have Detail node and SerialNumber node and there are elements under it.  All fields are under SerialNumber node expect ManufactureItemId which is under Detail node.

    So my output is producing always only first record of Detail node , it is not picking related Matching record ManufactureItemId record . How can I fix this in my below XSLT

    <?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://Company.Integration.LAT.Schemas.Shipment.1000" xmlns:ns0="http://Company.Integration.LAT.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:variable name="quantity" select="s0:QuantityShipped/text()"></xsl:variable>
            <xsl:variable name="ManufactureId" select="s0:ManufactureItemId/text()"></xsl:variable>
    
            <xsl:for-each select="../s0:SerialNumbers">
    
              <xsl:if test="($itemId=s0:ItemId/text()) and ($Warehouse=s0:Warehouse/text())">
                <ItemIdRecord>
    
                  <xsl:if test="../s0:Header/s0:CustomerAddress/s0:Name">
                    <Name>
                      <xsl:value-of select="../s0:Header/s0:CustomerAddress/s0:Name/text()" />
                    </Name>
                  </xsl:if>
    
                  <PackingSlipId>
                    <xsl:value-of select="../s0:Header/s0:PackingSlipId/text()" />
                  </PackingSlipId>
    
                  <PackingSlipDateTime>
                    <xsl:value-of select="../s0:Header/s0:PackingSlipDateTime/text()" />
                  </PackingSlipDateTime>
    
    
                  <QuantityShipped>
                    <xsl:value-of select="../s0:Detail/s0:QuantityShipped/text()" />
                  </QuantityShipped>
    
                  <ManufactureItemId>
                    <xsl:value-of select="s0:ManufactureItemId/text()" />
                  </ManufactureItemId>
    
    
                  <WareHouse>
                    <xsl:value-of select="s0: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>
    


    MBH

    Monday, June 1, 2015 9:57 PM

Answers

  • Try this.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    >
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
    
        <ns0:Shipments xmlns:ns0="http://Company.Integration.LATAM.SamsungCollaboration.ItemIDs">
          <xsl:for-each select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='SerialNumbers' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']">
            <ItemIdRecord>
              <Name>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Header' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='CustomerAddress' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Name' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']" />
              </Name>
              <PackingSlipId>
                <xsl:value-of select="./*[local-name()='PackingSlipId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </PackingSlipId>
              <PackingSlipDateTime>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Header' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='PackingSlipDateTime' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']" />
              </PackingSlipDateTime>
              <WareHouse>
                <xsl:value-of select="./*[local-name()='Warehouse' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </WareHouse>
              <xsl:variable name="CurrentShipmentItemId" select="./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              <ManufactureItemId>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Detail' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000'][./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000'] = $CurrentShipmentItemId]/*[local-name()='ManufactureItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </ManufactureItemId>
              <ItemId>
                <xsl:value-of select="./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </ItemId>
              <QuantityShipped>
                <xsl:value-of select="./*[local-name()='Warehouse' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </QuantityShipped>
              <IMEINumber>
                <xsl:value-of select="./*[local-name()='IMEINumber' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </IMEINumber>
            </ItemIdRecord>
          </xsl:for-each>
        </ns0:Shipments>
      </xsl:template>
    </xsl:stylesheet>

    Best regards 

    Rasmus Jaeger

    Wednesday, June 10, 2015 9:24 AM

All replies

  • Can you post the input XML?

    Morten la Cour

    Tuesday, June 2, 2015 9:33 AM
  • Please post schemas.
    Tuesday, June 2, 2015 9:37 AM
  • Input schema xml :

    <?xml version="1.0" encoding="utf-16"?> <xs:schema xmlns="http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="https://Company.Integration.LATAM.Shipments.Schemas.ShipmentPropSchema" elementFormDefault="qualified" targetNamespace="http://Brightstar.Integration.LATAM.Shipments.Schemas.Shipment.1000" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:appinfo> <b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003"> <b:namespace prefix="ns0" uri="https://Brightstar.Integration.LATAM.Shipments.Schemas.ShipmentPropSchema" location=".\ShipmentPropSchema.xsd" /> </b:imports> </xs:appinfo> </xs:annotation> <xs:element name="Shipment"> <xs:annotation> <xs:appinfo> <b:properties> <b:property name="ns0:CompanyId" xpath="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Header' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='CompanyId' and namespace-uri()='http://Brightstar.Integration.LATAM.Shipments.Schemas.Shipment.1000']" /> <b:property name="ns0:Source" xpath="/*[local-name()='Shipment' and namespace-uri()='http://Comapny.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Source' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']" /> </b:properties> </xs:appinfo> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Source" type="xs:string" /> <xs:element name="Header"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="CustomerAddress"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Address1" type="xs:string" /> <xs:element minOccurs="0" name="Address2" type="xs:string" /> <xs:element minOccurs="0" name="Address3" type="xs:string" /> <xs:element minOccurs="0" name="Attention" type="xs:string" /> <xs:element minOccurs="0" name="City" type="xs:string" /> <xs:element minOccurs="0" name="Country" type="xs:string" /> <xs:element minOccurs="0" name="County" type="xs:string" /> <xs:element minOccurs="0" name="Name" type="xs:string" /> <xs:element minOccurs="0" name="Phone" type="xs:string" /> <xs:element minOccurs="0" name="PostalCode" type="xs:string" /> <xs:element minOccurs="0" name="State" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element minOccurs="0" name="ShippingAddress"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Address1" type="xs:string" /> <xs:element minOccurs="0" name="Address2" type="xs:string" /> <xs:element minOccurs="0" name="Address3" type="xs:string" /> <xs:element minOccurs="0" name="Attention" type="xs:string" /> <xs:element minOccurs="0" name="City" type="xs:string" /> <xs:element minOccurs="0" name="Country" type="xs:string" /> <xs:element minOccurs="0" name="County" type="xs:string" /> <xs:element minOccurs="0" name="Name" type="xs:string" /> <xs:element minOccurs="0" name="Phone" type="xs:string" /> <xs:element minOccurs="0" name="PostalCode" type="xs:string" /> <xs:element minOccurs="0" name="State" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element minOccurs="0" name="CarrierName" type="xs:string" /> <xs:element minOccurs="0" name="CompanyId" type="xs:string" /> <xs:element minOccurs="0" name="CreatedDateTime" type="xs:dateTime" /> <xs:element minOccurs="0" name="CustomerId" type="xs:string" /> <xs:element minOccurs="0" name="CustomerDeliveryId" type="xs:string" /> <xs:element minOccurs="0" name="CustomerOrderNumber" type="xs:string" /> <xs:element minOccurs="0" name="Guia" type="xs:string" /> <xs:element minOccurs="0" name="InvoiceAmount" type="xs:decimal" /> <xs:element minOccurs="0" name="InvoiceDate" type="xs:dateTime" /> <xs:element minOccurs="0" name="InvoiceId" type="xs:string" /> <xs:element minOccurs="0" name="NumberOfBoxes" type="xs:long" /> <xs:element minOccurs="0" name="OrderId" type="xs:string" /> <xs:element minOccurs="0" name="ShipLocationName" type="xs:string" /> <xs:element minOccurs="0" name="ShipmentNotes" type="xs:string" /> <xs:element minOccurs="0" name="ShipperId" type="xs:string" /> <xs:element minOccurs="0" name="ShipToId" type="xs:string" /> <xs:element minOccurs="0" name="Status" type="xs:string" /> <xs:element minOccurs="0" name="TotalWeight" type="xs:decimal" /> <xs:element minOccurs="0" name="PackingSlipDateTime" type="xs:string" /> <xs:element minOccurs="0" name="PackingSlipId" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element maxOccurs="unbounded" name="Detail"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="AlternateItemId" type="xs:string" /> <xs:element minOccurs="0" name="InventoryTransactionId" type="xs:string" /> <xs:element minOccurs="0" name="ItemBrand" type="xs:string" /> <xs:element minOccurs="0" name="ItemDescription" type="xs:string" /> <xs:element minOccurs="0" name="ItemId" type="xs:string" /> <xs:element minOccurs="0" name="ItemModel" type="xs:string" /> <xs:element minOccurs="0" name="NetWeight" type="xs:decimal" /> <xs:element minOccurs="0" name="QuantityShipped" type="xs:long" /> <xs:element minOccurs="0" name="SalesPrice" type="xs:decimal" /> <xs:element minOccurs="0" name="SiteId" type="xs:string" /> <xs:element minOccurs="0" name="ShipperId" type="xs:string" /> <xs:element minOccurs="0" name="UnitPrice" type="xs:decimal" /> <xs:element minOccurs="0" name="Warehouse" type="xs:string" /> <xs:element name="ManufactureItemId" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element minOccurs="0" maxOccurs="unbounded" name="ShipmentBox"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Scanned" type="xs:string" /> <xs:element minOccurs="0" name="ShipperId" type="xs:string" /> <xs:element minOccurs="0" name="TrackingNumber" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element minOccurs="0" maxOccurs="unbounded" name="SerialNumbers"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Email" type="xs:string" /> <xs:element minOccurs="0" name="PackingSlipId" type="xs:string" /> <xs:element minOccurs="0" name="CodeOpen" type="xs:string" /> <xs:element minOccurs="0" name="CodeSAP" type="xs:string" /> <xs:element minOccurs="0" name="ItemId" type="xs:string" /> <xs:element minOccurs="0" name="Description" type="xs:string" /> <xs:element minOccurs="0" name="IMEINumber" type="xs:string" /> <xs:element minOccurs="0" name="ICC" type="xs:string" /> <xs:element minOccurs="0" name="IMSI" type="xs:string" /> <xs:element minOccurs="0" name="Warehouse" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

    Output Schema (XML) :

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns="http://Company.Integration.LATAM.SamsungCollaboration.ItemIDs" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Company.Integration.LATAM.SamsungCollaboration.ItemIDs" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Shipments">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="ItemIdRecord">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" name="Name" type="xs:string" />
                  <xs:element minOccurs="0" name="PackingSlipId" type="xs:string" />
                  <xs:element minOccurs="0" name="PackingSlipDateTime" type="xs:string" />
                  <xs:element minOccurs="0" name="WareHouse" type="xs:string" />
                  <xs:element minOccurs="0" name="ManufactureItemId" type="xs:string" />
                  <xs:element minOccurs="0" name="ItemId" type="xs:string" />
                  <xs:element minOccurs="0" name="QuantityShipped" type="xs:long" />
                  <xs:element minOccurs="0" name="IMEINumber" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>



    MBH

    Tuesday, June 2, 2015 10:54 AM
  • Please also let me know if sample test file is also required for testing ? I can email it to you ?

    MBH

    Tuesday, June 2, 2015 11:30 AM
  • Below is the test file

    <ns0:Shipment xmlns:ns0="http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000"><ns0:Source>DynamicsAX</ns0:Source><ns0:Header><ns0:CustomerAddress><ns0:Address1>CERRO EL PLOMO 5680, TORRE 6 PISO 20, SANTIAGO</ns0:Address1><ns0:Attention>intercambio_empresas@gsuite.cl</ns0:Attention><ns0:City>Santiago</ns0:City><ns0:Country>CHL</ns0:Country><ns0:Name>VIRGIN MOBILE CHILE SPA</ns0:Name><ns0:Phone>5627143956</ns0:Phone><ns0:State>13</ns0:State></ns0:CustomerAddress><ns0:ShippingAddress><ns0:Address1>CERRO EL PLOMO 5680, TORRE 6 PISO 20, SANTIAGO</ns0:Address1><ns0:Attention>intercambio_empresas@gsuite.cl</ns0:Attention><ns0:City>Santiago</ns0:City><ns0:Country>CHL</ns0:Country><ns0:County>CHL</ns0:County><ns0:Name>TRIBE MOBILE CHILE SPA</ns0:Name><ns0:Phone>5627143956</ns0:Phone><ns0:State>13</ns0:State></ns0:ShippingAddress><ns0:CarrierName>Correo de Chile</ns0:CarrierName><ns0:CompanyId>1077</ns0:CompanyId><ns0:CreatedDateTime>2015-06-01T18:50:38Z</ns0:CreatedDateTime><ns0:CustomerId>31000000278</ns0:CustomerId><ns0:CustomerOrderNumber>B2C Virgin</ns0:CustomerOrderNumber><ns0:InvoiceAmount>204363.00</ns0:InvoiceAmount><ns0:InvoiceDate>2015-05-31T00:00:00Z</ns0:InvoiceDate><ns0:InvoiceId>FC-030-0005</ns0:InvoiceId><ns0:OrderId>SOZN00000030</ns0:OrderId><ns0:ShipLocationName>VIRGIN MOBILE CHILE SPA</ns0:ShipLocationName><ns0:ShipperId>IBZN000108</ns0:ShipperId><ns0:ShipToId>41000003521</ns0:ShipToId><ns0:Status>N</ns0:Status><ns0:PackingSlipDateTime>2015-02-10T15:16:41Z</ns0:PackingSlipDateTime><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId></ns0:Header><ns0:Detail><ns0:AlternateItemId>NVIO795SUM891LVMC-A0</ns0:AlternateItemId><ns0:InventoryTransactionId>LZN003030</ns0:InventoryTransactionId><ns0:ItemBrand>AV3</ns0:ItemBrand><ns0:ItemDescription>AVVIO AVVIO 795S DUAL SIM UMTS, NEW (FROM FACTORY), FREQUENCY: UMTS 850- 1900 -</ns0:ItemDescription><ns0:ItemId>11000011781</ns0:ItemId><ns0:ItemModel>NVIO795SUM891LVMC-A0</ns0:ItemModel><ns0:QuantityShipped>2.00</ns0:QuantityShipped><ns0:SalesPrice>100000.00</ns0:SalesPrice><ns0:SiteId>CL-01</ns0:SiteId><ns0:ShipperId>IBZN000108</ns0:ShipperId><ns0:UnitPrice>80666.00</ns0:UnitPrice><ns0:Warehouse>00000103</ns0:Warehouse><ns0:ManufactureItemId>SWD08815BB</ns0:ManufactureItemId></ns0:Detail><ns0:Detail><ns0:AlternateItemId>VMSCARD-CBS2M---0004</ns0:AlternateItemId><ns0:InventoryTransactionId>LZN003031</ns0:InventoryTransactionId><ns0:ItemBrand>OT9</ns0:ItemBrand><ns0:ItemDescription>Chip Blister con sticker $2.000</ns0:ItemDescription><ns0:ItemId>11000009465</ns0:ItemId><ns0:ItemModel>VMSCARD-CBS2M---0004</ns0:ItemModel><ns0:QuantityShipped>5.00</ns0:QuantityShipped><ns0:SalesPrice>1000.00</ns0:SalesPrice><ns0:SiteId>CL-01</ns0:SiteId><ns0:ShipperId>IBZN000108</ns0:ShipperId><ns0:UnitPrice>743.00</ns0:UnitPrice><ns0:Warehouse>00000103</ns0:Warehouse><ns0:ManufactureItemId>CHP16582AS</ns0:ManufactureItemId></ns0:Detail><ns0:Detail><ns0:AlternateItemId>VMSCARD-CWST----0004</ns0:AlternateItemId><ns0:InventoryTransactionId>LZN003032</ns0:InventoryTransactionId><ns0:ItemBrand>OT9</ns0:ItemBrand><ns0:ItemDescription>Chip Wallet Santander</ns0:ItemDescription><ns0:ItemId>11000009482</ns0:ItemId><ns0:ItemModel>VMSCARD-CWST----0004</ns0:ItemModel><ns0:QuantityShipped>9.00</ns0:QuantityShipped><ns0:SalesPrice>1000.00</ns0:SalesPrice><ns0:SiteId>CL-01</ns0:SiteId><ns0:ShipperId>IBZN000108</ns0:ShipperId><ns0:UnitPrice>743.00</ns0:UnitPrice><ns0:Warehouse>00000103</ns0:Warehouse><ns0:ManufactureItemId>CHP86325AR</ns0:ManufactureItemId></ns0:Detail><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000011781</ns0:ItemId><ns0:Description>AVVIO, AVVIO 795S DUAL SIM, UMTS, UMTS 850- 1900 - GSM 85</ns0:Description><ns0:IMEINumber>355040060655146</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000011781</ns0:ItemId><ns0:Description>AVVIO, AVVIO 795S DUAL SIM, UMTS, UMTS 850- 1900 - GSM 85</ns0:Description><ns0:IMEINumber>355040060659429</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009465</ns0:ItemId><ns0:Description>Chip Blister con sticker $2.000</ns0:Description><ns0:IMEINumber>895607020000886870</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009465</ns0:ItemId><ns0:Description>Chip Blister con sticker $2.000</ns0:Description><ns0:IMEINumber>895607020000886871</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009465</ns0:ItemId><ns0:Description>Chip Blister con sticker $2.000</ns0:Description><ns0:IMEINumber>895607020000886872</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009465</ns0:ItemId><ns0:Description>Chip Blister con sticker $2.000</ns0:Description><ns0:IMEINumber>895607020000886873</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009465</ns0:ItemId><ns0:Description>Chip Blister con sticker $2.000</ns0:Description><ns0:IMEINumber>895607020000886874</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882624</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882625</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882626</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882627</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882628</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882629</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882641</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882663</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers><ns0:SerialNumbers><ns0:PackingSlipId>GD-052-100026</ns0:PackingSlipId><ns0:ItemId>11000009482</ns0:ItemId><ns0:Description>Chip Wallet Santander</ns0:Description><ns0:IMEINumber>895607020000882664</ns0:IMEINumber><ns0:ICC></ns0:ICC><ns0:IMSI></ns0:IMSI><ns0:Warehouse>00000103</ns0:Warehouse></ns0:SerialNumbers></ns0:Shipment>

    for the schema above provided


    MBH

    Tuesday, June 2, 2015 2:17 PM
  • Try this:

    <?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://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000" xmlns:ns0="http://Company.Integration.LAT.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:variable name="quantity" select="s0:QuantityShipped/text()">
            </xsl:variable>
            <xsl:variable name="ManufactureId" select="s0:ManufactureItemId/text()">
            </xsl:variable>
            <xsl:for-each select="../s0:SerialNumbers">
              <xsl:if test="($itemId=s0:ItemId/text()) and ($Warehouse=s0:Warehouse/text())">
                <ItemIdRecord>
                  <xsl:if test="../s0:Header/s0:CustomerAddress/s0:Name">
                    <Name>
                      <xsl:value-of select="../s0:Header/s0:CustomerAddress/s0:Name/text()" />
                    </Name>
                  </xsl:if>
                  <PackingSlipId>
                    <xsl:value-of select="../s0:Header/s0:PackingSlipId/text()" />
                  </PackingSlipId>
                  <PackingSlipDateTime>
                    <xsl:value-of select="../s0:Header/s0:PackingSlipDateTime/text()" />
                  </PackingSlipDateTime>
                  <QuantityShipped>
                    <xsl:value-of select="../s0:Detail/s0:QuantityShipped/text()" />
                  </QuantityShipped>
                  <ManufactureItemId>
                    <xsl:value-of select="$ManufactureId" />
                  </ManufactureItemId>
                  <WareHouse>
                    <xsl:value-of select="s0: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>

    Morten la Cour

    Tuesday, June 2, 2015 8:09 PM
  • this is same as my code, this code is producing 'ManufactureId' same in all records, not what I want

    MBH

    Tuesday, June 2, 2015 9:44 PM
  • Try this.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    >
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
    
        <ns0:Shipments xmlns:ns0="http://Company.Integration.LATAM.SamsungCollaboration.ItemIDs">
          <xsl:for-each select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='SerialNumbers' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']">
            <ItemIdRecord>
              <Name>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Header' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='CustomerAddress' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Name' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']" />
              </Name>
              <PackingSlipId>
                <xsl:value-of select="./*[local-name()='PackingSlipId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </PackingSlipId>
              <PackingSlipDateTime>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Header' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='PackingSlipDateTime' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']" />
              </PackingSlipDateTime>
              <WareHouse>
                <xsl:value-of select="./*[local-name()='Warehouse' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </WareHouse>
              <xsl:variable name="CurrentShipmentItemId" select="./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              <ManufactureItemId>
                <xsl:value-of select="/*[local-name()='Shipment' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']/*[local-name()='Detail' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000'][./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000'] = $CurrentShipmentItemId]/*[local-name()='ManufactureItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </ManufactureItemId>
              <ItemId>
                <xsl:value-of select="./*[local-name()='ItemId' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </ItemId>
              <QuantityShipped>
                <xsl:value-of select="./*[local-name()='Warehouse' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </QuantityShipped>
              <IMEINumber>
                <xsl:value-of select="./*[local-name()='IMEINumber' and namespace-uri()='http://Company.Integration.LATAM.Shipments.Schemas.Shipment.1000']"/>
              </IMEINumber>
            </ItemIdRecord>
          </xsl:for-each>
        </ns0:Shipments>
      </xsl:template>
    </xsl:stylesheet>

    Best regards 

    Rasmus Jaeger

    Wednesday, June 10, 2015 9:24 AM