Note that there are some explanatory texts on larger screens.

plurals
  1. POPerform SUM operation in XSLT
    primarykey
    data
    text
    <p>In the below input we have to check the supplier code if it is match to any of the node supplier code then we have to perform sum operation on Quantity.otherwise directly map the quantity.</p> <p>input:</p> <pre><code>&lt;Move-Afile&gt; &lt;Afile&gt; &lt;Item&gt; &lt;suppliercode&gt;1&lt;/suppliercode&gt; &lt;PackNumber&gt;1234&lt;/PackNumber&gt; &lt;Quantity&gt;12&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;2&lt;/suppliercode&gt; &lt;PackNumber&gt;567&lt;/PackNumber&gt; &lt;Quantity&gt;3&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;1&lt;/suppliercode&gt; &lt;PackNumber&gt;567&lt;/PackNumber&gt; &lt;Quantity&gt;8&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;3&lt;/suppliercode&gt; &lt;PackNumber&gt;126&lt;/PackNumber&gt; &lt;Quantity&gt;11&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;4&lt;/suppliercode&gt; &lt;PackNumber&gt;876&lt;/PackNumber&gt; &lt;Quantity&gt;32&lt;/Quantity&gt; &lt;/Item&gt; &lt;/Afile&gt; &lt;/Move-Afile&gt; </code></pre> <p>If supplier code is equal then perform sum operation on Quantity,otherwise directly map the Quantity.</p> <p>output:</p> <pre><code>&lt;A&gt; &lt;target&gt; &lt;Item&gt; &lt;suppliercode&gt;1&lt;/suppliercode&gt; &lt;PackNumber&gt;1234&lt;/PackNumber&gt; &lt;Quantity&gt;20&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;2&lt;/suppliercode&gt; &lt;PackNumber&gt;567&lt;/PackNumber&gt; &lt;Quantity&gt;3&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;1&lt;/suppliercode&gt; &lt;PackNumber&gt;567&lt;/PackNumber&gt; &lt;Quantity&gt;20&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;3&lt;/suppliercode&gt; &lt;PackNumber&gt;126&lt;/PackNumber&gt; &lt;Quantity&gt;11&lt;/Quantity&gt; &lt;/Item&gt; &lt;Item&gt; &lt;suppliercode&gt;4&lt;/suppliercode&gt; &lt;PackNumber&gt;876&lt;/PackNumber&gt; &lt;Quantity&gt;32&lt;/Quantity&gt; &lt;/Item&gt; &lt;/target&gt; &lt;/A&gt; </code></pre> <p>i need the sum logic in a separate temporary variable like below.</p> <pre><code>&lt;varaible name=tempvar&gt; &lt;xsl:choose&gt; &lt;xsl:when suppliercode=suppliercode&gt; &lt;xsl:value-of select=sum(quntity)/&gt; &lt;xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select=quntity/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/variable&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload