David Carlisle The way to get numbered cross refs to work is
get the numbering of the item (figure, chapter, table, ...)
to work
when making the cross ref, go to the node that is referenced (with
for-each or apply-templates in a special mode) ) produce the number with the same code as in step 1. In your case you have <xsl:number count="figure" level="any" from="mainfunc"
format="1"/>
for
step 1 so for step 2 you want <xsl:template match="xref">
<fo:basic-link background-color="lightblue"
internal-destination="{@xrefid}">
<xsl:text>Fig. </xsl:text>
<xsl:for-each select="id(@xrefid)"/>
so at this point (assuming that you have a dtd and your figure ids are of
type ID so id() function works.) you are at the figure, so now you can do <xsl:number count="figure" level="any" from="mainfunc" format="1"/>
then just finish up </xsl:for-each>
</fo:basic-link>
</xsl:template>
If you haven't declared your ids to be of type id you can declare a key
instead and use key() rather than id() Without seeing a (small) input file I'm a bit confused as you have
internal-destination="{@xrefid}"
which implies that your source doc has ids that you can use in teh generated
FO for cross referencing, but in teh figure itself <xsl:template
match="figure"> and <xsl:template match="graphic"> you are not accessing any
id attribute and using generate-id to put a machine generated if into the FO
which won't have any relationship to the id used in your fo:basic-link. I suspect you don't want id="{generate-id(.)}£ but instead id="{@id}"
or whatever the attribute is called that stores the value that is used in
the xrefid attribute of xref.
Later:
> Here are parts of relavent schema I'm using unless I read it wrong
> figure does have ID
XSLT1 won't look at your schema so IDs declared in a schema don't count.
so you'd better use keys, Add
<xsl:key name="ids" match="*[@id] use="@id"/>
to the top level of your stylesheet then use
<xsl:for-each select="key('ids',@xrefid)">
instead of id(@xrefid)
the for-each will iterate over exactly one node (your figure) then
xsl:number will generate the right number, since it will be executed with
the figure as the context node.
The OP, Norma, then offered a solution using keys
A template for the xref, and one for the actual figure
which was being referenced
<xsl:key name="ids" match="*[@id]" use="@id"/>
<xsl:template match="xref">
<fo:basic-link background-color="lightblue"
internal-destination="{@idref}">
<xsl:for-each select="key('ids',@xrefid)">
<xsl:text>Fig. </xsl:text>
<xsl:number count="figure" level="any"
from="mainfunc" format="1"/>
</xsl:for-each>
</fo:basic-link>
</xsl:template>
<xsl:template match="figure">
<fo:block id="{@id}" text-align="center" font-style="italic"
keep-together.within-page="always">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
|