我有这个XML文件,其中有这些节点:
<Rows>
<Row type="Comment">
<Amount>0.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Comment">
<Amount>0.00</Amount>
</Row>
<Row type="Spec">
<Amount>20.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>20.00</Amount>
</Row>
</Rows>
结果应为:评论:30评论:50
这些规范行将始终排在注释行之后。我需要对“注释”行之后的那些“规范”行进行求和。
我试图在XSLT 1.0中使用Preceeding and Follow函数,但无法正常工作:
<xsl:value-of select="sum(../Row[@type='Spec']/Amount][following-sibling::row[1][@type='comment']])"/>
有人可以帮忙吗?