他のxmlファイルをxincludeするxmlドキュメントがあります。これらの xml ファイルにはすべて、異なるソースの場所にある画像の相対パスが含まれています。
<chapter xml:id="chapter1">
<title>First chapter in Main Document</title>
<section xml:id="section1">
<title>Section 1 in Main Document</title>
<para>this is paragraph<figure>
<title>Car images</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/image1.jpg"/>
</imageobject>
</mediaobject>
</figure></para>
</section>
<xi:include href="../doc/section2.xml"/>
<xi:include href="../doc/section3.xml"/>
</chapter>
section2 と section3 の xml ドキュメントは次のようになります。
<section xml:id="section2"
<title>Main Documentation Section2</title>
<para>This is also paragraph <figure>
<title>Different Images</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/image2.jpg"/>
</imageobject>
</mediaobject>
</figure></para>
</section>
すべての xml ドキュメントで画像パスのリストを生成する XSLT 1.0 スタイル シートを作成したいと考えています。異なるソースの場所にあるこれらの画像を単一の画像フォルダーにコピーします。次に、そのイメージ パスのリストを使用して、それらのイメージをコピーできます。そして、その画像パスリストがJavaクラスでアクセスできる構造に保存されていれば素晴らしいでしょう。
現在、別の質問から得た XSLT を使用しています。しかし、この XSLT は、他のノードの値をイメージ パスと共に提供します。テンプレートの値を変更して、たくさんフィルターをかけてみました。
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xi:include[@href][@parse='xml' or not(@parse)]">
<xsl:apply-templates select="document(@href)" />
</xsl:template>
期待される結果リストは、次のようなものになります。
/home/vish/test/images/image1.jpg
/home/vish/test/doc/other/images/image2.jpg
/home/vish/test2/other/images/image3.jpg
前もって感謝します..!!