每次我尝试做类似的事情时:
<xsl:value-of select="wd:XMLNAME_57-Payment_Deducted+preceding-sibling::wd:Result_Lines/wd:XMLNAME_57-Payment_Deducted"></xsl:value-of>
我在氧气中发现了一个错误,说明了......的效果。
Description: XPTY0004: A sequence of more than one item is not allowed as the second operand of '+'
我尝试将每种情况转换为变量,然后在add函数中调用变量并尝试创建序列。似乎没有什么工作:
<xsl:variable name="child_support" select="preceding-sibling::wd:Result_Lines/wd:XMLNAME_57-Payment_Deducted[position()=1]"></xsl:variable>
<xsl:value-of select="sum(wd:XMLNAME_57-Payment_Deducted+(concat($child_support, '')))"></xsl:value-of>
<xsl:sequence select="format-number(preceding-sibling::wd:Result_Lines/wd:XMLNAME_57-Payment_Deducted+wd:XMLNAME_57-Payment_Deducted, '#')"></xsl:sequence>
这是类似于我试图为添加运算符调用的xml:
<?xml version='1.0' encoding='UTF-8'?>
<wd:Report_Data xmlns:wd="urn:com.workday.report/CR-INT034-ADP-Garnishment_Disbursements_File-Outbound2">
<wd:Report_Entry>
<wd:Result_Lines>
<wd:XMLNAME_57-Payment_Deducted>2</wd:XMLNAME_57-Payment_Deducted>
</wd:Result_Lines>
<wd:Result_Lines>
<wd:XMLNAME_57-Payment_Deducted>276.92</wd:XMLNAME_57-Payment_Deducted>
</wd:Result_Lines>
</wd:Report_Entry>
</wd:Report_Data>
我错过了什么?如果我创建了一个xslt函数那会有用吗? XSLT函数不是我以前创建过的。
我可以帮助找出问题所在。
谢谢, 萨拉
答案 0 :(得分:0)
这个怎么样:
<xsl:value-of select="sum(wd:XMLNAME_57-Payment_Deducted |
preceding-sibling::wd:Result_Lines/
wd:XMLNAME_57-Payment_Deducted)" />
或者更清洁一点:
<xsl:variable name="thisAndPreceding"
select=". | preceding-sibling::wd:Result_Lines" />
<xsl:value-of select="sum($thisAndPreceding/wd:XMLNAME_57-Payment_Deducted)" />