微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我有一个 XSLT,其中有 2 个不同的案例,并且由于多个项目循环,我没有得到所需的输出

如何解决我有一个 XSLT,其中有 2 个不同的案例,并且由于多个项目循环,我没有得到所需的输出

在我的 XSLT 中,我正在检查 oa:ShipUnitQuantity 是否小于 1,在这种情况下我的输出应该是 FLOW_856MMO;当 oa:ShipUnitQuantity 大于 1 且 oa:DocumentReference/@type='ManualMarkout' 时,我的输出应该是 FLOW_856PARMMO 其余的都应该转到 FLOW_856NONMMO

由于多个 us:ShipmentUnit 循环,我无法获得 FLOW_856PARMMO 输出

我的输入:

<us:ShowShipment releaseID="1.0" systemEnvironmentCode="Production" languageCode="en-US">
    <us:DataArea>
        <oa:Show/>
        <us:Shipment>
            <us:ShipmentHeader>
                <oa:DocumentID>
                    <oa:ID>63210223S000003</oa:ID>
                </oa:DocumentID>
            </us:ShipmentHeader>
            <us:ShipmentOrder>
                <us:ShipmentHeader>
                    <oa:DocumentReference type="OMSOrderInfo">
                        <oa:SalesOrderReference>
                            <oa:DocumentID>
                                <oa:ID>BFDKK7J</oa:ID>
                            </oa:DocumentID>
                            <oa:ReleaseNumber>2</oa:ReleaseNumber>
                        </oa:SalesOrderReference>
                    </oa:DocumentReference>
                    <oa:ShipUnitQuantity>3</oa:ShipUnitQuantity>
                </us:ShipmentHeader>
                <us:ShipmentUnit>
                    <us:ShipCode>Y</us:ShipCode>
                    <us:COdamount currencyID="USD">0</us:COdamount>
                    <us:ShipmentUnitItem>
                        <oa:UPCID>00000000000001</oa:UPCID>
                    </us:ShipmentUnitItem>
                    <us:ShipmentUnitItem>
                        <oa:UPCID>00000000000003</oa:UPCID>
                        <oa:DocumentReference type="ManualMarkout">
                            <oa:Status>
                                <oa:Code>MM,24</oa:Code>
                            </oa:Status>
                        </oa:DocumentReference>
                </us:ShipmentUnit>
                <us:ShipmentUnit>
                    <us:ShipCode>Y</us:ShipCode>
                    <us:COdamount currencyID="USD">0</us:COdamount>
                    <us:ShipmentUnitItem>
                        <oa:UPCID >00000000000004</oa:UPCID>
                    </us:ShipmentUnitItem>
                </us:ShipmentUnit>
            </us:ShipmentOrder>
        </us:Shipment>
    </us:DataArea>
</us:ShowShipment>

我的 XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:us='http://www.ussco.com/oagis/0' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:oa='http://www.openapplications.org/oagis/9' version="1.0">
    <!-- <xsl:strip-space elements="*"/> -->
    <xsl:output method="xml" indent="yes" media-type="text/xml" omit-xml-declaration="no" encoding="utf-8"/>
    <xsl:param name="lineDelimiter" select="'&#10;'"/>
    <!-- -->
    <!--  -->
<!--<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
</xsl:template> -->

<xsl:template match="node()|@*">
<xsl:element name="OUTPUT">
  <xsl:element name="Flag_ind">
        <xsl:choose>
            <xsl:when test="(/us:ShowShipment/us:DataArea/us:Shipment/us:ShipmentOrder/us:ShipmentHeader/oa:ShipUnitQuantity) &lt; 1">
                <xsl:value-of select="'FLOW_856MMO'"/>
            </xsl:when>
            <xsl:when test="(/us:ShowShipment/us:DataArea/us:Shipment/us:ShipmentOrder/us:ShipmentHeader/oa:ShipUnitQuantity) &gt; 1 and (/us:ShowShipment/us:DataArea/us:Shipment/us:ShipmentOrder/us:ShipmentUnit/us:ShipmentUnitItem/oa:DocumentReference[@type='ManualMarkout'])">
                <xsl:value-of select="'FLOW_856PARMMO'"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="'FLOW_856NONMMO'"/>
            </xsl:otherwise>
        </xsl:choose>
  </xsl:element>
  </xsl:element>
</xsl:template> 
</xsl:stylesheet>

我的输出:这应该是 FLOW_856PARMMO,但逻辑会遇到其他情况。

<?xml version="1.0" encoding="utf-8"?>
<OUTPUT>
    <Flag_ind>FLOW_856NONMMO</Flag_ind>
</OUTPUT>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。