私は以下のようなxml文書を持っています、
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter1">
<title>First chapter</title>
<section xml:id="section1">
<imageobject>
<imagedata fileref="images/image1.jpg"/>
</imageobject>
<imageobject>
<imagedata fileref="images/image5.jpg"/>
</imageobject>
</section>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter2" xml:base="../foder1/section2.xml">
<section xml:id="section2">
<imageobject>
<imagedata fileref="images/image2.jpg"/>
</imageobject>
<imageobject>
<imagedata fileref="images/image3.jpg"/>
</imageobject>
</section>
</chapter>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="chapter3" xml:base="../folder3/section3.xml">
<section xml:id="section3">
<imageobject>
<imagedata fileref="images/image4.jpg"/>
</imageobject>
</section>
</chapter>
</chapter>
ファイルと同様に、各 xinclude ファイルには画像への相対パスがあります。画像の絶対パスを取得したい。そのために、各章の xml:base 値をその章の相対画像パスと組み合わせます。次に、各章の画像への絶対パスをすべて取得できます。そのために、次の XSLT 1.o ファイルを使用しました。
<xsl:template match="/">
<imagepaths>
<xsl:for-each select="chapter/chapter">
<basepath>
<xsl:value-of select="@xml:base"/>
</basepath>
</xsl:for-each>
<xsl:apply-templates select="*" />
</image-paths>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="imagedata">
<relativepath>
<xsl:value-of select="@fileref" />
</realtivepath>
</xsl:template>
</xsl:stylesheet>
しかし、これはすべての xml:base 値と相対パスを別々に与えます。各章の xml:base 値とその章の相対パスの間のマッピングは提供されません。その章の xml:base 値とすべての相対パスの間のマッピングが必要です。このマッピングはどのようにすればよいですか? 以下のように出力することで、マッピングを行い、画像の絶対パスを取得できると思います。私のXSLTで次の出力を得るのを手伝ってください。それを使用すると、セクション 1 のすべての画像に「mainrelativepath」でアクセスでき、セクション 2、セクション 3 の画像に basepath ノードと relativepath ノードでアクセスできます。
<Imagedata>
<mainrelativepath>images/image1.jpg</mainrelativepath>
<mainrelativepath>images/image5.jpg</mainrelativepath>
<chapter>
<basepath>../foder1/section2.xml</basepath>
<relativepath>images/image2.jpg</relativepath>
<relativepath>images/image3.jpg</relativepath>
</chapter>
<chapter>
<basepath>../foder3/section3.xml</basepath>
<relativepath>images/image4.jpg</relativepath>
</chapter>
前もって感謝します..!!