summaryrefslogtreecommitdiffstats
path: root/kdoctools/docbook/xsl/manpages/xref.xsl
blob: 3f2df52a6aadaf692fe3dc9d01752a7b261bcc1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<xsl:template match="xref">
  <xsl:variable name="targets" select="key('id', @linkend)"/>
  <xsl:variable name="target" select="$targets[1]"/>
  <xsl:variable name="type" select="local-name($target)"/>

  <xsl:choose>
    <xsl:when test="$type=''">
      <xsl:message>
        <xsl:text>xref to nonexistent id </xsl:text>
        <xsl:value-of select="@linkend"/>
      </xsl:message>
    </xsl:when>

    <xsl:when test="$type='refentry'">
      <xsl:call-template name="do-citerefentry">
        <xsl:with-param name="refentrytitle"
                        select="$target/refmeta/refentrytitle[1]"/>
        <xsl:with-param name="manvolnum"
			select="$target/refmeta/manvolnum"/>
      </xsl:call-template>
    </xsl:when>

    <xsl:when test="$type='refname'">
      <xsl:call-template name="do-citerefentry">
        <xsl:with-param name="refentrytitle" select="$target"/>
        <xsl:with-param name="manvolnum"
          select="$target/../../refmeta/manvolnum"/>
      </xsl:call-template>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>[xref to </xsl:text>
      <xsl:value-of select="$type"/>
      <xsl:text>]</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>