This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
[docbook-apps] Adjusting trailing punctuation after <xref>
- From: paul at kitebird dot com
- To: docbook-apps at lists dot oasis-open dot org
- Date: Tue, 14 Dec 2004 21:53:06 -0600
- Subject: [docbook-apps] Adjusting trailing punctuation after <xref>
My question concerns the handling of trailing punctuation
following the closing double quote generated by the <xref>
mechanism.
Suppose I have this input:
<para>
Configuration options and configuration file syntax are described in
<xref linkend="using-config-files"/>.
</para>
Running the document containing that paragraph results in output like
this:
Configuration options and configuration file syntax are described in
Section 4, "Using Configuration Files".
Note that the trailing period appears after the closing double quote.
What I would like to do is have trailing punctuation (such as period,
question or exclamation mark, comma, colon, semicolon)) move inside the
closing double quote, like this:
Configuration options and configuration file syntax are described in
Section 4, "Using Configuration Files."
I suspect that achieving this requires two things:
1. The <xref> mechanism must examine the following element to see if it's
a text node that begins with a punctuation character and use the
character in the cross-reference if it is.
2. There needs to be a template for text nodes that follow <xref> such
that the template strips off the first character if it's one of the
punctuation characters.
The second part of that can be done like this:
<xsl:template match="text()[preceding-sibling::*[1][self::xref]]">
<xsl:choose>
<xsl:when test="contains('.?!,:;', substring(., 1, 1))">
<xsl:value-of select="substring(., 2)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
But is there a way to do the first part? I have spent some time
looking at some of the <xref> machinery in the stylesheets, but I'm
afraid that I can only admire it as deep wizardry, with little
understanding of what I'm looking at. :-)