如何在xslt中减去值? [英] How to subtract value in xslt?

查看:121
本文介绍了如何在xslt中减去值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您告诉我如何使用变量在xslt中减去值?

Could you please tell me how to subtract value in xslt using a variable?

这是我的代码:

<xsl:variable name="currentCurpg" select="1"/>
<xsl:variable name="tCurpg" select="($currentCurpg-1)"/>

变量tCurpg应该为zero0.

为什么我会出错?

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

    <xsl:template match="/">
      <hmtl>
        <head>
          <title>New Version!</title>
        </head>
         <xsl:variable name="currentCurpg" select="1"/>
          <xsl:variable name="tCurpg" select="($currentCurpg-1)"/>
     <xsl:value-of select="$tCurpg"/>

      </hmtl>
    </xsl:template>


</xsl:transform>

我希望输出为zero.

推荐答案

问题在于连字符在变量名中有效,所以当您这样做时...

The problem is that hyphens are valid in variable names, so when you do this...

<xsl:variable name="tCurpg" select="($currentCurpg-1)"/>

它实际上是在寻找一个名为currentCurpg-1的变量.

It is literally looking for a variable named currentCurpg-1.

改为将其更改为此...

Instead change it to this...

<xsl:variable name="tCurpg" select="$currentCurpg - 1"/>

这篇关于如何在xslt中减去值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆