— Use role attribute for xrefstyle on xref?


<xsl:param name="" select="1"></xsl:param>


In DocBook documents that conform to a schema older than V4.3, this parameter allows role to serve the purpose of specifying the cross reference style.

If non-zero, the role attribute on xref will be used to select the cross reference style. In DocBook V4.3, the xrefstyle attribute was added for this purpose. If the xrefstyle attribute is present, role will be ignored, regardless of the setting of this parameter.


The following small stylesheet shows how to configure the stylesheets to make use of the cross reference style:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=""

<xsl:import href="../xsl/html/docbook.xsl"/>

<xsl:output method="html"/>

<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="">
  <l:l10n xmlns:l="" language="en">
   <l:context name="xref">
      <l:template name="chapter" style="title" text="Chapter %n, %t"/>
      <l:template name="chapter" text="Chapter %n"/>


With this stylesheet, the cross references in the following document:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
<book id="book"><title>Book</title>


<para>Normal: <xref linkend="ch1"/>.</para>
<para>Title: <xref xrefstyle="title" linkend="ch1"/>.</para>


<chapter id="ch1">
<title>First Chapter</title>



will appear as:

Normal: Chapter 1.

Title: Chapter 1, First Chapter.