title: How to store dynamically values in array using XSLT and make comparision of values?
body: <p>I am again providing you the requirement like this.
  Could you please look into this?</p>
  
  <pre><code>&lt;xml&gt;
  &lt;test&gt;
  &lt;BookID&gt;
    &lt;BookID1&gt;
      &lt;BookID2&gt;
        0061AB
      &lt;/BookID2&gt;
    &lt;/BookID1&gt;
  &lt;/BookID&gt;
  &lt;amount&gt;
    16
  &lt;/amount&gt;
  &lt;/test&gt;
  &lt;test&gt;
  &lt;BookID&gt;
    &lt;BookID1&gt;
      &lt;BookID2&gt;
        0062CD
      &lt;/BookID2&gt;
    &lt;/BookID1&gt;
  &lt;/BookID&gt;
  &lt;amount&gt;
    2
  &lt;/amount&gt;
  &lt;/test&gt;
  &lt;test&gt;
  &lt;BookID&gt;
    &lt;BookID1&gt;
      &lt;BookID2&gt;
        0061AB
      &lt;/BookID2&gt;
    &lt;/BookID1&gt;
  &lt;/BookID&gt;
  &lt;amount&gt;
    2
  &lt;/amount&gt;
  &lt;/test&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>here According to the equal value of BookID, I want to add the amount value.....like for above example, if value of BookID is 0061AB, then the value of amount should be 18.</p>
  
  <p><strong>Edit</strong> (Pasted to Answer)</p>
  
  <p><em>Output should be like this</em></p>
  
  <pre><code>&lt;xml&gt;
    &lt;test&gt;
      &lt;BookID&gt;
        &lt;BookID1&gt;
          &lt;BookID2&gt;
            0061AB
          &lt;/BookID2&gt;
        &lt;BookID1&gt;
      &lt;/BookID&gt;
      &lt;amount&gt;
        18
      &lt;/amount&gt;
    &lt;/test&gt;
    &lt;test&gt;
      &lt;BookID&gt;
        &lt;BookID1&gt;
          &lt;BookID2&gt;
            0062CD
          &lt;/BookID2&gt;
        &lt;BookID1&gt;
      &lt;/BookID&gt;
      &lt;amount&gt;
        2
      &lt;/amount&gt;
    &lt;/test&gt;
  &lt;/xml&gt;
  </code></pre>