BizTalk映射:xslt 1.0 sum“无法将类型'string'隐式转换为'int'”

时间:2019-03-08 20:18:54

标签: xslt-1.0 biztalk-2013

获取错误:

  

无法将类型'string'隐式转换为'int'

关于此代码:

<TotalInvoiceCost>
    <xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>

然后尝试了这个:

   <TotalInvoiceCost>
      <xsl:value-of select="sum(number(//*[local-name()='InvoiceTotal']))" />
   </TotalInvoiceCost>

但出现此错误:

  

函数'sum()'的参数1无法转换为节点集。

减少具有结构的样本数据(所有值都是数字):

<TAR210 xmlns="demo">
    <DummyHeaderGroup xmlns=""/>
    <Invoice xmlns="">
        <Level1>
            <InvoiceTotal>1075</InvoiceTotal>
        </Level1>
        <Level1>
            <InvoiceTotal>595</InvoiceTotal>
        </Level1>
    </Invoice>
</TAR210>

http://www.xpathtester.com/xpath中,此方法工作正常:

  

sum(// * [local-name()=“ InvoiceTotal”])

上下文中的XSLT示例:

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
  exclude-result-prefixes="msxsl var userCSharp" version="1.0"
  xmlns:ns0="demo"
  xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

  <xsl:template match="/">
    <ns0:TAR210>
      <DummyHeaderGroup>
        <Level0>
          <TotalInvoiceCost>
            <xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
          </TotalInvoiceCost>
        </Level0>
      </DummyHeaderGroup>
    </ns0:TAR210>
  </xsl:template>

</xsl:stylesheet>

0 个答案:

没有答案