Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml Globale变量在XSLT中使用并递增该变量值_Xml_Xslt_Xslt 1.0_Xslt 2.0 - Fatal编程技术网

Xml Globale变量在XSLT中使用并递增该变量值

Xml Globale变量在XSLT中使用并递增该变量值,xml,xslt,xslt-1.0,xslt-2.0,Xml,Xslt,Xslt 1.0,Xslt 2.0,嗨,我搜索每一个我找不到任何答案或解决方案的地方,我需要这样做的方式;我的要求是我有这样的XML <mail> <hotel> <name>asd</name> <cost>50</cost> </hotel> <hotel> <name>sdesd</name>

嗨,我搜索每一个我找不到任何答案或解决方案的地方,我需要这样做的方式;我的要求是我有这样的XML

 <mail>
     <hotel>
           <name>asd</name>
           <cost>50</cost>
     </hotel>
      <hotel>
           <name>sdesd</name>
           <cost>60</cost>
     </hotel>
    <totalcost>170</totalcost>
 </mail>
<xsl:template match="/">
   <html>
      <xsl:for-each select="mail/hotel">
        <tr>HOTEL NAME : <xsl:valueof select="name"></tr>
        <tr>COST <xsl:valueof select="cost"></tr>
      </xsl:for-each>
        <tr>TOTAL COST WITH TAX <xsl:valueof select="mail/totalcost"></tr>
        <tr>TAX <b><xsl:valueof select="_____"></b></tr> (for this place I want to calculate cost values comeing under hotel child and set)   
   </html>
</xsl:template>

自闭症
50
sdesd
60
170
我有这样的XSLT文件

 <mail>
     <hotel>
           <name>asd</name>
           <cost>50</cost>
     </hotel>
      <hotel>
           <name>sdesd</name>
           <cost>60</cost>
     </hotel>
    <totalcost>170</totalcost>
 </mail>
<xsl:template match="/">
   <html>
      <xsl:for-each select="mail/hotel">
        <tr>HOTEL NAME : <xsl:valueof select="name"></tr>
        <tr>COST <xsl:valueof select="cost"></tr>
      </xsl:for-each>
        <tr>TOTAL COST WITH TAX <xsl:valueof select="mail/totalcost"></tr>
        <tr>TAX <b><xsl:valueof select="_____"></b></tr> (for this place I want to calculate cost values comeing under hotel child and set)   
   </html>
</xsl:template>

酒店名称:
成本
含税总成本
税(对于这个地方,我想计算酒店子项和集合项下的成本值)
就像在java中一样,我们初始化globe变量并在for循环中设置增量值,然后使用循环的最终输出端,在这个XSLT中如何做到这一点?

变量在XSLT中是“值”,您只能设置一次

对于常见的操作,请查找语言操作,例如sum(),对于您的示例来说,这些操作应该很好

如果您需要更复杂的东西,可以使用带有变量的模板递归调用

例如


0

如果要计算总和,请使用例如

这是如何增加ryhgt的?我需要一些全局变量来赋值,比如java“class ASD{public a=0.0;for(loop){a=somevalue+a;}sysout(a+”);}如果用条件替换示例中的ifs,用操作替换+1,应该可以。其他一些解决方案找到了buddy..thnx很多帮助:)