Hi,
I have a list of figure names and width and height informations in separate xml file,
I need to match the figure name in the source xml file and need to insert the width and height information as a attribute in the source xml file.
here the source xml file..
<graphic name="sample.jpg" align="center"/>
expected output xml file
<graphic name="sample.jpg" width="100" depth="200" align="center"/>
figure measurement xml
<figure>
<name>sample.jpg</name>
<width>100</width>
<height>200</height>
</figure>
I have stored source file name attribute value in '$names'. And I have stored figure measure file name attribute value in '$figname'.
my xsl script
<xsl:for-each select="@name">
<xsl:if test="$figname=$name">
<xsl:attribute name="width"><xsl:value-of select="document('figure.xml')/figure/width"/></xsl:attribute>
<xsl:attribute name="depth"><xsl:value-of select="document('figure.xml')/figure/height"/></xsl:attribute>
</xsl:if>
</xsl:for-each>
It works for only the first time, not for all. i have nearly more than 100 images. for all images i need the width and height values. my scripts works only first value. how do i select the all value ?
plase suggest me..
Best Regards, Antony
-------------------------------------------------------------------------------------------
I am sorry, i have used your scripts, but i am not able to get the exact output which i require.
I have given all the clear details here for your consideration.
INPUT XML:
<figure>
<title>Earliest Discoveries</title>
<graphic name="luc26959_0101.eps" align="center"/>
<caption>These lithographs of teeth of Iguanodon are from Mantell original 1825 article.</caption>
</figure>
INPUT FIGURE XML:
<?xml version="1.0"?>
<figuregroup>
<figure><name>luc26959_0101.eps</name><width>500</width><height>347</height></figure>
<figure><name>luc26959_0102.eps</name><width>500</width><height>352</height></figure>
<figure><name>luc26959_0103.eps</name><width>500</width><height>348</height></figure>
<figure><name>luc26959_0104.eps</name><width>445</width><height>263</height></figure>
<figure><name>luc26959_0105.eps</name><width>217</width><height>250</height></figure>
</figuregroup>
TRANSFORMATION XSL CODE:
<xsl:template match="graphic">
<xsl:variable name="names">
<xsl:value-of select="substring-before(@name, '.')"/>
</xsl:variable>
<xsl:for-each select="//graphic">
<imageobject>
<imagedata>
<xsl:attribute name="fileref">graphics/<xsl:value-of select="$names"/>.jpg</xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="document('../input/fig.xml')/figuregroup/figure[name=$names]/width"/></xsl:attribute>
<xsl:attribute name="depth"><xsl:value-of select="document('../input/fig.xml')/figuregroup/figure[name=$names]/height"/></xsl:attribute>
<xsl:apply-templates/>
</imagedata>
</imageobject>
</xsl:for-each>
</xsl:template>
CURRENT OUTPUT XML:
<figure>
<title>Earliest Discoveries</title>
<mediaobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="" depth=""/></imageobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="" depth=""/></imageobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="" depth=""/></imageobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="" depth=""/></imageobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="" depth=""/></imageobject>
<caption><para>These lithographs of teeth of <emphasis>Iguanodon</emphasis> are from Mantell's original 1825 article.</para><para/></caption>
</mediaobject>
</figure>
REQUIRED OUTPUT:
<figure>
<title>Earliest Discoveries</title>
<mediaobject>
<imageobject><imagedata fileref="graphics/luc26959_0101.jpg" width="500" depth="347"/></imageobject>
<caption><para>These lithographs of teeth of <emphasis>Iguanodon</emphasis> are from Mantell's original 1825 article.</para><para/></caption>
</mediaobject>
</figure>
Hope i have given a clear picture about my requirement, i have tried with-out "for-each" also, when i give without 'for-each' i am not getting any output element repeatly, only one time i m getting it, still width and depth attributes empty.
I dont know how to fill that attribute in the correct way, after using your code also.
Please help me..
Thanks & Regards, Antony