I want to modify xslt file according to output xml
My input xml is
-<NewDataSet><Header><BankName>SAMA</BankName><CashCenterName>SAMA Riyadh</CashCenterName></Header><DepositorList><ReferenceNumber>1</ReferenceNumber><DepositList_Id>0</DepositList_Id><PreparedBy>FZE</PreparedBy><TotalContainerCount>2</TotalContainerCount><ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate><DeclaredAmount>150000</DeclaredAmount></DepositorList><Carrier><CarrierName>tns1:Commercial CIT</CarrierName><CarrierNumber>10001</CarrierNumber><CarrierLocationName>tns1:Riyadh</CarrierLocationName><CarrierLocationNumber>100011</CarrierLocationNumber><CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName><CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber><DepositList_Id>0</DepositList_Id>
</Carrier><Customer><AccountNumber>ISB</AccountNumber><LocationNumber>10065100</LocationNumber><DepositList_Id>0</DepositList_Id></Customer><ContainerList><ContainerNumber>903000033102</ContainerNumber><ContainerList_Id>0</ContainerList_Id><DeclaredAmount>50000</DeclaredAmount><DepositList_Id>0</DepositList_Id></ContainerList><ContainerList><ContainerNumber>903000033103</ContainerNumber><ContainerList_Id>1</ContainerList_Id><DeclaredAmount>100000</DeclaredAmount><DepositList_Id>0</DepositList_Id></ContainerList><ContainerContentList><ContainerContentList_Id>0</ContainerContentList_Id><TotalRecordCount>1</TotalRecordCount><ContainerList_Id>0</ContainerList_Id></ContainerContentList><ContainerContentList><ContainerContentList_Id>1</ContainerContentList_Id><TotalRecordCount>1</TotalRecordCount><ContainerList_Id>1</ContainerList_Id></ContainerContentList><ContentCategory><ISOCurrencyCode>SAR</ISOCurrencyCode><InventoryType>Fit Currency</InventoryType><InventorySubType>Fit</InventorySubType><ContainerContentList_Id>0</ContainerContentList_Id></ContentCategory><ContentCategory><ISOCurrencyCode>SAR</ISOCurrencyCode><InventoryType>Fit Currency</InventoryType><InventorySubType>Fit</InventorySubType><ContainerContentList_Id>1</ContainerContentList_Id></ContentCategory><ContentCategoryItemList><ItemFaceValue>5</ItemFaceValue><ItemCount>10000</ItemCount><DeclaredAmount>50000</DeclaredAmount><ContentCategoryItemList_Id>0</ContentCategoryItemList_Id><ContainerContentList_Id>0</ContainerContentList_Id></ContentCategoryItemList><ContentCategoryItemList><ItemFaceValue>10</ItemFaceValue><ItemCount>10000</ItemCount><DeclaredAmount>100000</DeclaredAmount><ContentCategoryItemList_Id>1</ContentCategoryItemList_Id><ContainerContentList_Id>1</ContainerContentList_Id></ContentCategoryItemList><CategoryItemUnitList><InventoryUnitName>Bundle</InventoryUnitName><UnitQuantity>10</UnitQuantity><UnitAmount>5000</UnitAmount><UnitWeight/><MeasurementUnit/><BeginSerialNumber/><Series/><EndSerialNumber/><ContentCategoryItemList_Id>0</ContentCategoryItemList_Id></CategoryItemUnitList><CategoryItemUnitList><InventoryUnitName>Bundle</InventoryUnitName><UnitQuantity>10</UnitQuantity><UnitAmount>10000</UnitAmount><UnitWeight/><MeasurementUnit/><BeginSerialNumber/><Series/><EndSerialNumber/><ContentCategoryItemList_Id>1</ContentCategoryItemList_Id></CategoryItemUnitList></NewDataSet>
The xslt so far
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes"/><xsl:strip-space elements="*"/><xsl:template match="/NewDataSet"><NewDataSet><xsl:copy-of select="Header"/><xsl:for-each select="DepositorList"><DepositorList><xsl:variable name="DepositList_Id"><xsl:value-of select="DepositList_Id"/></xsl:variable><xsl:variable name="ContainerList_Id"><xsl:value-of select="../ContainerList[DepositList_Id=$DepositList_Id]/ContainerList_Id"/></xsl:variable><xsl:variable name="ContainerContentList_Id"><xsl:value-of select="../ContainerContentList[ContainerList_Id=$DepositList_Id]/ContainerList_Id/ontainerContentList_Id"/></xsl:variable><xsl:copy-of select="../Carrier[DepositList_Id=$DepositList_Id]"/><xsl:copy-of select="../Customer[DepositList_Id=$DepositList_Id]"/><xsl:copy-of select="*"/><ContainerList><xsl:copy-of select="../ContainerList[DepositList_Id=$DepositList_Id]"/><ContainerContentList> <xsl:copy-of select="../ContainerContentList[ContainerList_Id=$ContainerList_Id]"/></ContainerContentList> </ContainerList></DepositorList></xsl:for-each></NewDataSet></xsl:template></xsl:stylesheet>
expected xml output is
<?xml version='1.0' ?><NewDataSet><Header><BankName>SAMA</BankName><CashCenterName>SAMA Riyadh</CashCenterName></Header><DepositorList><ReferenceNumber>1</ReferenceNumber><DepositList_Id>0</DepositList_Id><PreparedBy>FZE</PreparedBy><TotalContainerCount>2</TotalContainerCount><ExpectedDate>20180419T09:13:1005:00</ExpectedDate><DeclaredAmount>150000.00</DeclaredAmount></DepositorList><Carrier><CarrierName>tns1:Commercial CIT</CarrierName><CarrierNumber>10001</CarrierNumber><CarrierLocationName>tns1:Riyadh</CarrierLocationName><CarrierLocationNumber>100011</CarrierLocationNumber><CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName><CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber><DepositList_Id>0</DepositList_Id></Carrier><Customer><AccountNumber>ISB</AccountNumber><LocationNumber>10065100</LocationNumber><DepositList_Id>0</DepositList_Id></Customer><ContainerList><Container><ContainerNumber>903000033102</ContainerNumber><ContainerList_Id>0</ContainerList_Id><DeclaredAmount>50000.00</DeclaredAmount><DepositList_Id>0</DepositList_Id><ContentCategory><ISOCurrencyCode>SAR</ISOCurrencyCode><InventoryType>Fit Currency</InventoryType><InventorySubType>Fit</InventorySubType></ContentCategory><ContentCategoryItemList><ItemFaceValue>5.0000</ItemFaceValue><ItemCount>10000</ItemCount><DeclaredAmount>50000.00</DeclaredAmount><ContentCategoryItemList_Id>0</ContentCategoryItemList_Id></ContentCategoryItemList><CategoryItemUnitList><InventoryUnitName>Bundle</InventoryUnitName><UnitQuantity>10</UnitQuantity><UnitAmount>5000.0</UnitAmount><UnitWeight/><MeasurementUnit/><BeginSerialNumber/><Series/><EndSerialNumber/></CategoryItemUnitList></Container><Container><ContainerNumber>903000033103</ContainerNumber><ContainerList_Id>1</ContainerList_Id><DeclaredAmount>100000.00</DeclaredAmount><DepositList_Id>0</DepositList_Id><ContentCategory><ISOCurrencyCode>SAR</ISOCurrencyCode><InventoryType>Fit Currency</InventoryType><InventorySubType>Fit</InventorySubType></ContentCategory><ContentCategoryItemList><ItemFaceValue>10.0000</ItemFaceValue><ItemCount>10000</ItemCount><DeclaredAmount>100000.00</DeclaredAmount><ContentCategoryItemList_Id>1</ContentCategoryItemList_Id></ContentCategoryItemList><CategoryItemUnitList><InventoryUnitName>Bundle</InventoryUnitName><UnitQuantity>10</UnitQuantity><UnitAmount>10000.0</UnitAmount><UnitWeight/><MeasurementUnit/><BeginSerialNumber/><Series/><EndSerialNumber/></CategoryItemUnitList></Container></ContainerList></NewDataSet>
Please suggest xslt changes?
The depositor_Id is not a constant value and there can be n number of deposits in the xml so the attached is only for 1 of them with deposit_Id=0