嗨,我有两个带逗号的值,我想知道这两个值之间的区别。(例如: 10,35 - 9,33)
<xsl:template name="getUPEDifferenz">
<xsl:param name="preisHersteller" />
<xsl:param name="preisDokument" />
<xsl:choose>
<xsl:when test="($preisDokument != '' and $preisDokument != 0) and ($preisHersteller != '' and $preisHersteller != 0)">
<xsl:value-of select="$preisDokument - $preisHersteller" />
</xsl:when>
<xsl:otherwise>
<xsl:text>nicht angegeben</xsl:text>
</xsl:otherwise>
</xsl:choose>
<fo:table-cell padding="5px" border-style="solid" border-width="0.5pt" text-align="right">
<fo:block font-size="10px" font-weight="normal">
<xsl:if test="boolean(Listenpreis)">
<xsl:call-template name="getUPEDifferenz">
<xsl:with-param name="preisDokument" select="format-number(string(Gesamtpreis), '###.##0,00', 'european')" />
<xsl:with-param name="preisHersteller" select="format-number(string(Basispreis), '###.##0,00', 'european')" />
</xsl:call-template>
</xsl:if>
</fo:block>
</fo:table-cell>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Haus>
<Teile>
<Position Nummer="1">
<Benennung>Das Haus 1</Benennung>
<Gesamtpreis>27.65</Gesamtpreis>
<Basispreis>24.04</Basispreis>
</Position>
<Position Nummer="2">
<Benennung>Das Haus 2</Benennung>
<Gesamtpreis>27.65</Gesamtpreis>
<Basispreis>24.04</Basispreis>
</Position>
<Position Nummer="3">
<Benennung>Das Haus 3</Benennung>
<Gesamtpreis>133.29</Gesamtpreis>
<Basispreis>115.9</Basispreis>
</Position>
</Teile>
</Haus>
</Root>这是给定的代码。xml文件本身和xsl文件。但结果我得到了“NaN”。有人能帮忙吗?我想得到Gesamtpreis和Basispreis对于每个Position的区别。
发布于 2017-03-22 10:29:26
试着改变这个部分:
<xsl:call-template name="getUPEDifferenz">
<xsl:with-param name="preisDokument" select="format-number(string(Gesamtpreis), '###.##0,00', 'european')" />
<xsl:with-param name="preisHersteller" select="format-number(string(Basispreis), '###.##0,00', 'european')" />
</xsl:call-template> 至:
<xsl:call-template name="getUPEDifferenz">
<xsl:with-param name="preisDokument" select="Gesamtpreis" />
<xsl:with-param name="preisHersteller" select="Basispreis" />
</xsl:call-template>然后改变:
<xsl:value-of select="$preisDokument - $preisHersteller" />至:
<xsl:value-of select="format-number($preisDokument - $preisHersteller, '#.##0,00', 'european')" />这里的想法是使用原始值执行减法,而小数分隔符仍然是一个句号--这是XML允许的唯一十进制分隔符。
未经过测试,因为还没有提供完整的示例。
https://stackoverflow.com/questions/42948111
复制相似问题