Я хочу скопировать все содержимое XML, сопоставив определенный узел и добавив конверт SOAP для каждого повторяющегося узла 'postItemCost'.
Исходный XML:
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>0.00</avgcost>
<lastcost>0.00</lastcost>
<stdcost>0.00</stdcost>
</invcost>
<location>2201</location>
</ItemInvCostRequest>
<itemnum>9322979</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>0.00</avgcost>
<lastcost>0.00</lastcost>
<stdcost>0.00</stdcost>
</invcost>
<location>1101</location>
</ItemInvCostRequest>
<itemnum>9322979</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>1000.00</avgcost>
<lastcost>1000.00</lastcost>
<stdcost>1000.00</stdcost>
</invcost>
<location>1101</location>
</ItemInvCostRequest>
<itemnum>9322984</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
</ns0:Message1>
</ns0:Messages>
ОжидаетсяВыходные данные -
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>0.00</avgcost>
<lastcost>0.00</lastcost>
<stdcost>0.00</stdcost>
</invcost>
<location>2201</location>
</ItemInvCostRequest>
<itemnum>9322979</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>0.00</avgcost>
<lastcost>0.00</lastcost>
<stdcost>0.00</stdcost>
</invcost>
<location>1101</location>
</ItemInvCostRequest>
<itemnum>9322979</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:postItemCost xmlns:ns1="http://items.test.com/">
<ItemInvCostReqList>
<ItemInvCostRequest>
<invcost>
<avgcost>1000.00</avgcost>
<lastcost>1000.00</lastcost>
<stdcost>1000.00</stdcost>
</invcost>
<location>1101</location>
</ItemInvCostRequest>
<itemnum>9322984</itemnum>
</ItemInvCostReqList>
</ns1:postItemCost>
</soapenv:Body>
</soapenv:Envelope>
Это мой XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="w3.org/1999/XSL/Transform" xmlns:ns0="sap.com/xi/XI/SplitAndMerge" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope">
<soapenv:Header/>
<soapenv:Body>
<xsl:template match="Message//Message1//postInvCostRequest">
<xsl:copy-of select="/postInvCostRequest"/>
</xsl:template>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
Я хочу добавить конверт SOAP для каждого повторяющегося узла postItemCost.
Итак, не могли бы вы мне помочь?с кодом XSLT, который может помочь мне достичь ожидаемого результата.