在下面的输入中,我们必须检查供应商代码是否与任何节点供应商代码匹配,然后我们必须对数量执行求和操作。否则直接映射数量。
输入:
<Move-Afile>
<Afile>
<Item>
<suppliercode>1</suppliercode>
<PackNumber>1234</PackNumber>
<Quantity>12</Quantity>
</Item>
<Item>
<suppliercode>2</suppliercode>
<PackNumber>567</PackNumber>
<Quantity>3</Quantity>
</Item>
<Item>
<suppliercode>1</suppliercode>
<PackNumber>567</PackNumber>
<Quantity>8</Quantity>
</Item>
<Item>
<suppliercode>3</suppliercode>
<PackNumber>126</PackNumber>
<Quantity>11</Quantity>
</Item>
<Item>
<suppliercode>4</suppliercode>
<PackNumber>876</PackNumber>
<Quantity>32</Quantity>
</Item>
</Afile>
</Move-Afile>
如果供应商代码相等,则对数量进行求和运算,否则直接映射数量。
输出:
<A>
<target>
<Item>
<suppliercode>1</suppliercode>
<PackNumber>1234</PackNumber>
<Quantity>20</Quantity>
</Item>
<Item>
<suppliercode>2</suppliercode>
<PackNumber>567</PackNumber>
<Quantity>3</Quantity>
</Item>
<Item>
<suppliercode>1</suppliercode>
<PackNumber>567</PackNumber>
<Quantity>20</Quantity>
</Item>
<Item>
<suppliercode>3</suppliercode>
<PackNumber>126</PackNumber>
<Quantity>11</Quantity>
</Item>
<Item>
<suppliercode>4</suppliercode>
<PackNumber>876</PackNumber>
<Quantity>32</Quantity>
</Item>
</target>
</A>
我需要一个单独的临时变量中的求和逻辑,如下所示。
<varaible name=tempvar>
<xsl:choose>
<xsl:when suppliercode=suppliercode>
<xsl:value-of select=sum(quntity)/>
<xsl:when>
<xsl:otherwise>
<xsl:value-of select=quntity/>
</xsl:otherwise>
</xsl:choose>
</variable>