OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] different gentext for olinks and xref


Yes, this can be done. From your example, you want olinks to get the default styling, and you want to change the styling for xrefs. You can do that in two steps in your customization layer:

1. Add a gentext template with @style="xref" to your customization of local.l10n.xml:

  ...
  <l:context name="xref-number-and-title">
    <l:template name="section" text="%t" style="xref"/>
  </l:context>
  ...

2.  Customize the template in fo/xref.xsl that starts with:

  <xsl:match="xref" name="xref">

by changing how its variable named 'xrefstyle' is set.  I used:

  <xsl:variable name="xrefstyle">
    <xsl:choose>
      <xsl:when test="@role and not(@xrefstyle)
                      and $use.role.as.xrefstyle != 0">
        <xsl:value-of select="@role"/>
      </xsl:when>
      <xsl:when test="@xrefstyle">
        <xsl:value-of select="@xrefstyle"/>
      </xsl:when>
      <xsl:when test="local-name($target) = 'section'">xref</xsl:when>
      <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

If an xref instance already has an @xrefstyle attribute, it uses it. If not, then it tests if the target is a section, and if so sets the $xrefstyle variable to 'xref' to match the one you defined in the gentext template. That special gentext template won't be used with olinks.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net

On 4/1/2014 9:23 PM, natk wrote:
Is it possible to have different gentext for olinks and xrefs?

e.g.
<book id="bookId"><title>Book Title</title>
...
<section id="sectionId"><title>Section Title</title>

For <olink targetdoc="bookId" targetptr="sectionId"/> I would like to see
something like:

Section x.y "Section Title" in Book Title

For <xref linkend="sectionId"> I would like to see:

Section Title (which will be hyperlinked to the appropriate internal
section)

At the moment, if I customise the section template in the
xref-number-and-title context, they both change.

Nat



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]