私は以下のようなxmlドキュメントを持っています、
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter1">
<title>First chapter</title>
<section xml:id="section1">
<imageobject>
<image fileref="images/image1.jpg"/>
</imageobject>
<imageobject>
<image fileref="images/image2.jpg"/>
</imageobject>
</section>
<section xml:id="section2" xml:base="../other/section1.xml">
<imageobject>
<image fileref="images/image1.jpg"/>
</imageobject>
<imageobject>
<image fileref="images/image2.jpg"/>
</imageobject>
<section xml:id="section3" xml:base="../some-other/more/section3.xml">
<imageobject>
<image fileref="images/image1.jpg"/>
</imageobject>
</section>
</section>
<section xml:id="section4" xml:base="../some-other/section4.xml">
<imageobject>
<image fileref="images/image2.jpg"/>
</imageobject>
</section>
</chapter>
同じ画像名が異なるセクションで繰り返されているため、Javaクラスを使用して最初のセクション以外のすべての画像名の名前を変更しています。次に、名前が変更された画像名のリストを生成できます。
次に、これらの変更を上記のxmlファイルにも反映させたいと思います。たとえば、セクション2で「image1.jpg」の名前を「aaa.jpg」に変更する場合、名前を変更した新しい画像名で新しいxmlを生成することにより、その変更を最初のxmlに反映する必要があります。
そのために、XSLT 1.0を使用するAntスクリプトを使用しており、最初のxmlと名前を変更した画像リストを入力として取得し、新しいfileref値を使用して新しいxmlドキュメントを生成します。そのXSLTを作成し、Antスクリプトで使用するにはどうすればよいですか。
これが私の新しい名前変更された画像リストです。
<Imagedata>
<section>
<sectionID>section2</sectionID>
<relativepath>images/aaa.jpg</relativepath>
<relativepath>images/bbb.jpg</relativepath>
</section>
<section>
<sectionID>section3</sectionID>
<relativepath>images/ccc.jpg</relativepath>
</section>
<section>
<sectionID>section4</sectionID>
<relativepath>images/ddd.jpg</relativepath>
</section>
</Imagedata>
そして、私の新しい最終的なxmlは、次のようなものになります。
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter1">
<title>First chapter</title>
<section xml:id="section1">
<imageobject>
<image fileref="images/image1.jpg"/>
</imageobject>
<imageobject>
<image fileref="images/image2.jpg"/>
</imageobject>
</section>
<section xml:id="section2" xml:base="../other/section1.xml">
<imageobject>
<image fileref="images/aaa.jpg"/>
</imageobject>
<imageobject>
<image fileref="images/bbb.jpg"/>
</imageobject>
<section xml:id="section3" xml:base="../some-other/more/section3.xml">
<imageobject>
<image fileref="images/ccc.jpg"/>
</imageobject>
</section>
</section>
<section xml:id="section4" xml:base="../some-other/section4.xml">
<imageobject>
<image fileref="images/ddd.jpg"/>
</imageobject>
</section>
</chapter>
ありがとうございました..!!