XSLT乘法问题

时间:2017-03-03 02:19:50

标签: xslt

我试图将数字乘以XSLT,但结果不正确。 不知道为什么会这样发生。

XML输入:

<jdeResponse xmlns="http://www.schemas.e1.oracle.com" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/jms/GWI/PurchaseOrdersFromE1/ser_jms_ConsumePOFromE1" xmlns:pc="http://xmlns.oracle.com/pcbpel/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:ns0="http://www.schemas.e1.oracle.com" xmlns:sch="http://www.schemas.e1.oracle.com" pwd="" token="" role="*ALL" type="realTimeEvent" category="RTE" user="C-SPATIL" session="8aa5b38" environment="JPY900" responseCreator="XAPI" InterfaceIdentifier="AFFYMETRIX" E1UpdateFlag="Y">
    <ns0:event>            
        <ns0:body elementCount="8">
            <ns0:detail_D4302470B date="03022017" name="R43500 - PurchaseOrderPrint" time="17:58:38" type="RTPODTL" DSTMPL="D4302470B" executionOrder="4" parameterCount="154">
                <ns0:mnOrderLineNumber>2.010</ns0:mnOrderLineNumber>
            </ns0:detail_D4302470B>
        </ns0:body>
    </ns0:event>
</jdeResponse>

XSLT:

    <?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
                xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                xmlns:oraxsl="http://www.oracle.com/XSL/Transform/java" xmlns:ns0="http://www.schemas.e1.oracle.com"
                xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas"
                xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:cst="http://www.oracle.com/XSL/Transform/java/searchandreplacestring.SearchAndReplaceString"
                xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/top/ref_DB_F47012"
                xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
                xmlns:ns1="http://www.Thermofisher.com/ofm/schema/ProcessPOFromLSGE1ToTargetE1/"
                exclude-result-prefixes="xsi oracle-xsl-mapper xsl xsd ns0 ns1 tns xp20 oraxsl mhdr oraext dvm xref cst socket"
                xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/jms/GWI/ProcessPOFromLSGE1ToTargetE1/ser_jms_getPO"
                xmlns:pc="http://xmlns.oracle.com/pcbpel/" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
                xmlns:ns3="http://www.Thermofisher.com/ofm/ProcessPOFromLSGE1ToTargetE1BPEL/schema/v1.0/"
                xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                xmlns:ns4="http://xmlns.oracle.com/pcbpel/adapter/db/LSG_AFFY/ProcessPOFromLSGE1ToTargetE1/ref_DB_F47012"
                xmlns:ns5="http://www.themofisher.com/ofm/otc/ProcessPOFromLSGE1ToTargetE1/schema"
                xmlns:ns6="http://www.thermofisher.com/ofm/ProcessPOFromLSGE1ToTargetE1/temp_SalesOrderDetailAttachmentManager">

  <xsl:template match="/">
    <tns:F47012Collection>
      <xsl:for-each select="/ns0:jdeResponse/ns0:event/ns0:body/ns0:detail_D4302470B">
        <tns:F47012>
           <tns:szrlln>
            <xsl:value-of select="normalize-space(ns0:mnOrderLineNumber)*1000"/>
          </tns:szrlln> 
        </tns:F47012>
      </xsl:for-each>
    </tns:F47012Collection>
  </xsl:template>
</xsl:stylesheet>

输出:

<?xml version="1.0" encoding="UTF-8"?>
<tns:F47012Collection xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/jms/GWI/ProcessPOFromLSGE1ToTargetE1/ser_jms_getPO" xmlns:pc="http://xmlns.oracle.com/pcbpel/" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:ns3="http://www.Thermofisher.com/ofm/ProcessPOFromLSGE1ToTargetE1BPEL/schema/v1.0/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns4="http://xmlns.oracle.com/pcbpel/adapter/db/LSG_AFFY/ProcessPOFromLSGE1ToTargetE1/ref_DB_F47012" xmlns:ns5="http://www.themofisher.com/ofm/otc/ProcessPOFromLSGE1ToTargetE1/schema" xmlns:ns6="http://www.thermofisher.com/ofm/ProcessPOFromLSGE1ToTargetE1/temp_SalesOrderDetailAttachmentManager" xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/top/ref_DB_F47012"><tns:F47012>
    <tns:szrlln>2009.9999999999998</tns:szrlln>
  </tns:F47012>
</tns:F47012Collection>

输出应为

2010

请建议。

............................................... .................................................. ......................................

由于 亚坦

1 个答案:

答案 0 :(得分:1)

如果XSLT 2.0是您的选项,您可以使用十进制算术:

...
<xsl:value-of select="xs:decimal(ns0:mnOrderLineNumber)*xs:decimal(1000)"/>
...

在XSLT 1.0中,您可以使用format-number

<xsl:value-of select="format-number(ns0:mnOrderLineNumber * 1000, '0.##')"/>

更多信息in this answer