title: Creat a XSLT in Ant script to change fileref values in a xml file
body: <p>I have xml document like below,</p>
  
  <pre><code>&lt;chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter1"&gt;
  &lt;title&gt;First chapter&lt;/title&gt;
  &lt;section xml:id="section1"&gt;
                  &lt;imageobject&gt;
                      &lt;image fileref="images/image1.jpg"/&gt;
                  &lt;/imageobject&gt;
                  &lt;imageobject&gt;
                      &lt;image fileref="images/image2.jpg"/&gt;
                  &lt;/imageobject&gt;
  &lt;/section&gt;
      &lt;section xml:id="section2" xml:base="../other/section1.xml"&gt;  
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image1.jpg"/&gt;
                      &lt;/imageobject&gt;
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image2.jpg"/&gt;
                      &lt;/imageobject&gt;
  
  &lt;section xml:id="section3" xml:base="../some-other/more/section3.xml"&gt;
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image1.jpg"/&gt;
                      &lt;/imageobject&gt;
      &lt;/section&gt;
      &lt;/section&gt;
      &lt;section xml:id="section4" xml:base="../some-other/section4.xml"&gt;
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image2.jpg"/&gt;
                      &lt;/imageobject&gt;
      &lt;/section&gt;
   &lt;/chapter&gt;
  </code></pre>
  
  <p>Be cause of same image name is repeated in different sections, I am renaming all image names other than first section using a java class. Then I can generate a list of renamed image names.</p>
  
  <p>Now I want to reflect those changes in the above xml file also. As example when I rename "image1.jpg" to "aaa.jpg" in section2, I need to reflect that change in the my initial xml by generating a new xml with new renamed image names.</p>
  
  <p>For that purpose, I am using Ant script which uses XSLT 1.0 and take my first xml and renamed image list as inputs and generate a new xml document with new fileref values. How I can make that XSLT and use it in my Ant script.</p>
  
  <p>Here is my new renamed images list.</p>
  
  <pre><code>&lt;Imagedata&gt;
    &lt;section&gt;
      &lt;sectionID&gt;section2&lt;/sectionID&gt;
      &lt;relativepath&gt;images/aaa.jpg&lt;/relativepath&gt;
      &lt;relativepath&gt;images/bbb.jpg&lt;/relativepath&gt;
    &lt;/section&gt;
    &lt;section&gt;
      &lt;sectionID&gt;section3&lt;/sectionID&gt;
      &lt;relativepath&gt;images/ccc.jpg&lt;/relativepath&gt;
    &lt;/section&gt;
     &lt;section&gt;
      &lt;sectionID&gt;section4&lt;/sectionID&gt;
      &lt;relativepath&gt;images/ddd.jpg&lt;/relativepath&gt;
    &lt;/section&gt;
  &lt;/Imagedata&gt;
  </code></pre>
  
  <p>And my new final xml will be some thing like,</p>
  
  <pre><code>&lt;chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter1"&gt;
      &lt;title&gt;First chapter&lt;/title&gt;
      &lt;section xml:id="section1"&gt;
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image1.jpg"/&gt;
                      &lt;/imageobject&gt;
                      &lt;imageobject&gt;
                          &lt;image fileref="images/image2.jpg"/&gt;
                      &lt;/imageobject&gt;
      &lt;/section&gt;
          &lt;section xml:id="section2" xml:base="../other/section1.xml"&gt;  
                          &lt;imageobject&gt;
                              &lt;image fileref="images/aaa.jpg"/&gt;
                          &lt;/imageobject&gt;
                          &lt;imageobject&gt;
                              &lt;image fileref="images/bbb.jpg"/&gt;
                          &lt;/imageobject&gt;
  
      &lt;section xml:id="section3" xml:base="../some-other/more/section3.xml"&gt;
                          &lt;imageobject&gt;
                              &lt;image fileref="images/ccc.jpg"/&gt;
                          &lt;/imageobject&gt;
          &lt;/section&gt;
          &lt;/section&gt;
          &lt;section xml:id="section4" xml:base="../some-other/section4.xml"&gt;
                          &lt;imageobject&gt;
                              &lt;image fileref="images/ddd.jpg"/&gt;
                          &lt;/imageobject&gt;
          &lt;/section&gt;
       &lt;/chapter&gt;
  </code></pre>
  
  <p>Thank you..!!</p>