title: Please guide me for the muenchian grouping based on attribute value using xslt1.0
body: <p>I want to group the element using muenchian grouping  . I am using xslt 1.0 Could you pleae guide me..</p>
  
  <p>xml is like below..</p>
  
  <pre><code>&lt;responseDA xmlns:tem="http://tempuri.org"&gt;
  &lt;outputData&gt;   
  &lt;dictionary id="AutoOutputs"&gt; 
  
  &lt;list numOfItems="2"&gt;       
  &lt;item&gt;       
  &lt;field dataType="double" name="DOWNPAYMENT"&gt;2000.00&lt;/field&gt;
  &lt;/item&gt;     
  &lt;item&gt;       
  &lt;field dataType="double" name="DOWNPAYMENT"&gt;3000.00&lt;/field&gt;
  &lt;/item&gt;
  &lt;/list&gt;  
  &lt;list numOfItems="2"&gt;       
  &lt;item&gt;       
  &lt;field dataType="string" name="CAMPAIGNCODE"&gt;A&lt;/field&gt;\
  &lt;/item&gt;
  &lt;item&gt;       
  &lt;field dataType="string" name="CAMPAIGNCODE"&gt;B&lt;/field&gt;
  &lt;/item&gt;
  &lt;/list&gt;   
  &lt;list numOfItems="2"&gt;       
  &lt;item&gt;      
  &lt;field dataType="double" name="BALLOONPAYMENT"&gt;4000.00&lt;/field&gt;
  &lt;/item&gt;
  &lt;item&gt;       
  &lt;field dataType="double" name="BALLOONPAYMENT"&gt;5000.00&lt;/field&gt;
  &lt;/item&gt;
  &lt;/list&gt;       
  &lt;/dictionary&gt;
  &lt;/outputData&gt;
  &lt;/responseDA&gt;
  </code></pre>
  
  <p>Now I need to group the campaign based on the "numofitems" in the attribute of list.
  Output should be..   </p>
  
  <pre><code> &lt;Campaigns&gt;
      &lt;campaignNumber&gt;A&lt;/ns:campaignNumber&gt;
      &lt;downPayment&gt;2000.00&lt;/ns:downPayment&gt;
      &lt;ballonPayment&gt;4000.00&lt;/ns:ballonPayment&gt;
      &lt;/Campaigns&gt;
      &lt;Campaigns&gt;
      &lt;campaignNumber&gt;B&lt;/ns:campaignNumber&gt;
      &lt;downPayment&gt;3000.00&lt;/ns:downPayment&gt;
      &lt;ballonPayment&gt;5000.00&lt;/ns:ballonPayment&gt;
      &lt;/Campaigns&gt; 
  </code></pre>
  
  <p>I have tried but it is not working...</p>
  
  <pre><code>&lt;xsl:template match="/"&gt;
  &lt;xsl:apply-templates select="responseDA" /&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:key name="camp" match="//list/@numOfItems" use="field" /&gt;
  
  &lt;xsl:template match="responseDA"&gt;       
  &lt;xsl:for-each  select="list/@numOfItems[generate-id(.)=generate-id(key(&amp;apos;camp&amp;apos;,field)[1])]"&gt;
  &lt;Campaigns&gt;
  &lt;campaignNumber&gt;
  &lt;xsl:value-of select="item/field[@name=&amp;apos;CAMPAIGNCODE&amp;apos;]" /&gt;
  &lt;/campaignNumber&gt;
  &lt;xsl:for-each xmltem="http://tempuri.org" select="key(&amp;apos;camp&amp;apos;,field)"&gt;
  &lt;downPayment&gt;
  &lt;xsl:value-of select="item/field[@name=&amp;apos;DOWNPAYMENT&amp;apos;]" /&gt;
  &lt;/downPayment&gt;
  &lt;ballonPayment&gt;
  &lt;xsl:value-of select="item/field[@name=&amp;apos;BALLOONPAYMENT&amp;apos;]" /&gt;
  &lt;/ballonPayment&gt;
  &lt;/xsl:for-each&gt;
  &lt;/Campaigns&gt;
  &lt;/xsl:for-each&gt;     
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Please correct me where  I am doing wrong...</p>
  
  <p>regards,
  Inian</p>