title: How to convert XML to another XML file using xslt
body: <p>I have input XML which I have to reorganize into another XML using XSLT. 
  Here is the example of input file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Report asOfDate="2010-03-31 00:00:00"
         &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010" fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK4V10" fieldValueIsNull="false" fieldValueNatural="9001HK4V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0003" fieldValueIsNull="false" fieldValueNatural="0003"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="61,941.00" fieldValueIsNull="false" fieldValueNatural="61941.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_06_000_0_065_0" fieldValueIsNull="false" fieldValueNatural="r_06_000_0_065_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_2250_SPU" fieldValueIsNull="false" fieldValueNatural="c_2250_SPU"/&gt;
      &lt;/Record&gt;
      &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010"  fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK1V10" fieldValueIsNull="false" fieldValueNatural="9001HK1V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0003" fieldValueIsNull="false" fieldValueNatural="0003"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="4,157.00" fieldValueIsNull="false" fieldValueNatural="4157.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_06_570_0_070_0" fieldValueIsNull="false" fieldValueNatural="r_06_570_0_070_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_2250_SPU" fieldValueIsNull="false" fieldValueNatural="c_2250_SPU"/&gt;
      &lt;/Record&gt;
      &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010" fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK1V10" fieldValueIsNull="false" fieldValueNatural="9001HK1V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0629" fieldValueIsNull="false" fieldValueNatural="0629"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="1.00" fieldValueIsNull="false" fieldValueNatural="1.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_24_000_1_020_0" feldValueIsNull="false" fieldValueNatural="r_24_000_1_020_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_2250_SPU" fieldValueIsNull="false" fieldValueNatural="c_2250_SPU"/&gt;
      &lt;/Record&gt;
      &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010" fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK1V10" fieldValueIsNull="false" fieldValueNatural="9001HK1V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0003" fieldValueIsNull="false" fieldValueNatural="0003"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="61.00" fieldValueIsNull="false" fieldValueNatural="61.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_06_570_1_070_0" fieldValueIsNull="false" fieldValueNatural="r_06_570_1_070_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_2242_SPU" fieldValueIsNull="false" fieldValueNatural="c_2242_SPU"/&gt;
      &lt;/Record&gt;
      &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010" fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK1V10" fieldValueIsNull="false" fieldValueNatural="9001HK1V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0002" fieldValueIsNull="false" fieldValueNatural="0002"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="3.00" fieldValueIsNull="false" fieldValueNatural="3.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_18_000_1_000_0" fieldValueIsNull="false" fieldValueNatural="r_18_000_1_000_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_9000_SPU" fieldValueIsNull="false" fieldValueNatural="c_9000_SPU"/&gt;
      &lt;/Record&gt;
      &lt;Record&gt;
   &lt;FieldValue fieldName="rapportage_nihil" fieldValue="false" fieldValueIsNull="false" fieldValueNatural="false"/&gt;
   &lt;FieldValue fieldName="periode" fieldValue="31-Mar-2010" fieldValueIsNull="false" fieldValueNatural="2010-03-31 00:00:00"/&gt;
   &lt;FieldValue fieldName="formulierid" fieldValue="9001HK4V10" fieldValueIsNull="false" fieldValueNatural="9001HK4V10"/&gt;
   &lt;FieldValue fieldName="versie" fieldValue="1" fieldValueIsNull="false" fieldValueNatural="1"/&gt;
   &lt;FieldValue fieldName="frequentie" fieldValue="M" fieldValueIsNull="false" fieldValueNatural="M"/&gt;
   &lt;FieldValue fieldName="variant_type" fieldValue="Landen" fieldValueIsNull="false" fieldValueNatural="Landen"/&gt;
   &lt;FieldValue fieldName="value" fieldValue="0003" fieldValueIsNull="false" fieldValueNatural="0003"/&gt;
   &lt;FieldValue fieldName="post_value" fieldValue="2.00" fieldValueIsNull="false" fieldValueNatural="2.0"/&gt;
   &lt;FieldValue fieldName="cube" fieldValue="c01" fieldValueIsNull="false" fieldValueNatural="c01"/&gt;
   &lt;FieldValue fieldName="rij" fieldValue="r_06_000_1_040_0" fieldValueIsNull="false" fieldValueNatural="r_06_000_1_040_0"/&gt;
   &lt;FieldValue fieldName="kolom" fieldValue="c_2250_SPU" fieldValueIsNull="false" fieldValueNatural="c_2250_SPU"/&gt;
          &lt;/Record&gt;
  &lt;/Report&gt;
  </code></pre>
  
  <p>The output file should look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;bestand registratienummer="93391"&gt;
    &lt;rapportage nihil="false" periode="2010-03-31" formulierid="9001HK1V10" versie="1" frequentie="M"&gt;
     &lt;variant type="Landen" value="0003"/&gt;
     &lt;post value="4,157.00" cube="c01" rij="r_06_570_0_070_0" kolom="c_2250_SPU"/&gt;
     &lt;post value="61.00" cube="c01" rij="r_06_570_1_070_0" kolom="c_2242_SPU"/&gt;
   &lt;/rapportage&gt;
   &lt;rapportage nihil="false" periode="2010-03-31" formulierid="9001HK4V10" versie="1" frequentie="M"&gt;
   &lt;variant type="Landen" value="0002"/&gt;
   &lt;post value="61,941.00" cube="c01" rij="r_06_000_0_065_0" kolom="c_2250_SPU"/&gt;
   &lt;post value="2.00" cube="c01" rij="r_06_000_1_040_0" kolom="c_2250_SPU"/&gt;
   &lt;/rapportage&gt;
   &lt;rapportage nihil="false" periode="2010-03-31" formulierid="9001HK1V10" versie="1" frequentie="M"&gt;
   &lt;variant type="Landen" value="0629"/&gt;
   &lt;post value="1.00" cube="c01" rij="r_24_000_1_020_0" kolom="c_2250_SPU"/&gt;
   &lt;/rapportage&gt;
  &lt;/bestand&gt;
  </code></pre>
  
  <p>Basically I need to group records by variables <strong>formulierid</strong> and <strong>value</strong>.
  The real file contains thousands of records and contains numerous combinations.
  Can anyone please provide me with a sample script that can do this? I appreciate any help. Thanks very much.</p>