我有问题。我想要的是对对象求和并为每次迭代打印它们。我是 XSLT 的新手,所以请善待。我所拥有的是这段代码:
<?xml version = "1.0" encoding = "Windows-1252"?>
<GPDUMP>
<ROUTE>
<ALL_ROUTEANDORDER>
<NUMBER>3</NUMBER>
<NO0>
<ROUTEANDORDER>
<FKCUSTOMERID>2</FKCUSTOMERID>
<SEQUENCENO>1</SEQUENCENO>
<STOPNO>1</STOPNO>
<SPLITKMDRIVING>13076</SPLITKMDRIVING>
</ROUTEANDORDER>
</NO0>
<NO1>
<ROUTEANDORDER>
<FKCUSTOMERID>4</FKCUSTOMERID>
<SEQUENCENO>2</SEQUENCENO>
<STOPNO>2</STOPNO>
<SPLITKMDRIVING>6204</SPLITKMDRIVING>
</ROUTEANDORDER>
</NO1>
<NO2>
<ROUTEANDORDER>
<FKCUSTOMERID>3</FKCUSTOMERID>
<SEQUENCENO>3</SEQUENCENO>
<STOPNO>3</STOPNO>
<SPLITKMDRIVING>4775</SPLITKMDRIVING>
</ROUTEANDORDER>
</NO2>
</ALL_ROUTEANDORDER>
</ROUTE>
</GPDUMP>
我想要的输出是这样的:
<CUSTOMERID>2</CUSTOMERID>
<DIST_FROM_PREVIOUS>13076</DIST_FROM_PREVIOUS>
<DIST_FROM_START>13076</DIST_FROM_START>
<CUSTOMERID>4</CUSTOMERID>
<DIST_FROM_PREVIOUS>6204</DIST_FROM_PREVIOUS>
<DIST_FROM_START>13076 + 6204</DIST_FROM_START>
<CUSTOMERID>3</CUSTOMERID>
<DIST_FROM_PREVIOUS>4775</DIST_FROM_PREVIOUS>
<DIST_FROM_START>13076 + 6204 + 4775</DIST_FROM_START>
如您所见,DIST_FROM_START
应该按照以下过程求和。
我所拥有的是:
<xsl:for-each select="ALL_ROUTEANDORDER[1]/*[$index]" >
<xsl:variable name="kmFromStart" select="sum(ALL_ROUTEANDORDER/*[starts-with(name(),'NO')]/ROUTEANDORDER/SPLITKMDRIVING)"/>
<xsl:variable name="kmFromPrevious" select="ALL_ROUTEANDORDER/*[starts-with(name(),'NO')]/ROUTEANDORDER/SPLITKMDRIVING"/>
<xsl:text>From start</xsl:text><xsl:value-of select="$kmFromStart" />
<xsl:text>From previous </xsl:text><xsl:value-of select="$kmFromPrevious" />
</xsl:for-each>
希望有人能理解我的想法,并可以帮助我!我用谷歌搜索了几页,也尝试了没有运气的参数。我真的很想让这个工作!任何帮助都将不胜感激!谢谢 :)