2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 exclude-result-prefixes="doc"
7 <!-- ********************************************************************
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
13 and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
19 <!-- cross reference target collection -->
21 <doc:mode mode="collect.targets" xmlns="">
22 <refpurpose>Collects information for potential cross reference targets</refpurpose>
24 <para>Processing the root element in the
25 <literal role="mode">collect.targets</literal> mode produces
26 a set of target database elements that can be used by
27 the olink mechanism to resolve external cross references.
28 The collection process is controlled by the <literal>
29 collect.xref.targets</literal> parameter, which can be
30 <literal>yes</literal> to collect targets and process
31 the document for output, <literal>only</literal> to
32 only collect the targets, and <literal>no</literal>
33 (default) to not collect the targets and only process the document.
36 A <literal>targets.filename</literal> parameter must be
37 specified to receive the output if
38 <literal>collect.xref.targets</literal> is
39 set to <literal>yes</literal> so as to
40 redirect the target data to a file separate from the
46 <!-- ============================================================ -->
48 <xsl:template match="*" mode="collect.targets">
50 <xsl:when test="$collect.xref.targets = 'yes' and $targets.filename = ''">
52 Must specify a $targets.filename parameter when
53 $collect.xref.targets is set to 'yes'.
54 The xref targets were not collected.
59 <xsl:when test="$targets.filename">
60 <xsl:call-template name="write.chunk">
61 <xsl:with-param name="filename" select="$targets.filename"/>
62 <xsl:with-param name="method" select="'xml'"/>
63 <xsl:with-param name="encoding" select="'utf-8'"/>
64 <xsl:with-param name="omit-xml-declaration" select="'yes'"/>
65 <xsl:with-param name="doctype-public" select="''"/>
66 <xsl:with-param name="doctype-system" select="''"/>
67 <xsl:with-param name="indent" select="'yes'"/>
68 <xsl:with-param name="quiet" select="0"/>
69 <xsl:with-param name="content">
70 <xsl:apply-templates select="." mode="olink.mode"/>
75 <!-- Else write to standard output -->
76 <xsl:apply-templates select="." mode="olink.mode"/>
83 <xsl:template name="olink.href.target">
84 <xsl:param name="nd" select="."/>
86 <xsl:value-of select="$olink.base.uri"/>
87 <xsl:call-template name="href.target">
88 <xsl:with-param name="object" select="$nd"/>
92 <!-- Templates for extracting cross reference information
93 from a document for use in an xref database.
96 <xsl:template name="attrs">
97 <xsl:param name="nd" select="."/>
99 <xsl:attribute name="element">
100 <xsl:value-of select="local-name(.)"/>
103 <xsl:attribute name="href">
104 <xsl:call-template name="olink.href.target">
105 <xsl:with-param name="nd" select="$nd"/>
109 <xsl:variable name="num">
110 <xsl:apply-templates select="$nd" mode="label.markup">
111 <xsl:with-param name="verbose" select="0"/>
112 </xsl:apply-templates>
116 <xsl:attribute name="number">
117 <xsl:value-of select="$num"/>
121 <xsl:if test="$nd/@id">
122 <xsl:attribute name="targetptr">
123 <xsl:value-of select="$nd/@id"/>
127 <xsl:if test="$nd/@lang">
128 <xsl:attribute name="lang">
129 <xsl:value-of select="$nd/@lang"/>
135 <xsl:template name="div">
136 <xsl:param name="nd" select="."/>
139 <xsl:call-template name="attrs">
140 <xsl:with-param name="nd" select="$nd"/>
143 <xsl:apply-templates select="$nd" mode="title.markup">
144 <xsl:with-param name="verbose" select="0"/>
145 </xsl:apply-templates>
149 <xsl:when test="$nd/@xreflabel">
150 <xsl:call-template name="xref.xreflabel">
151 <xsl:with-param name="target" select="$nd"/>
155 <xsl:apply-templates select="$nd" mode="xref-to">
156 <xsl:with-param name="verbose" select="0"/>
157 </xsl:apply-templates>
161 <xsl:apply-templates mode="olink.mode"/>
165 <xsl:template name="obj">
166 <xsl:param name="nd" select="."/>
169 <xsl:call-template name="attrs">
170 <xsl:with-param name="nd" select="$nd"/>
173 <xsl:apply-templates select="$nd" mode="title.markup">
174 <xsl:with-param name="verbose" select="0"/>
175 </xsl:apply-templates>
179 <xsl:when test="$nd/@xreflabel">
180 <xsl:call-template name="xref.xreflabel">
181 <xsl:with-param name="target" select="$nd"/>
185 <xsl:apply-templates select="$nd" mode="xref-to">
186 <xsl:with-param name="verbose" select="0"/>
187 </xsl:apply-templates>
194 <xsl:template match="text()|processing-instruction()|comment()"
200 <xsl:template match="*" mode="olink.mode">
204 <xsl:template match="set" mode="olink.mode">
205 <xsl:call-template name="div"/>
208 <xsl:template match="book" mode="olink.mode">
209 <xsl:call-template name="div"/>
212 <xsl:template match="preface|chapter|appendix" mode="olink.mode">
213 <xsl:call-template name="div"/>
216 <xsl:template match="part|reference" mode="olink.mode">
217 <xsl:call-template name="div"/>
220 <xsl:template match="article" mode="olink.mode">
221 <xsl:call-template name="div"/>
224 <xsl:template match="bibliography|bibliodiv" mode="olink.mode">
225 <xsl:call-template name="div"/>
228 <xsl:template match="biblioentry|bibliomixed" mode="olink.mode">
229 <xsl:call-template name="obj"/>
232 <xsl:template match="refentry" mode="olink.mode">
233 <xsl:call-template name="div"/>
236 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5" mode="olink.mode">
237 <xsl:call-template name="div"/>
240 <xsl:template match="refsection|refsect1|refsect2|refsect3" mode="olink.mode">
241 <xsl:call-template name="div"/>
244 <xsl:template match="figure|example|table" mode="olink.mode">
245 <xsl:call-template name="obj"/>
248 <xsl:template match="equation[title]" mode="olink.mode">
249 <xsl:call-template name="obj"/>
252 <xsl:template match="qandaset|qandaentry" mode="olink.mode">
253 <xsl:call-template name="div"/>
256 <xsl:template match="*" mode="olink.mode">
258 <xsl:call-template name="obj"/>
260 <xsl:apply-templates mode="olink.mode"/>