none
How to write XSLT using multiple input to one output xml RRS feed

  • Question

  • Currently have a requirement to to create a XSLT, using multiple input xml to one output xml, we need to create a one xml with the line wise data, Could you please guide and advise on this?
    Thursday, August 8, 2019 2:55 PM

Answers

  • Hi Mahesh,

    So it should be 3 step process:

    1. FTP all XML files to a local storage.
    2. Compose index  XML file, i.e. XMLFileList.xml
    3. Process all of it via XSLT transformation I provided earlier in this thread.



    • Edited by Yitzhak Khabinsky Wednesday, October 16, 2019 1:27 PM
    • Marked as answer by Maheshma Monday, October 21, 2019 6:45 AM
    Wednesday, October 16, 2019 1:26 PM

All replies

  • Hi Maheshma,

    Please share a couple of XML files, and a final XML file structure.

    In the meantime, here is a good link: How to process multiple input xml files with a single xslt ?
    Thursday, August 8, 2019 3:05 PM
  • Hi Yitzhak, Thank you response, For your reference here with attached sample required output xml and Input xml little big, So i have attached that input and current single xslt mapping script on media fire file share location, Could you please check and support to create multiple input to one output xml.

    Input xml and current single xslt mapping- : http://www.mediafire.com/file/tib1g5drc92mltk/InputSampleAnd_Single_Mapping.zip/file

    Expected Output Sample :-

    <?xml version="1.0" encoding="utf-8"?> <tblFreight_Excel_Upload> <intFreightExcelCode>1</intFreightExcelCode> <BL>HAWB No: FTK18100140</BL> <HABN></HABN> <InvoiceNo>AR INV ECL-CM1-00000441</InvoiceNo> <InvoiceType>CUR</InvoiceType> <NBT>0.1700</NBT> <FREIGHT>2989.9800</FREIGHT> <IOUDDOCUM>8.4400</IOUDDOCUM> <Total>2998.5900</Total> <Currency>USD</Currency> <ExchangeRate>177.650000000</ExchangeRate> <BillDate>2018-11-06T15:45:00</BillDate> <PaymentType>Prepaid</PaymentType> <Remark></Remark> <intFreightExcelCode>2</intFreightExcelCode> <BL>HAWB No: FTK18100143</BL> <HABN> </HABN> <InvoiceNo>AR INV ECL-CM1-00000447</InvoiceNo> <InvoiceType>CUR</InvoiceType> <NBT>0.1700</NBT> <FREIGHT>2989.9800</FREIGHT> <IOUDDOCUM>8.4400</IOUDDOCUM> <Total>2998.5900</Total> <Currency>USD</Currency> <ExchangeRate>177.650000000</ExchangeRate> <BillDate>2018-11-06T15:45:00</BillDate> <PaymentType>Prepaid</PaymentType> <Remark></Remark> <intFreightExcelCode>3</intFreightExcelCode> <BL>HAWB No: FTK18100148</BL> <HABN></HABN> <InvoiceNo>AR INV ECL-CM1-00000449</InvoiceNo> <InvoiceType>CUR</InvoiceType> <NBT>0.1700</NBT> <FREIGHT>2989.9800</FREIGHT> <IOUDDOCUM>8.4400</IOUDDOCUM> <Total>2998.5900</Total> <Currency>USD</Currency> <ExchangeRate>177.650000000</ExchangeRate> <BillDate>2018-11-06T15:45:00</BillDate> <PaymentType>Prepaid</PaymentType> <Remark></Remark> </tblFreight_Excel_Upload> Thanks Mahehs



    • Edited by Maheshma Sunday, August 11, 2019 5:57 AM
    Sunday, August 11, 2019 5:55 AM
  • Hi Maheshma,

    I created an XML file XMLFileList.xml (in the same directory as the rest of the XML files) that enlists all the XML files to process/combine together:

    <list>
    	<entry name="InputSample1.xml"/>
    	<entry name="InputSample2.xml"/>
    	<entry name="InputSample3.xml"/>
    </list>

    Here is the XSLT with the document() function that loads all URIs of XML files to process. I produced just a couple of elements: BL and InvoiceNo.
    Just proceeed with the rest of the elements.

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cw="http://www.cargowise.com/Schemas/Universal/2011/11" exclude-result-prefixes="cw">
    	<xsl:output method="xml" indent="yes"/>
    
    	<xsl:variable name="allResults" select="document(/list/entry/@name)//cw:Body"/>
    
    	<xsl:template match="/">
    		<tblFreight_Excel_Upload>
    			<xsl:for-each select="$allResults//cw:UniversalTransaction">
    				<perEachXMLFile>
    					<!--<xsl:copy-of select="."/>-->
    					<BL>
    						<xsl:value-of select="cw:TransactionInfo/cw:ShipmentCollection/cw:Shipment/cw:SubShipmentCollection/cw:SubShipment/cw:CarrierDocumentsOverride/cw:AWBHeader/cw:ForwardingAgentReference"/>
    					</BL>
    					<InvoiceNo>
    						<xsl:value-of select="cw:TransactionInfo/cw:DataContext/cw:DataSourceCollection/cw:DataSource/cw:Key"/>
    					</InvoiceNo>
    				</perEachXMLFile>
    			</xsl:for-each>
    		</tblFreight_Excel_Upload>
    	</xsl:template>
    </xsl:stylesheet>

    Output XML:
    <?xml version='1.0' ?>
    <tblFreight_Excel_Upload>
      <perEachXMLFile>
        <BL>HAWB No: 14019008179</BL>
        <InvoiceNo>AR INV EFL-CM1-00023151</InvoiceNo>
      </perEachXMLFile>
      <perEachXMLFile>
        <BL>HAWB No: 14019008180</BL>
        <InvoiceNo>AR INV EFL-CM1-00023153</InvoiceNo>
      </perEachXMLFile>
      <perEachXMLFile>
        <BL>HAWB No: FTK19010071</BL>
        <InvoiceNo>AR INV EFL-CM1-00023156</InvoiceNo>
      </perEachXMLFile>
    </tblFreight_Excel_Upload>
    Sunday, August 11, 2019 4:29 PM
  • HI Yitzhak,

    Well Noted, i'll look and get back to you.


    Wednesday, August 28, 2019 7:13 AM
  • Hi Yitzhak,

    i'm using Azure logic app for a translate this xml, im picking multiple xml files from FTP location, for your reference here with attached logic app workflow for your reference. Hope above xslt your wrote for a C# programming, How can i write a xslt for picked files (list of files) from FTP location.

    Thanks

    Mahesh

    Monday, October 14, 2019 4:39 AM
  • Hi Mahesh,

    So it should be 3 step process:

    1. FTP all XML files to a local storage.
    2. Compose index  XML file, i.e. XMLFileList.xml
    3. Process all of it via XSLT transformation I provided earlier in this thread.



    • Edited by Yitzhak Khabinsky Wednesday, October 16, 2019 1:27 PM
    • Marked as answer by Maheshma Monday, October 21, 2019 6:45 AM
    Wednesday, October 16, 2019 1:26 PM