基本上,我需要使用xsl将orderrelease和order的内容移动到orderline级别。
输入xml示例:
<OrderRelease EnterpriseCode="BRD" ReleaseNo="1234ABC" DocumentType="0001" SellerOrganizationCode="BU1" ShipNode="US1">
<Order OrderDate="2019-06-13T09:27:36-04:00" Action="CANCEL" OrderNo="1234ABC">
<Extn ExtnWMSOrderNumber="123ADS"/>
</Order>
<OrderLines>
<OrderLine Action="CANCEL" PrimeLineNo="1" SubLineNo="1" OrderedQty="5">
<Item ItemID="A" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
<OrderLine Action="" PrimeLineNo="2" SubLineNo="1" OrderedQty="10">
<Item ItemID="B" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
<OrderLine Action="CANCEL" PrimeLineNo="3" SubLineNo="1" OrderedQty="0">
<Item ItemID="C" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
</OrderLines>
</OrderRelease>
xml后期翻译示例:
<OrderLines>
<OrderLine Action="CANCEL" PrimeLineNo="1" SubLineNo="1" OrderedQty="5" OrderDate="2019-06-13T09:27:36-04:00" OrderNo="1234ABC" EnterpriseCode="BRD" ReleaseNo="1234ABC" DocumentType="0001" SellerOrganizationCode="BU1" ShipNode="US1" AggregatorOrderId=”12345 >
<Item ItemID="A" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
<OrderLine Action="" PrimeLineNo="1" SubLineNo="1" OrderedQty="10" OrderDate="2019-06-13T09:27:36-04:00" OrderNo="1234ABC" EnterpriseCode="BRD" ReleaseNo="1234ABC" DocumentType="0001" SellerOrganizationCode="BU1" ShipNode="US1" AggregatorOrderId=”12345>
<Item ItemID="B" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
<OrderLine Action="CANCEL" PrimeLineNo="1" SubLineNo="1" OrderedQty="0" OrderDate="2019-06-13T09:27:36-04:00" OrderNo="1234ABC" EnterpriseCode="BRD" ReleaseNo="1234ABC" DocumentType="0001" SellerOrganizationCode="BU1" ShipNode="US1 AggregatorOrderId=”12345">
<Item ItemID="C" UnitOfMeasure="STD" ProductClass="NEW"/>
</OrderLine>
</OrderLines>
我使用了下面的xsl,但它删除了所有原始的orderline元素,而且似乎没有为每个orderline执行此操作
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="OrderRelease">
<OrderLine>
<xsl:copy-of select="@*|OrderLine/@*" />
<xsl:apply-templates /><!-- optional -->
</OrderLine>
</xsl:template>
<xsl:template match="Order">
<xsl:copy-of select="@*|OrderLine/@*" />
<xsl:apply-templates /><!-- optional -->
</xsl:template>
<xsl:template match="Extn">
<xsl:copy-of select="@*|OrderLine/@*" />
<xsl:apply-templates /><!-- optional -->
</xsl:template>
<xsl:template match="OrderLine">
<xsl:copy-of select="@*|OrderLine/@*" />
</xsl:template>
</xsl:stylesheet>
这个的输出是
<OrderLine EnterpriseCode="BRD"
ReleaseNo="1234ABC"
DocumentType="0001"
SellerOrganizationCode="BU1"
ShipNode="US1"
OrderDate="2019-06-13T09:27:36-04:00"
Action="CANCEL"
OrderNo="1234ABC"
ExtnWMSOrderNumber="123ADS"
PrimeLineNo="3"
SubLineNo="1"
OrderedQty="0"/>
1条答案
按热度按时间gc0ot86w1#
你可以这样做。
看到它在这里工作了吗:https://xsltfiddle.liberty-development.net/93nwmog