Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
如何使用XSLT显示这个HTML输出:1+3+4+17+8+15=48。。?_Html_Xml_Xslt_Xpath - Fatal编程技术网

如何使用XSLT显示这个HTML输出:1+3+4+17+8+15=48。。?

如何使用XSLT显示这个HTML输出:1+3+4+17+8+15=48。。?,html,xml,xslt,xpath,Html,Xml,Xslt,Xpath,我需要知道如何在样式表中使用xPath的数值函数来显示HTML输出: 1+3+4+17+8+15=48 样式表需要使用数字函数、位置以及测试和条件语句来表示HTML输出 这是xml数据: <account> <number>1</number> <number>3</number> <number>4</number> <number>17</number>

我需要知道如何在样式表中使用xPath的数值函数来显示HTML输出:

1+3+4+17+8+15=48

样式表需要使用数字函数、位置以及测试和条件语句来表示HTML输出

这是xml数据:

<account>
   <number>1</number>
   <number>3</number>
   <number>4</number>
   <number>17</number>
   <number>8</number>
   <number>15</number>
</account>
到目前为止,这是我在.xsl中的全部内容。。它只显示了48的总和

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:value-of select='sum(//number)'/>
    </xsl:template>
</xsl:stylesheet>
任何帮助都将不胜感激

谢谢,


肖恩

像这样的东西会有用的

XSLT1.0


像这样的东西会有用的

XSLT1.0


在XSLT 2.0中,这几乎是一行:

<xsl:template match="account">
  <xsl:value-of select="string-join(number, ' + '), '=', sum(number)"/>
</xsl:template>
哦,你说你需要使用位置。如果您认为您将因不使用该职位而被取消资格,则您可以将其更改为:

<xsl:template match="account">
  <xsl:value-of select="string-join(number, ' + '), '=', sum(number)*position()"/>
</xsl:template> 

但是你可能会因为嘲笑法官的愚蠢而被取消资格。

在XSLT 2.0中,这几乎是一行:

<xsl:template match="account">
  <xsl:value-of select="string-join(number, ' + '), '=', sum(number)"/>
</xsl:template>
哦,你说你需要使用位置。如果您认为您将因不使用该职位而被取消资格,则您可以将其更改为:

<xsl:template match="account">
  <xsl:value-of select="string-join(number, ' + '), '=', sum(number)*position()"/>
</xsl:template> 

但是你可能会因为嘲笑法官的愚蠢而被取消资格。

这听起来像是家庭作业。你试过什么了?这是为下周的考试做准备。上述问题是在去年的测试中提出的;这听起来像是家庭作业。你试过什么了?这是为下周的考试做准备。上述问题是在去年的测试中提出的;
<xsl:template match="account">
  <xsl:value-of select="string-join(number, ' + '), '=', sum(number)*position()"/>
</xsl:template>