0
要素の値の合計:XSL - 私は1つの<code>XML</code>ファイルを持っている
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<File>
<Cars>
<Car>
<Color>Blue</Color>
<Year>1988</Year>
<Quantity>150</Quantity>
</Car>
<Car>
<Color>Green</Color>
<Year>1989</Year>
<Quantity>200</Quantity>
</Car>
</Cars>
</File>
そして1つのXSL
ファイル:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8" media-type="text/xml"/>
<xsl:template match="File">
<File>
<vehicles>
<xsl:for-each select="Cars/Car">
<vehicle>
<vehicleColor>
<xsl:value-of select="Color"/>
</vehicleColor>
<vehicleYear>
<xsl:value-of select="Year"/>
</vehicleYear>
</vehicle>
</xsl:for-each>
</vehicles>
<TotalQuantity>
<xsl:value-of select="sum()"/> ///// Sum of quantity of all car (<Quantity>)
</TotalQuantity>
</File>
</xsl:template>
</xsl:stylesheet>
が、私は、各車とディスプレイの全ての量の合計を作りたいです結果は要素TotalQuantity
になります。 sum()メソッドには何を入れますか?
私はXSL
1.0のみを使用します。私はあなたの現在のノードがFile
あるので、私のXML
XslCompiledTransform
を持つクラスは#
非常に簡単です...ありがとうございます! –
XSL 1.0ではすべてのXPath機能を利用できますか? http://www.tutorialspoint.com/xpath/index.htm軸、演算子、ワイルドカード、述語など –
すべてのXPath 1.0の機能は、公式ドキュメントに記載されています:https://www.w3.org/TR/xpath/ #contents –