Problem: I'm trying to reference figures in the HTML text, which is an internal link pointing to the caption of the figure.
The XML code for the figure and the referencing is this:
(...) As it can be seen in the Figure <p:iref intref="f1"/> (...)
<float:figure id="f1">
<float:graphic path="f1.jpg"/>
<float:caption>
<p:p> Some text </p:p>
</float:caption>
And the XSL code for processing the figures is the following:
<xsl:template match="float:figure">
<a name="{@id}"></a>
<br/>
<xsl:apply-templates select="float:graphic"/>
<br/>
<center>
<b>Figure <xsl:value-of select="count(preceding::float:figure)+1"/> - </b> <xsl:value-of select="float:caption"/>
</center>
<br/>
</xsl:template>
<xsl:template match="//float:graphic">
<xsl:variable name="path" select="./@path"/>
<center>
<img src="{$path}"/>
</center>
</xsl:template>
Now, for referencing the figures:
<xsl:template match="p:iref">
<xsl:variable name="fid" select="@intref"/>
<xsl:if test="//float:figure/@id=$fid">
<a href="#{$fid}"><xsl:value-of select="count(preceding::float:figure)+1"/></a>
</xsl:if>
</xsl:template>
The thing is: when the reference (intref) comes before the figure, the reference works fine. But when I want to refer to images that already have been passed, although the link works fine, it references a diferent figure.
Example:
Current Result in HTML:
(...) As it can be seen in Figure 1 (...)
-----------some Figure------------
Figure 1 - some text
(...) and like we've seen back then, in Figure 2 (...)
Desired Result in HTML:
(...) As it can be seen in Figure 1 (...)
-----------some Figure------------
Figure 1 - some text
(...) and like we've seen back then, in Figure 1 (...)
So it seems like, although the reference is fine (in the first output, if I click the link, which is the number 2 in Figure 2, it references right to Figure 1) appears Figure 2...
Any suggestions?
No comments:
Post a Comment