none
How To Create the XSLT with the Grouping RRS feed

  • Question

  • Hi Team

    Currently i have a requirement write a XSLT map for transform one xml format to on another format,  have requirement is grouping Order no on the  JS_UniqueConsignRef, Could you please Support to me to complete that. for your reference here with attached sample input file  and expected Sample output.

    Input XML

    <Booking odata.context="https://logic-apis-southeastasia.azure-apim.net/apim/sql/076c2af418044a429486d5c21815d600/$metadata#datasets('default%2Cdefault')/tables('%5Bdbo%5D.%5BShippingXMLTable_ForOneTesting%5D')/items">
    <value odata.etag="">
    <ItemInternalId>2983e1fd-940e-4554-b1e4-293c2cf3a801</ItemInternalId>
    <JS_UniqueConsignRef>S17119207972</JS_UniqueConsignRef>
    <OrderNo>BY-91959</OrderNo>
    <BuyerCode>DKVEJ</BuyerCode>
    <SupplierCode>SRESANTUP1</SupplierCode>
    <ConfirmNo>
    </ConfirmNo>
    <InvoiceNo>SSE/0101</InvoiceNo>
    </value>
    <value odata.etag="">
    <ItemInternalId>00bb143f-a928-463e-831a-c03ef9ca71ee</ItemInternalId>
    <JS_UniqueConsignRef>S17119207972</JS_UniqueConsignRef>
    <OrderNo>BY-91967</OrderNo>
    <BuyerCode>DKVEJ</BuyerCode>
    <SupplierCode>SRESANTUP1</SupplierCode>
    <ConfirmNo>
    </ConfirmNo>
    <InvoiceNo>SSE/0101</InvoiceNo>
    
    </value>
    </Booking>

    Expected Sample Output

    <value odata.etag="">
    <JS_UniqueConsignRef>S17119207972</JS_UniqueConsignRef>
    <JS_IsForwardRegistered>true</JS_IsForwardRegistered>
    <OrderCollection>
    <OrderNo>BY-91959</OrderNo>
    <OrderNo>BY-91967</OrderNo>
    </OrderCollection>
    </value>
    

    Saturday, January 18, 2020 5:30 AM

All replies

  • Try a possible solution:

    <?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="/Booking">
    
        <Values>
          <xsl:apply-templates select="value[not(JS_UniqueConsignRef = preceding-sibling::value/JS_UniqueConsignRef)]"/>
        </Values>
    
      </xsl:template>
    
      <xsl:template match="value">
    
        <value odata.etag="">
          <xsl:copy-of select="JS_UniqueConsignRef"/>
          <JS_IsForwardRegistered>true</JS_IsForwardRegistered>
          <OrderCollection>
            <xsl:copy-of select="/Booking/value[JS_UniqueConsignRef = current()/JS_UniqueConsignRef]/OrderNo"/>
          </OrderCollection>
        </value>
    
      </xsl:template>
    
    </xsl:stylesheet>
    


    • Edited by Viorel_MVP Saturday, January 18, 2020 12:32 PM
    • Marked as answer by Maheshma Monday, January 20, 2020 1:06 AM
    • Unmarked as answer by Maheshma Monday, January 20, 2020 3:35 PM
    Saturday, January 18, 2020 12:25 PM