Hi Bob,
One more small fix to your template: the 2nd <xsl:when> should exclude
footnotes,
i.e.:
<xsl:when test="not(self::footnote) and $id != ''">
The reason is that @id on footnotes does not make it into the FO output, so FOP
emits a warning about an unresolved destination.
Regards,
Alexey.
On Tuesday, August 27, 2013 02:43:39 PM Alexey Neyman wrote:
Hi Bob,
Yes, the suggested template makes sense.
I did a bit of further digging, though, and found that there's a way to
generate the
same IDs on the document by setting $generate.consistent.ids parameter to 1. In
that case, it would be possible to create links to a given element - which
would
stay valid even if the document is rebuilt (but only as long as it is
unchanged). I am
not sure if it vindicates the creation of internal destination for ID-less
sections,
though. I still think the template you suggest makes much more sense as a
default.
Thanks,
Alexey.
On Tuesday, August 27, 2013 02:13:09 PM Bob Stayton wrote:
Hi Alexey,
I applied your patch, thanks for that.
I agree that for fop1.foxdest mode, it makes no sense to output the dynamically
generated id values. I also agree that any element that has an @id | @xml:id
should
get a fox destination in case someone wants to link to it from another PDF
file. I
think this template suffered much from the copy-paste operation that created
it.
8^)
I think the following template is the only one needed for that mode:
<xsl:template match="*" mode="fop1.foxdest"> <xsl:variable name="id">
<xsl:value-of select="(@id|@xml:id)[1]"/> </xsl:variable> <xsl:choose>
<xsl:when
test="self::index and $generate.index = 0"/> <xsl:when test="$id != ''">
<fox:destination internal-destination="{$id}"/> <xsl:apply-templates
select="*"
mode="fop1.foxdest"/> </xsl:when> <xsl:otherwise>
<xsl:apply-templates
select="*" mode="fop1.foxdest"/> </xsl:otherwise>
</xsl:choose></xsl:template>
Let me know if you see anything wrong with it.
If you are wondering about the case with $generate.index = 0, I checked the
indexing templates to see if that made sense. As it turns out, an index
element
generates no output at all if $generate.index = 0, even if that index element
in the
document contains manually created indexentry and indexdiv elements. When
$generate.index = 1, it will process any indexdiv|indexentry elements if they
exist,
and then if there are none, it calls "generate-index". Perhaps that param
should
have been named 'show.index' instead, but I'm not going to change that now.
Bob StaytonSagehill Enterprises
[email protected][1]
*From:* Alexey Neyman[2]
*Sent:* Tuesday, August 27, 2013 1:27 PM
*To:* DocBook Apps[3]
*Subject:* [docbook-apps] Clean up copy-pasted code in fop1.xsl
Hi all,
The attached patch removes an unnecessary call for fop1.foxdest mode template
which is a copy-paste from bookmark generation code. Should speed up XSLT a bit
:)
As a related question, does it make sense to limit the template to "*[@id |
@xml:id]
instead of current match pattern? Given that IDs on subsequent runs are going
to
be different for elements without an explicit ID attribute, it won't be
possible to
create a permanent URL to point to such ID-less sections. On other hand,
current
match pattern does not generate destinations for tables/figures/equations, even
if they have IDs - making impossible to <olink> to them.
Regards,
Alexey.
--------------------
--------
[1] mailto:[email protected]
[2] mailto:[email protected]
[3] mailto:[email protected]