summaryrefslogtreecommitdiff
path: root/stylesheets/db2html-xref.xsl
blob: 07b6802355464ab6785ef11acb6ef733163e5313 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?xml version='1.0'?><!-- -*- Mode: fundamental; tab-width: 3 -*- -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<!-- ======================================================================= -->

<xsl:template name="anchor" match="anchor">
	<xsl:param name="name" select="@id"/>
	<xsl:if test="$name">
		<a name="{$name}"/>
	</xsl:if>
</xsl:template>

<!-- ======================================================================= -->

<xsl:template match="link">
	<a>
		<xsl:attribute name="href">
			<xsl:call-template name="xref.target">
				<xsl:with-param name="linkend" select="@linkend"/>
			</xsl:call-template>
		</xsl:attribute>
		<xsl:choose>
			<xsl:when test="@endterm">
				<xsl:apply-templates select="id(@endterm)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
	</a>
</xsl:template>

<xsl:template match="olink">
	<xsl:call-template name="FIXME"/>
</xsl:template>

<xsl:template name="ulink" match="ulink">
	<xsl:param name="url" select="@url"/>
	<xsl:param name="content" select="false()"/>
	<a href="{$url}">
		<xsl:choose>
			<xsl:when test="$content">
				<xsl:copy-of select="$content"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
	</a>
</xsl:template>

<!-- ======================================================================= -->

<xsl:template name="xref" match="xref">
	<xsl:param name="linkend" select="@linkend"/>
	<xsl:param name="target" select="id($linkend)"/>
	<xsl:param name="content" select="false()"/>
	<a>
		<xsl:attribute name="href">
			<xsl:call-template name="xref.target">
				<xsl:with-param name="linkend" select="$linkend"/>
				<xsl:with-param name="target" select="$target"/>
			</xsl:call-template>
		</xsl:attribute>
		<xsl:choose>
			<xsl:when test="$content">
				<xsl:copy-of select="$content"/>
			</xsl:when>
			<xsl:when test="@endterm">
				<xsl:apply-templates select="id(@endterm)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="xref.content">
					<xsl:with-param name="linkend" select="$linkend"/>
					<xsl:with-param name="target" select="$target"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</a>
</xsl:template>

<xsl:template name="xref.target">
	<xsl:param name="linkend" select="@linkend"/>
	<xsl:param name="target" select="id($linkend)"/>
	<xsl:variable name="chunk_id">
		<xsl:apply-templates select="$target" mode="chunk.id.mode"/>
	</xsl:variable>
	<xsl:value-of select="concat($chunk_id, $html_extension)"/>
	<xsl:if test="$linkend and string($chunk_id) != $linkend">
		<xsl:text>#</xsl:text>
		<xsl:value-of select="$linkend"/>
	</xsl:if>
</xsl:template>

<xsl:template name="xref.content">
	<xsl:param name="linkend" select="@linkend"/>
	<xsl:param name="target" select="id($linkend)"/>
	<xsl:choose>
		<xsl:when test="$target/@xreflabel">
			<xsl:value-of select="$target/@xreflabel"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:apply-templates select="$target" mode="node.header.inline.mode"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- ======================================================================= -->

</xsl:stylesheet>