docbook_xsl_wrapper 0.1.2 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/CHANGELOG +41 -0
- data/README.md +9 -17
- data/bin/docbook_xsl_wrapper +9 -14
- data/docbook_xsl_wrapper.gemspec +8 -7
- data/lib/docbook_xsl_wrapper.rb +24 -1
- data/lib/docbook_xsl_wrapper/epub.rb +124 -122
- data/lib/docbook_xsl_wrapper/options.rb +1 -1
- data/lib/docbook_xsl_wrapper/validate.rb +22 -0
- data/lib/docbook_xsl_wrapper/version.rb +1 -1
- data/schema/docbookxi.rng +18654 -0
- data/spec/docbook_xsl_wrapper/validate_spec.rb +64 -0
- data/xsl/AUTHORS +4 -0
- data/xsl/COPYING +48 -0
- data/xsl/REVISION +1 -0
- data/xsl/VERSION.xsl +115 -0
- data/xsl/common/addns.xsl +124 -0
- data/xsl/common/af.xml +1272 -0
- data/xsl/common/am.xml +1272 -0
- data/xsl/common/ar.xml +1272 -0
- data/xsl/common/as.xml +703 -0
- data/xsl/common/ast.xml +703 -0
- data/xsl/common/autoidx-kimber.xsl +45 -0
- data/xsl/common/autoidx-kosek.xsl +155 -0
- data/xsl/common/az.xml +715 -0
- data/xsl/common/bg.xml +767 -0
- data/xsl/common/bn.xml +1272 -0
- data/xsl/common/bn_in.xml +703 -0
- data/xsl/common/bs.xml +705 -0
- data/xsl/common/ca.xml +703 -0
- data/xsl/common/charmap.xsl +222 -0
- data/xsl/common/common.xsl +2129 -0
- data/xsl/common/cs.xml +743 -0
- data/xsl/common/cy.xml +1288 -0
- data/xsl/common/da.xml +707 -0
- data/xsl/common/de.xml +709 -0
- data/xsl/common/el.xml +772 -0
- data/xsl/common/en.xml +1272 -0
- data/xsl/common/entities.ent +67 -0
- data/xsl/common/eo.xml +1272 -0
- data/xsl/common/es.xml +719 -0
- data/xsl/common/et.xml +1272 -0
- data/xsl/common/eu.xml +1272 -0
- data/xsl/common/fa.xml +703 -0
- data/xsl/common/fi.xml +713 -0
- data/xsl/common/fr.xml +733 -0
- data/xsl/common/ga.xml +1272 -0
- data/xsl/common/gentext.xsl +855 -0
- data/xsl/common/gl.xml +1272 -0
- data/xsl/common/gu.xml +703 -0
- data/xsl/common/he.xml +1272 -0
- data/xsl/common/hi.xml +703 -0
- data/xsl/common/hr.xml +705 -0
- data/xsl/common/hu.xml +721 -0
- data/xsl/common/id.xml +1272 -0
- data/xsl/common/insertfile.xsl +113 -0
- data/xsl/common/is.xml +715 -0
- data/xsl/common/it.xml +1272 -0
- data/xsl/common/ja.xml +703 -0
- data/xsl/common/ka.xml +743 -0
- data/xsl/common/kn.xml +1272 -0
- data/xsl/common/ko.xml +1272 -0
- data/xsl/common/ky.xml +775 -0
- data/xsl/common/l10n.dtd +64 -0
- data/xsl/common/l10n.xml +78 -0
- data/xsl/common/l10n.xsl +598 -0
- data/xsl/common/la.xml +1272 -0
- data/xsl/common/labels.xsl +933 -0
- data/xsl/common/lt.xml +721 -0
- data/xsl/common/lv.xml +1272 -0
- data/xsl/common/ml.xml +703 -0
- data/xsl/common/mn.xml +773 -0
- data/xsl/common/mr.xml +703 -0
- data/xsl/common/nb.xml +1272 -0
- data/xsl/common/nds.xml +709 -0
- data/xsl/common/nl.xml +703 -0
- data/xsl/common/nn.xml +1272 -0
- data/xsl/common/olink.xsl +1284 -0
- data/xsl/common/or.xml +1272 -0
- data/xsl/common/pa.xml +703 -0
- data/xsl/common/pi.xml +168 -0
- data/xsl/common/pi.xsl +347 -0
- data/xsl/common/pl.xml +721 -0
- data/xsl/common/pt.xml +1272 -0
- data/xsl/common/pt_br.xml +1272 -0
- data/xsl/common/refentry.xsl +1353 -0
- data/xsl/common/ro.xml +1272 -0
- data/xsl/common/ru.xml +769 -0
- data/xsl/common/sk.xml +1272 -0
- data/xsl/common/sl.xml +1272 -0
- data/xsl/common/sq.xml +1272 -0
- data/xsl/common/sr.xml +763 -0
- data/xsl/common/sr_Latn.xml +722 -0
- data/xsl/common/subtitles.xsl +181 -0
- data/xsl/common/sv.xml +707 -0
- data/xsl/common/ta.xml +703 -0
- data/xsl/common/table.xsl +515 -0
- data/xsl/common/targetdatabase.dtd +49 -0
- data/xsl/common/targets.xsl +338 -0
- data/xsl/common/te.xml +703 -0
- data/xsl/common/th.xml +1272 -0
- data/xsl/common/titles.xsl +850 -0
- data/xsl/common/tl.xml +1272 -0
- data/xsl/common/tr.xml +709 -0
- data/xsl/common/uk.xml +769 -0
- data/xsl/common/ur.xml +705 -0
- data/xsl/common/utility.xsl +291 -0
- data/xsl/common/vi.xml +1272 -0
- data/xsl/common/xh.xml +1272 -0
- data/xsl/common/zh.xml +703 -0
- data/xsl/common/zh_cn.xml +703 -0
- data/xsl/common/zh_tw.xml +703 -0
- data/xsl/epub/docbook.xsl +1769 -0
- data/xsl/epub3/chunk.xsl +30 -0
- data/xsl/epub3/docbook-epub.css.xml +142 -0
- data/xsl/epub3/docbook.xsl +20 -0
- data/xsl/epub3/epub3-chunk-mods.xsl +52 -0
- data/xsl/epub3/epub3-element-mods.xsl +2533 -0
- data/xsl/epub3/titlepage.templates.xml +712 -0
- data/xsl/epub3/titlepage.templates.xsl +3842 -0
- data/xsl/lib/lib.xsl +533 -0
- data/xsl/xhtml/admon.xsl +142 -0
- data/xsl/xhtml/annotations.xsl +160 -0
- data/xsl/xhtml/autoidx.xsl +831 -0
- data/xsl/xhtml/autotoc.xsl +706 -0
- data/xsl/xhtml/biblio-iso690.xsl +1302 -0
- data/xsl/xhtml/biblio.xsl +1371 -0
- data/xsl/xhtml/block.xsl +584 -0
- data/xsl/xhtml/callout.xsl +210 -0
- data/xsl/xhtml/chunk-code.xsl +675 -0
- data/xsl/xhtml/chunk-common.xsl +1627 -0
- data/xsl/xhtml/chunker.xsl +317 -0
- data/xsl/xhtml/component.xsl +440 -0
- data/xsl/xhtml/division.xsl +214 -0
- data/xsl/xhtml/ebnf.xsl +331 -0
- data/xsl/xhtml/footnote.xsl +346 -0
- data/xsl/xhtml/formal.xsl +496 -0
- data/xsl/xhtml/glossary.xsl +602 -0
- data/xsl/xhtml/graphics.xsl +1537 -0
- data/xsl/xhtml/html-rtf.xsl +321 -0
- data/xsl/xhtml/html.xsl +690 -0
- data/xsl/xhtml/htmltbl.xsl +102 -0
- data/xsl/xhtml/index.xsl +264 -0
- data/xsl/xhtml/info.xsl +48 -0
- data/xsl/xhtml/inline.xsl +1508 -0
- data/xsl/xhtml/its.xsl +109 -0
- data/xsl/xhtml/keywords.xsl +38 -0
- data/xsl/xhtml/lists.xsl +1227 -0
- data/xsl/xhtml/math.xsl +286 -0
- data/xsl/xhtml/param.xsl +449 -0
- data/xsl/xhtml/pi.xsl +1237 -0
- data/xsl/xhtml/qandaset.xsl +440 -0
- data/xsl/xhtml/refentry.xsl +307 -0
- data/xsl/xhtml/sections.xsl +564 -0
- data/xsl/xhtml/synop.xsl +1623 -0
- data/xsl/xhtml/table.xsl +1179 -0
- data/xsl/xhtml/task.xsl +76 -0
- data/xsl/xhtml/titlepage.templates.xsl +4005 -0
- data/xsl/xhtml/titlepage.xsl +1108 -0
- data/xsl/xhtml/toc.xsl +334 -0
- data/xsl/xhtml/verbatim.xsl +389 -0
- data/xsl/xhtml/xref.xsl +1268 -0
- data/xsl/xhtml5/docbook.xsl +22 -0
- data/xsl/xhtml5/html5-chunk-mods.xsl +112 -0
- data/xsl/xhtml5/html5-element-mods.xsl +791 -0
- data/xsl/xhtml5/xhtml-docbook.xsl +531 -0
- metadata +207 -27
- data/.rvmrc +0 -48
- data/xslt/obfuscate.xsl +0 -12
|
@@ -0,0 +1,1284 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
3
|
+
version="1.0">
|
|
4
|
+
|
|
5
|
+
<!-- ********************************************************************
|
|
6
|
+
$Id: olink.xsl 9817 2013-09-25 22:38:32Z stilor $
|
|
7
|
+
********************************************************************
|
|
8
|
+
|
|
9
|
+
This file is part of the DocBook XSL Stylesheet distribution.
|
|
10
|
+
See ../README or http://docbook.sf.net/ for copyright
|
|
11
|
+
copyright and other information.
|
|
12
|
+
|
|
13
|
+
******************************************************************** -->
|
|
14
|
+
|
|
15
|
+
<!-- Create keys for quickly looking up olink targets -->
|
|
16
|
+
<xsl:key name="targetdoc-key" match="document" use="@targetdoc" />
|
|
17
|
+
<xsl:key name="targetptr-key" match="div|obj"
|
|
18
|
+
use="concat(ancestor::document/@targetdoc, '/',
|
|
19
|
+
@targetptr, '/', ancestor::document/@lang)" />
|
|
20
|
+
|
|
21
|
+
<!-- Customize this template if you want olink errors to be fatal -->
|
|
22
|
+
<xsl:template name="olink.error">
|
|
23
|
+
<xsl:param name="message"/>
|
|
24
|
+
|
|
25
|
+
<xsl:message>
|
|
26
|
+
<xsl:text>Olink error: </xsl:text>
|
|
27
|
+
<xsl:value-of select="$message"/>
|
|
28
|
+
</xsl:message>
|
|
29
|
+
</xsl:template>
|
|
30
|
+
|
|
31
|
+
<!-- Customize this template if you want olink warnings to be fatal -->
|
|
32
|
+
<xsl:template name="olink.warning">
|
|
33
|
+
<xsl:param name="message"/>
|
|
34
|
+
|
|
35
|
+
<xsl:message>
|
|
36
|
+
<xsl:text>Olink warning: </xsl:text>
|
|
37
|
+
<xsl:value-of select="$message"/>
|
|
38
|
+
</xsl:message>
|
|
39
|
+
</xsl:template>
|
|
40
|
+
|
|
41
|
+
<!-- Customize this template if you want unresolved olink pointers to be fatal -->
|
|
42
|
+
<xsl:template name="olink.unresolved">
|
|
43
|
+
<xsl:param name="targetdoc.att"/>
|
|
44
|
+
<xsl:param name="targetptr.att"/>
|
|
45
|
+
|
|
46
|
+
<xsl:message>
|
|
47
|
+
<xsl:text>Error: unresolved olink: targetdoc/targetptr = '</xsl:text>
|
|
48
|
+
<xsl:value-of select="$targetdoc.att"/>
|
|
49
|
+
<xsl:text>/</xsl:text>
|
|
50
|
+
<xsl:value-of select="$targetptr.att"/>
|
|
51
|
+
<xsl:text>'.</xsl:text>
|
|
52
|
+
</xsl:message>
|
|
53
|
+
</xsl:template>
|
|
54
|
+
|
|
55
|
+
<!-- Return filename of database -->
|
|
56
|
+
<xsl:template name="select.target.database">
|
|
57
|
+
<xsl:param name="targetdoc.att" select="''"/>
|
|
58
|
+
<xsl:param name="targetptr.att" select="''"/>
|
|
59
|
+
<xsl:param name="olink.lang" select="''"/>
|
|
60
|
+
|
|
61
|
+
<!-- use root's xml:base if exists -->
|
|
62
|
+
<xsl:variable name="xml.base" select="/*/@xml:base"/>
|
|
63
|
+
|
|
64
|
+
<!-- This selection can be customized if needed -->
|
|
65
|
+
<xsl:variable name="target.database.filename">
|
|
66
|
+
<xsl:choose>
|
|
67
|
+
<xsl:when test="$xml.base != '' and
|
|
68
|
+
not(starts-with($target.database.document, 'file:/')) and
|
|
69
|
+
not(starts-with($target.database.document, '/'))">
|
|
70
|
+
<xsl:call-template name="systemIdToBaseURI">
|
|
71
|
+
<xsl:with-param name="systemId" select="$xml.base"/>
|
|
72
|
+
</xsl:call-template>
|
|
73
|
+
<xsl:value-of select="$target.database.document"/>
|
|
74
|
+
</xsl:when>
|
|
75
|
+
<xsl:otherwise>
|
|
76
|
+
<xsl:value-of select="$target.database.document"/>
|
|
77
|
+
</xsl:otherwise>
|
|
78
|
+
</xsl:choose>
|
|
79
|
+
</xsl:variable>
|
|
80
|
+
|
|
81
|
+
<xsl:variable name="target.database"
|
|
82
|
+
select="document($target.database.filename,/)"/>
|
|
83
|
+
|
|
84
|
+
<xsl:choose>
|
|
85
|
+
<!-- Was the database document parameter not set? -->
|
|
86
|
+
<xsl:when test="$target.database.document = ''">
|
|
87
|
+
<xsl:call-template name="olink.error">
|
|
88
|
+
<xsl:with-param name="message">
|
|
89
|
+
<xsl:text>olinks not processed: must specify a </xsl:text>
|
|
90
|
+
<xsl:text>$target.database.document parameter </xsl:text>
|
|
91
|
+
<xsl:text>when using olinks with targetdoc </xsl:text>
|
|
92
|
+
<xsl:text>and targetptr attributes.</xsl:text>
|
|
93
|
+
</xsl:with-param>
|
|
94
|
+
</xsl:call-template>
|
|
95
|
+
</xsl:when>
|
|
96
|
+
<xsl:when test="namespace-uri($target.database/*) != ''">
|
|
97
|
+
<xsl:call-template name="olink.error">
|
|
98
|
+
<xsl:with-param name="message">
|
|
99
|
+
<xsl:text>the targetset element and children in '</xsl:text>
|
|
100
|
+
<xsl:value-of select="$target.database.document"/>
|
|
101
|
+
<xsl:text>' should not be in any namespace.</xsl:text>
|
|
102
|
+
</xsl:with-param>
|
|
103
|
+
</xsl:call-template>
|
|
104
|
+
</xsl:when>
|
|
105
|
+
<!-- Did it not open? Should be a targetset element -->
|
|
106
|
+
<xsl:when test="not($target.database/*)">
|
|
107
|
+
<xsl:call-template name="olink.error">
|
|
108
|
+
<xsl:with-param name="message">
|
|
109
|
+
<xsl:text>could not open target database '</xsl:text>
|
|
110
|
+
<xsl:value-of select="$target.database.filename"/>
|
|
111
|
+
<xsl:text>'.</xsl:text>
|
|
112
|
+
</xsl:with-param>
|
|
113
|
+
</xsl:call-template>
|
|
114
|
+
</xsl:when>
|
|
115
|
+
<xsl:otherwise>
|
|
116
|
+
<xsl:value-of select="$target.database.filename"/>
|
|
117
|
+
</xsl:otherwise>
|
|
118
|
+
</xsl:choose>
|
|
119
|
+
</xsl:template>
|
|
120
|
+
|
|
121
|
+
<xsl:template name="select.olink.key">
|
|
122
|
+
<xsl:param name="targetdoc.att" select="''"/>
|
|
123
|
+
<xsl:param name="targetptr.att" select="''"/>
|
|
124
|
+
<xsl:param name="olink.lang" select="''"/>
|
|
125
|
+
<xsl:param name="target.database"/>
|
|
126
|
+
|
|
127
|
+
<xsl:if test="$target.database/*">
|
|
128
|
+
<xsl:variable name="olink.fallback.sequence">
|
|
129
|
+
<xsl:call-template name="select.olink.lang.fallback">
|
|
130
|
+
<xsl:with-param name="olink.lang" select="$olink.lang"/>
|
|
131
|
+
</xsl:call-template>
|
|
132
|
+
</xsl:variable>
|
|
133
|
+
|
|
134
|
+
<!-- Recurse through the languages until you find a match -->
|
|
135
|
+
<xsl:call-template name="select.olink.key.in.lang">
|
|
136
|
+
<xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
|
|
137
|
+
<xsl:with-param name="targetptr.att" select="$targetptr.att"/>
|
|
138
|
+
<xsl:with-param name="olink.lang" select="$olink.lang"/>
|
|
139
|
+
<xsl:with-param name="target.database" select="$target.database"/>
|
|
140
|
+
<xsl:with-param name="fallback.index" select="1"/>
|
|
141
|
+
<xsl:with-param name="olink.fallback.sequence"
|
|
142
|
+
select="$olink.fallback.sequence"/>
|
|
143
|
+
</xsl:call-template>
|
|
144
|
+
</xsl:if>
|
|
145
|
+
|
|
146
|
+
</xsl:template>
|
|
147
|
+
|
|
148
|
+
<!-- Locate olink key in a particular language -->
|
|
149
|
+
<xsl:template name="select.olink.key.in.lang">
|
|
150
|
+
<xsl:param name="targetdoc.att" select="''"/>
|
|
151
|
+
<xsl:param name="targetptr.att" select="''"/>
|
|
152
|
+
<xsl:param name="olink.lang" select="''"/>
|
|
153
|
+
<xsl:param name="target.database"/>
|
|
154
|
+
<xsl:param name="fallback.index" select="1"/>
|
|
155
|
+
<xsl:param name="olink.fallback.sequence" select="''"/>
|
|
156
|
+
|
|
157
|
+
<xsl:variable name="target.lang">
|
|
158
|
+
<xsl:call-template name="select.target.lang">
|
|
159
|
+
<xsl:with-param name="fallback.index" select="$fallback.index"/>
|
|
160
|
+
<xsl:with-param name="olink.fallback.sequence"
|
|
161
|
+
select="$olink.fallback.sequence"/>
|
|
162
|
+
</xsl:call-template>
|
|
163
|
+
</xsl:variable>
|
|
164
|
+
|
|
165
|
+
<xsl:if test="$olink.debug != 0">
|
|
166
|
+
<xsl:message><xsl:text>Olink debug: cases for targetdoc='</xsl:text>
|
|
167
|
+
<xsl:value-of select="$targetdoc.att"/>
|
|
168
|
+
<xsl:text>' and targetptr='</xsl:text>
|
|
169
|
+
<xsl:value-of select="$targetptr.att"/>
|
|
170
|
+
<xsl:text>' in language '</xsl:text>
|
|
171
|
+
<xsl:value-of select="$target.lang"/>
|
|
172
|
+
<xsl:text>'.</xsl:text>
|
|
173
|
+
</xsl:message>
|
|
174
|
+
</xsl:if>
|
|
175
|
+
|
|
176
|
+
<!-- Customize these cases if you want different selection logic -->
|
|
177
|
+
<xsl:variable name="CaseA">
|
|
178
|
+
<!-- targetdoc.att = not blank
|
|
179
|
+
targetptr.att = not blank
|
|
180
|
+
-->
|
|
181
|
+
<xsl:if test="$targetdoc.att != '' and
|
|
182
|
+
$targetptr.att != ''">
|
|
183
|
+
<xsl:for-each select="$target.database">
|
|
184
|
+
<xsl:variable name="key"
|
|
185
|
+
select="concat($targetdoc.att, '/',
|
|
186
|
+
$targetptr.att, '/',
|
|
187
|
+
$target.lang)"/>
|
|
188
|
+
<xsl:choose>
|
|
189
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
190
|
+
<xsl:value-of select="$key"/>
|
|
191
|
+
<xsl:if test="$olink.debug != 0">
|
|
192
|
+
<xsl:message>Olink debug: CaseA matched.</xsl:message>
|
|
193
|
+
</xsl:if>
|
|
194
|
+
</xsl:when>
|
|
195
|
+
<xsl:when test="$olink.debug != 0">
|
|
196
|
+
<xsl:message>Olink debug: CaseA NOT matched</xsl:message>
|
|
197
|
+
</xsl:when>
|
|
198
|
+
</xsl:choose>
|
|
199
|
+
</xsl:for-each>
|
|
200
|
+
</xsl:if>
|
|
201
|
+
</xsl:variable>
|
|
202
|
+
|
|
203
|
+
<xsl:variable name="CaseB">
|
|
204
|
+
<!-- targetdoc.att = not blank
|
|
205
|
+
targetptr.att = not blank
|
|
206
|
+
prefer.internal.olink = not zero
|
|
207
|
+
current.docid = not blank
|
|
208
|
+
-->
|
|
209
|
+
<xsl:if test="$targetdoc.att != '' and
|
|
210
|
+
$targetptr.att != '' and
|
|
211
|
+
$current.docid != '' and
|
|
212
|
+
$prefer.internal.olink != 0">
|
|
213
|
+
<xsl:for-each select="$target.database">
|
|
214
|
+
<xsl:variable name="key"
|
|
215
|
+
select="concat($current.docid, '/',
|
|
216
|
+
$targetptr.att, '/',
|
|
217
|
+
$target.lang)"/>
|
|
218
|
+
<xsl:choose>
|
|
219
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
220
|
+
<xsl:value-of select="$key"/>
|
|
221
|
+
<xsl:if test="$olink.debug != 0">
|
|
222
|
+
<xsl:message>Olink debug: CaseB matched.</xsl:message>
|
|
223
|
+
</xsl:if>
|
|
224
|
+
</xsl:when>
|
|
225
|
+
<xsl:when test="$olink.debug != 0">
|
|
226
|
+
<xsl:message>Olink debug: CaseB NOT matched</xsl:message>
|
|
227
|
+
</xsl:when>
|
|
228
|
+
</xsl:choose>
|
|
229
|
+
</xsl:for-each>
|
|
230
|
+
</xsl:if>
|
|
231
|
+
</xsl:variable>
|
|
232
|
+
|
|
233
|
+
<xsl:variable name="CaseC">
|
|
234
|
+
<!-- targetdoc.att = blank
|
|
235
|
+
targetptr.att = not blank
|
|
236
|
+
current.docid = not blank
|
|
237
|
+
-->
|
|
238
|
+
<xsl:if test="string-length($targetdoc.att) = 0 and
|
|
239
|
+
$targetptr.att != '' and
|
|
240
|
+
$current.docid != ''">
|
|
241
|
+
<!-- Must use a for-each to change context for keys to work -->
|
|
242
|
+
<xsl:for-each select="$target.database">
|
|
243
|
+
<xsl:variable name="key"
|
|
244
|
+
select="concat($current.docid, '/',
|
|
245
|
+
$targetptr.att, '/',
|
|
246
|
+
$target.lang)"/>
|
|
247
|
+
<xsl:choose>
|
|
248
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
249
|
+
<xsl:value-of select="$key"/>
|
|
250
|
+
<xsl:if test="$olink.debug != 0">
|
|
251
|
+
<xsl:message>Olink debug: CaseC matched.</xsl:message>
|
|
252
|
+
</xsl:if>
|
|
253
|
+
</xsl:when>
|
|
254
|
+
<xsl:when test="$olink.debug != 0">
|
|
255
|
+
<xsl:message>Olink debug: CaseC NOT matched.</xsl:message>
|
|
256
|
+
</xsl:when>
|
|
257
|
+
</xsl:choose>
|
|
258
|
+
</xsl:for-each>
|
|
259
|
+
</xsl:if>
|
|
260
|
+
</xsl:variable>
|
|
261
|
+
|
|
262
|
+
<xsl:variable name="CaseD">
|
|
263
|
+
<!-- targetdoc.att = blank
|
|
264
|
+
targetptr.att = not blank
|
|
265
|
+
current.docid = blank
|
|
266
|
+
-->
|
|
267
|
+
<!-- This is possible if only one document in the database -->
|
|
268
|
+
<xsl:if test="string-length($targetdoc.att) = 0 and
|
|
269
|
+
$targetptr.att != '' and
|
|
270
|
+
string-length($current.docid) = 0 and
|
|
271
|
+
count($target.database//document) = 1">
|
|
272
|
+
<xsl:for-each select="$target.database">
|
|
273
|
+
<xsl:variable name="key"
|
|
274
|
+
select="concat(.//document/@targetdoc, '/',
|
|
275
|
+
$targetptr.att, '/',
|
|
276
|
+
$target.lang)"/>
|
|
277
|
+
<xsl:choose>
|
|
278
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
279
|
+
<xsl:value-of select="$key"/>
|
|
280
|
+
<xsl:if test="$olink.debug != 0">
|
|
281
|
+
<xsl:message>Olink debug: CaseD matched.</xsl:message>
|
|
282
|
+
</xsl:if>
|
|
283
|
+
</xsl:when>
|
|
284
|
+
<xsl:when test="$olink.debug != 0">
|
|
285
|
+
<xsl:message>Olink debug: CaseD NOT matched</xsl:message>
|
|
286
|
+
</xsl:when>
|
|
287
|
+
</xsl:choose>
|
|
288
|
+
</xsl:for-each>
|
|
289
|
+
</xsl:if>
|
|
290
|
+
</xsl:variable>
|
|
291
|
+
|
|
292
|
+
<xsl:variable name="CaseE">
|
|
293
|
+
<!-- targetdoc.att = not blank
|
|
294
|
+
targetptr.att = blank
|
|
295
|
+
-->
|
|
296
|
+
<xsl:if test="$targetdoc.att != '' and
|
|
297
|
+
string-length($targetptr.att) = 0">
|
|
298
|
+
|
|
299
|
+
<!-- Try the document's root element id -->
|
|
300
|
+
<xsl:variable name="rootid">
|
|
301
|
+
<xsl:choose>
|
|
302
|
+
<xsl:when test="$target.lang != ''">
|
|
303
|
+
<xsl:value-of select="$target.database//document[@targetdoc = $targetdoc.att and @lang = $target.lang]/*[1]/@targetptr"/>
|
|
304
|
+
</xsl:when>
|
|
305
|
+
<xsl:otherwise>
|
|
306
|
+
<xsl:value-of select="$target.database//document[@targetdoc = $targetdoc.att and not(@lang)]/*[1]/@targetptr"/>
|
|
307
|
+
</xsl:otherwise>
|
|
308
|
+
</xsl:choose>
|
|
309
|
+
</xsl:variable>
|
|
310
|
+
|
|
311
|
+
<xsl:for-each select="$target.database">
|
|
312
|
+
<xsl:variable name="key"
|
|
313
|
+
select="concat($targetdoc.att, '/',
|
|
314
|
+
$rootid, '/',
|
|
315
|
+
$target.lang)"/>
|
|
316
|
+
<xsl:choose>
|
|
317
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
318
|
+
<xsl:value-of select="$key"/>
|
|
319
|
+
<xsl:if test="$olink.debug != 0">
|
|
320
|
+
<xsl:message>Olink debug: CaseE matched.</xsl:message>
|
|
321
|
+
</xsl:if>
|
|
322
|
+
</xsl:when>
|
|
323
|
+
<xsl:when test="$olink.debug != 0">
|
|
324
|
+
<xsl:message>Olink debug: CaseE NOT matched.</xsl:message>
|
|
325
|
+
</xsl:when>
|
|
326
|
+
</xsl:choose>
|
|
327
|
+
</xsl:for-each>
|
|
328
|
+
</xsl:if>
|
|
329
|
+
</xsl:variable>
|
|
330
|
+
|
|
331
|
+
<xsl:variable name="CaseF">
|
|
332
|
+
<!-- targetdoc.att = not blank
|
|
333
|
+
targetptr.att = blank
|
|
334
|
+
prefer.internal.olink = not zero
|
|
335
|
+
current.docid = not blank
|
|
336
|
+
-->
|
|
337
|
+
<xsl:if test="$targetdoc.att != '' and
|
|
338
|
+
string-length($targetptr.att) = 0 and
|
|
339
|
+
$current.docid != '' and
|
|
340
|
+
$prefer.internal.olink != 0">
|
|
341
|
+
<!-- Try the document's root element id -->
|
|
342
|
+
<xsl:variable name="rootid">
|
|
343
|
+
<xsl:choose>
|
|
344
|
+
<xsl:when test="$target.lang != ''">
|
|
345
|
+
<xsl:value-of select="$target.database//document[@targetdoc = $current.docid and @lang = $target.lang]/*[1]/@targetptr"/>
|
|
346
|
+
</xsl:when>
|
|
347
|
+
<xsl:otherwise>
|
|
348
|
+
<xsl:value-of select="$target.database//document[@targetdoc = $current.docid and not(@lang)]/*[1]/@targetptr"/>
|
|
349
|
+
</xsl:otherwise>
|
|
350
|
+
</xsl:choose>
|
|
351
|
+
</xsl:variable>
|
|
352
|
+
|
|
353
|
+
<xsl:for-each select="$target.database">
|
|
354
|
+
<xsl:variable name="key"
|
|
355
|
+
select="concat($current.docid, '/',
|
|
356
|
+
$rootid, '/',
|
|
357
|
+
$target.lang)"/>
|
|
358
|
+
<xsl:choose>
|
|
359
|
+
<xsl:when test="key('targetptr-key', $key)[1]/@href != ''">
|
|
360
|
+
<xsl:value-of select="$key"/>
|
|
361
|
+
<xsl:if test="$olink.debug != 0">
|
|
362
|
+
<xsl:message>Olink debug: CaseF matched.</xsl:message>
|
|
363
|
+
</xsl:if>
|
|
364
|
+
</xsl:when>
|
|
365
|
+
<xsl:when test="$olink.debug != 0">
|
|
366
|
+
<xsl:message>Olink debug: CaseF NOT matched.</xsl:message>
|
|
367
|
+
</xsl:when>
|
|
368
|
+
</xsl:choose>
|
|
369
|
+
</xsl:for-each>
|
|
370
|
+
</xsl:if>
|
|
371
|
+
</xsl:variable>
|
|
372
|
+
|
|
373
|
+
<!-- Now select the best match. Customize the order if needed -->
|
|
374
|
+
<xsl:variable name="selected.key">
|
|
375
|
+
<xsl:choose>
|
|
376
|
+
<xsl:when test="$CaseB != ''">
|
|
377
|
+
<xsl:value-of select="$CaseB"/>
|
|
378
|
+
<xsl:if test="$olink.debug != 0">
|
|
379
|
+
<xsl:message>
|
|
380
|
+
<xsl:text>Olink debug: CaseB key is the final selection: </xsl:text>
|
|
381
|
+
<xsl:value-of select="$CaseB"/>
|
|
382
|
+
</xsl:message>
|
|
383
|
+
</xsl:if>
|
|
384
|
+
</xsl:when>
|
|
385
|
+
<xsl:when test="$CaseA != ''">
|
|
386
|
+
<xsl:value-of select="$CaseA"/>
|
|
387
|
+
<xsl:if test="$olink.debug != 0">
|
|
388
|
+
<xsl:message>
|
|
389
|
+
<xsl:text>Olink debug: CaseA key is the final selection: </xsl:text>
|
|
390
|
+
<xsl:value-of select="$CaseA"/>
|
|
391
|
+
</xsl:message>
|
|
392
|
+
</xsl:if>
|
|
393
|
+
</xsl:when>
|
|
394
|
+
<xsl:when test="$CaseC != ''">
|
|
395
|
+
<xsl:value-of select="$CaseC"/>
|
|
396
|
+
<xsl:if test="$olink.debug != 0">
|
|
397
|
+
<xsl:message>
|
|
398
|
+
<xsl:text>Olink debug: CaseC key is the final selection: </xsl:text>
|
|
399
|
+
<xsl:value-of select="$CaseC"/>
|
|
400
|
+
</xsl:message>
|
|
401
|
+
</xsl:if>
|
|
402
|
+
</xsl:when>
|
|
403
|
+
<xsl:when test="$CaseD != ''">
|
|
404
|
+
<xsl:value-of select="$CaseD"/>
|
|
405
|
+
<xsl:if test="$olink.debug != 0">
|
|
406
|
+
<xsl:message>
|
|
407
|
+
<xsl:text>Olink debug: CaseD key is the final selection: </xsl:text>
|
|
408
|
+
<xsl:value-of select="$CaseD"/>
|
|
409
|
+
</xsl:message>
|
|
410
|
+
</xsl:if>
|
|
411
|
+
</xsl:when>
|
|
412
|
+
<xsl:when test="$CaseF != ''">
|
|
413
|
+
<xsl:value-of select="$CaseF"/>
|
|
414
|
+
<xsl:if test="$olink.debug != 0">
|
|
415
|
+
<xsl:message>
|
|
416
|
+
<xsl:text>Olink debug: CaseF key is the final selection: </xsl:text>
|
|
417
|
+
<xsl:value-of select="$CaseF"/>
|
|
418
|
+
</xsl:message>
|
|
419
|
+
</xsl:if>
|
|
420
|
+
</xsl:when>
|
|
421
|
+
<xsl:when test="$CaseE != ''">
|
|
422
|
+
<xsl:value-of select="$CaseE"/>
|
|
423
|
+
<xsl:if test="$olink.debug != 0">
|
|
424
|
+
<xsl:message>
|
|
425
|
+
<xsl:text>Olink debug: CaseE key is the final selection: </xsl:text>
|
|
426
|
+
<xsl:value-of select="$CaseE"/>
|
|
427
|
+
</xsl:message>
|
|
428
|
+
</xsl:if>
|
|
429
|
+
</xsl:when>
|
|
430
|
+
<xsl:otherwise>
|
|
431
|
+
<xsl:if test="$olink.debug != 0">
|
|
432
|
+
<xsl:message>
|
|
433
|
+
<xsl:text>Olink debug: No case matched for lang '</xsl:text>
|
|
434
|
+
<xsl:value-of select="$target.lang"/>
|
|
435
|
+
<xsl:text>'.</xsl:text>
|
|
436
|
+
</xsl:message>
|
|
437
|
+
</xsl:if>
|
|
438
|
+
</xsl:otherwise>
|
|
439
|
+
</xsl:choose>
|
|
440
|
+
</xsl:variable>
|
|
441
|
+
|
|
442
|
+
<xsl:choose>
|
|
443
|
+
<xsl:when test="$selected.key != ''">
|
|
444
|
+
<xsl:value-of select="$selected.key"/>
|
|
445
|
+
</xsl:when>
|
|
446
|
+
<xsl:when test="string-length($selected.key) = 0 and
|
|
447
|
+
string-length($target.lang) = 0">
|
|
448
|
+
<!-- No match on last try, and we are done -->
|
|
449
|
+
</xsl:when>
|
|
450
|
+
<xsl:otherwise>
|
|
451
|
+
<!-- Recurse through next language -->
|
|
452
|
+
<xsl:call-template name="select.olink.key.in.lang">
|
|
453
|
+
<xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
|
|
454
|
+
<xsl:with-param name="targetptr.att" select="$targetptr.att"/>
|
|
455
|
+
<xsl:with-param name="olink.lang" select="$olink.lang"/>
|
|
456
|
+
<xsl:with-param name="target.database" select="$target.database"/>
|
|
457
|
+
<xsl:with-param name="fallback.index" select="$fallback.index + 1"/>
|
|
458
|
+
<xsl:with-param name="olink.fallback.sequence"
|
|
459
|
+
select="$olink.fallback.sequence"/>
|
|
460
|
+
</xsl:call-template>
|
|
461
|
+
</xsl:otherwise>
|
|
462
|
+
</xsl:choose>
|
|
463
|
+
|
|
464
|
+
</xsl:template>
|
|
465
|
+
|
|
466
|
+
<xsl:template name="select.target.lang">
|
|
467
|
+
<xsl:param name="fallback.index" select="1"/>
|
|
468
|
+
<xsl:param name="olink.fallback.sequence" select="''"/>
|
|
469
|
+
|
|
470
|
+
<!-- recurse backwards to find the lang matching the index -->
|
|
471
|
+
<xsl:variable name="firstlang"
|
|
472
|
+
select="substring-before($olink.fallback.sequence, ' ')"/>
|
|
473
|
+
<xsl:variable name="rest"
|
|
474
|
+
select="substring-after($olink.fallback.sequence, ' ')"/>
|
|
475
|
+
<xsl:choose>
|
|
476
|
+
<xsl:when test="$fallback.index = 1">
|
|
477
|
+
<xsl:value-of select="$firstlang"/>
|
|
478
|
+
</xsl:when>
|
|
479
|
+
<xsl:when test="$fallback.index > 1">
|
|
480
|
+
<xsl:call-template name="select.target.lang">
|
|
481
|
+
<xsl:with-param name="fallback.index" select="$fallback.index - 1"/>
|
|
482
|
+
<xsl:with-param name="olink.fallback.sequence"
|
|
483
|
+
select="$rest"/>
|
|
484
|
+
</xsl:call-template>
|
|
485
|
+
</xsl:when>
|
|
486
|
+
<xsl:otherwise>
|
|
487
|
+
</xsl:otherwise>
|
|
488
|
+
</xsl:choose>
|
|
489
|
+
</xsl:template>
|
|
490
|
+
|
|
491
|
+
<xsl:template name="select.olink.lang.fallback">
|
|
492
|
+
<xsl:param name="olink.lang" select="''"/>
|
|
493
|
+
|
|
494
|
+
<!-- Prefer language of the olink element -->
|
|
495
|
+
<xsl:value-of select="concat(normalize-space(concat($olink.lang, ' ',
|
|
496
|
+
$olink.lang.fallback.sequence)), ' ')"/>
|
|
497
|
+
</xsl:template>
|
|
498
|
+
|
|
499
|
+
<!-- Returns the complete olink href value if found -->
|
|
500
|
+
<xsl:template name="make.olink.href">
|
|
501
|
+
<xsl:param name="olink.key" select="''"/>
|
|
502
|
+
<xsl:param name="target.database"/>
|
|
503
|
+
|
|
504
|
+
<xsl:if test="$olink.key != ''">
|
|
505
|
+
<xsl:variable name="target.href" >
|
|
506
|
+
<xsl:for-each select="$target.database" >
|
|
507
|
+
<xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href" />
|
|
508
|
+
</xsl:for-each>
|
|
509
|
+
</xsl:variable>
|
|
510
|
+
|
|
511
|
+
<xsl:variable name="targetdoc">
|
|
512
|
+
<xsl:value-of select="substring-before($olink.key, '/')"/>
|
|
513
|
+
</xsl:variable>
|
|
514
|
+
|
|
515
|
+
<!-- Does the target database use a sitemap? -->
|
|
516
|
+
<xsl:variable name="use.sitemap">
|
|
517
|
+
<xsl:choose>
|
|
518
|
+
<xsl:when test="$target.database//sitemap">1</xsl:when>
|
|
519
|
+
<xsl:otherwise>0</xsl:otherwise>
|
|
520
|
+
</xsl:choose>
|
|
521
|
+
</xsl:variable>
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
<!-- Get the baseuri for this targetptr -->
|
|
525
|
+
<xsl:variable name="baseuri" >
|
|
526
|
+
<xsl:choose>
|
|
527
|
+
<!-- Does the database use a sitemap? -->
|
|
528
|
+
<xsl:when test="$use.sitemap != 0" >
|
|
529
|
+
<xsl:choose>
|
|
530
|
+
<!-- Was current.docid parameter set? -->
|
|
531
|
+
<xsl:when test="$current.docid != ''">
|
|
532
|
+
<!-- Was it found in the database? -->
|
|
533
|
+
<xsl:variable name="currentdoc.key" >
|
|
534
|
+
<xsl:for-each select="$target.database" >
|
|
535
|
+
<xsl:value-of select="key('targetdoc-key',
|
|
536
|
+
$current.docid)[1]/@targetdoc" />
|
|
537
|
+
</xsl:for-each>
|
|
538
|
+
</xsl:variable>
|
|
539
|
+
<xsl:choose>
|
|
540
|
+
<xsl:when test="$currentdoc.key != ''">
|
|
541
|
+
<xsl:for-each select="$target.database" >
|
|
542
|
+
<xsl:call-template name="targetpath" >
|
|
543
|
+
<xsl:with-param name="dirnode"
|
|
544
|
+
select="key('targetdoc-key', $current.docid)[1]/parent::dir"/>
|
|
545
|
+
<xsl:with-param name="targetdoc" select="$targetdoc"/>
|
|
546
|
+
</xsl:call-template>
|
|
547
|
+
</xsl:for-each>
|
|
548
|
+
</xsl:when>
|
|
549
|
+
<xsl:otherwise>
|
|
550
|
+
<xsl:call-template name="olink.error">
|
|
551
|
+
<xsl:with-param name="message">
|
|
552
|
+
<xsl:text>cannot compute relative </xsl:text>
|
|
553
|
+
<xsl:text>sitemap path because $current.docid '</xsl:text>
|
|
554
|
+
<xsl:value-of select="$current.docid"/>
|
|
555
|
+
<xsl:text>' not found in target database.</xsl:text>
|
|
556
|
+
</xsl:with-param>
|
|
557
|
+
</xsl:call-template>
|
|
558
|
+
</xsl:otherwise>
|
|
559
|
+
</xsl:choose>
|
|
560
|
+
</xsl:when>
|
|
561
|
+
<xsl:otherwise>
|
|
562
|
+
<xsl:call-template name="olink.error">
|
|
563
|
+
<xsl:with-param name="message">
|
|
564
|
+
<xsl:text>cannot compute relative </xsl:text>
|
|
565
|
+
<xsl:text>sitemap path without $current.docid parameter</xsl:text>
|
|
566
|
+
</xsl:with-param>
|
|
567
|
+
</xsl:call-template>
|
|
568
|
+
</xsl:otherwise>
|
|
569
|
+
</xsl:choose>
|
|
570
|
+
<!-- In either case, add baseuri from its document entry-->
|
|
571
|
+
<xsl:variable name="docbaseuri">
|
|
572
|
+
<xsl:for-each select="$target.database" >
|
|
573
|
+
<xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri" />
|
|
574
|
+
</xsl:for-each>
|
|
575
|
+
</xsl:variable>
|
|
576
|
+
<xsl:if test="$docbaseuri != ''" >
|
|
577
|
+
<xsl:value-of select="$docbaseuri"/>
|
|
578
|
+
</xsl:if>
|
|
579
|
+
</xsl:when>
|
|
580
|
+
<!-- No database sitemap in use -->
|
|
581
|
+
<xsl:otherwise>
|
|
582
|
+
<!-- Just use any baseuri from its document entry -->
|
|
583
|
+
<xsl:variable name="docbaseuri">
|
|
584
|
+
<xsl:for-each select="$target.database" >
|
|
585
|
+
<xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri" />
|
|
586
|
+
</xsl:for-each>
|
|
587
|
+
</xsl:variable>
|
|
588
|
+
<xsl:if test="$docbaseuri != ''" >
|
|
589
|
+
<xsl:value-of select="$docbaseuri"/>
|
|
590
|
+
</xsl:if>
|
|
591
|
+
</xsl:otherwise>
|
|
592
|
+
</xsl:choose>
|
|
593
|
+
</xsl:variable>
|
|
594
|
+
|
|
595
|
+
<!-- Is this olink to be active? -->
|
|
596
|
+
<xsl:variable name="active.olink">
|
|
597
|
+
<xsl:choose>
|
|
598
|
+
<xsl:when test="$activate.external.olinks = 0">
|
|
599
|
+
<xsl:choose>
|
|
600
|
+
<xsl:when test="$current.docid = ''">1</xsl:when>
|
|
601
|
+
<xsl:when test="$targetdoc = ''">1</xsl:when>
|
|
602
|
+
<xsl:when test="$targetdoc = $current.docid">1</xsl:when>
|
|
603
|
+
<xsl:otherwise>0</xsl:otherwise>
|
|
604
|
+
</xsl:choose>
|
|
605
|
+
</xsl:when>
|
|
606
|
+
<xsl:otherwise>1</xsl:otherwise>
|
|
607
|
+
</xsl:choose>
|
|
608
|
+
</xsl:variable>
|
|
609
|
+
|
|
610
|
+
<!-- Form the href information -->
|
|
611
|
+
<xsl:if test="$active.olink != 0">
|
|
612
|
+
<xsl:if test="$baseuri != ''">
|
|
613
|
+
<xsl:value-of select="$baseuri"/>
|
|
614
|
+
<xsl:if test="substring($target.href,1,1) != '#'">
|
|
615
|
+
<!--xsl:text>/</xsl:text-->
|
|
616
|
+
</xsl:if>
|
|
617
|
+
</xsl:if>
|
|
618
|
+
<!-- optionally turn off frag for PDF references -->
|
|
619
|
+
<xsl:if test="not($insert.olink.pdf.frag = 0 and
|
|
620
|
+
translate(substring($baseuri, string-length($baseuri) - 3),
|
|
621
|
+
'PDF', 'pdf') = '.pdf'
|
|
622
|
+
and starts-with($target.href, '#') )">
|
|
623
|
+
<xsl:value-of select="$target.href"/>
|
|
624
|
+
</xsl:if>
|
|
625
|
+
</xsl:if>
|
|
626
|
+
</xsl:if>
|
|
627
|
+
</xsl:template>
|
|
628
|
+
|
|
629
|
+
<!-- Computes the href of the object containing the olink element -->
|
|
630
|
+
<xsl:template name="olink.from.uri">
|
|
631
|
+
<xsl:param name="target.database"/>
|
|
632
|
+
<xsl:param name="object" select="NotAnElement"/>
|
|
633
|
+
<xsl:param name="object.targetdoc" select="$current.docid"/>
|
|
634
|
+
<xsl:param name="object.lang"
|
|
635
|
+
select="concat($object/ancestor::*[last()]/@lang,
|
|
636
|
+
$object/ancestor::*[last()]/@xml:lang)"/>
|
|
637
|
+
|
|
638
|
+
<xsl:variable name="parent.id">
|
|
639
|
+
<xsl:call-template name="object.id">
|
|
640
|
+
<xsl:with-param name="object" select="$object"/>
|
|
641
|
+
</xsl:call-template>
|
|
642
|
+
</xsl:variable>
|
|
643
|
+
|
|
644
|
+
<!-- Get the olink key for the parent of olink element -->
|
|
645
|
+
<xsl:variable name="from.key">
|
|
646
|
+
<xsl:call-template name="select.olink.key">
|
|
647
|
+
<xsl:with-param name="targetdoc.att" select="$object.targetdoc"/>
|
|
648
|
+
<xsl:with-param name="targetptr.att" select="$parent.id"/>
|
|
649
|
+
<xsl:with-param name="olink.lang" select="$object.lang"/>
|
|
650
|
+
<xsl:with-param name="target.database" select="$target.database"/>
|
|
651
|
+
</xsl:call-template>
|
|
652
|
+
</xsl:variable>
|
|
653
|
+
|
|
654
|
+
<xsl:variable name="from.olink.href">
|
|
655
|
+
<xsl:for-each select="$target.database" >
|
|
656
|
+
<xsl:value-of select="key('targetptr-key', $from.key)[1]/@href" />
|
|
657
|
+
</xsl:for-each>
|
|
658
|
+
</xsl:variable>
|
|
659
|
+
|
|
660
|
+
<xsl:choose>
|
|
661
|
+
<!-- we found the olink object -->
|
|
662
|
+
<xsl:when test="$from.olink.href != ''">
|
|
663
|
+
<xsl:value-of select="$from.olink.href"/>
|
|
664
|
+
</xsl:when>
|
|
665
|
+
<xsl:when test="not($object/parent::*)">
|
|
666
|
+
<xsl:value-of select="$from.olink.href"/>
|
|
667
|
+
</xsl:when>
|
|
668
|
+
<xsl:otherwise>
|
|
669
|
+
<!-- recurse upward in current document -->
|
|
670
|
+
<xsl:call-template name="olink.from.uri">
|
|
671
|
+
<xsl:with-param name="target.database" select="$target.database"/>
|
|
672
|
+
<xsl:with-param name="object" select="$object/parent::*"/>
|
|
673
|
+
<xsl:with-param name="object.targetdoc" select="$object.targetdoc"/>
|
|
674
|
+
<xsl:with-param name="object.lang" select="$object.lang"/>
|
|
675
|
+
</xsl:call-template>
|
|
676
|
+
</xsl:otherwise>
|
|
677
|
+
</xsl:choose>
|
|
678
|
+
|
|
679
|
+
</xsl:template>
|
|
680
|
+
|
|
681
|
+
<xsl:template name="olink.hottext">
|
|
682
|
+
<xsl:param name="target.database"/>
|
|
683
|
+
<xsl:param name="olink.lang" select="''"/>
|
|
684
|
+
<xsl:param name="olink.key" select="''"/>
|
|
685
|
+
<xsl:param name="referrer" select="."/>
|
|
686
|
+
<xsl:param name="xrefstyle">
|
|
687
|
+
<xsl:apply-templates select="." mode="xrefstyle">
|
|
688
|
+
<xsl:with-param name="olink.key" select="$olink.key"/>
|
|
689
|
+
<xsl:with-param name="referrer" select="$referrer"/>
|
|
690
|
+
</xsl:apply-templates>
|
|
691
|
+
</xsl:param>
|
|
692
|
+
|
|
693
|
+
<xsl:choose>
|
|
694
|
+
<!-- If it has elements or text (not just PI or comment) -->
|
|
695
|
+
<xsl:when test="child::text() or child::*">
|
|
696
|
+
<xsl:apply-templates/>
|
|
697
|
+
</xsl:when>
|
|
698
|
+
<xsl:when test="$olink.key != ''">
|
|
699
|
+
<!-- Get the xref text for this record -->
|
|
700
|
+
<xsl:variable name="xref.text" >
|
|
701
|
+
<xsl:for-each select="$target.database" >
|
|
702
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
703
|
+
<xsl:with-param name="data"
|
|
704
|
+
select="key('targetptr-key', $olink.key)[1]/xreftext/node()" />
|
|
705
|
+
</xsl:call-template>
|
|
706
|
+
</xsl:for-each>
|
|
707
|
+
</xsl:variable>
|
|
708
|
+
|
|
709
|
+
<xsl:variable name="xref.number" >
|
|
710
|
+
<xsl:for-each select="$target.database" >
|
|
711
|
+
<xsl:value-of select="key('targetptr-key', $olink.key)[1]/@number" />
|
|
712
|
+
</xsl:for-each>
|
|
713
|
+
</xsl:variable>
|
|
714
|
+
|
|
715
|
+
<xsl:variable name="target.elem" >
|
|
716
|
+
<xsl:for-each select="$target.database" >
|
|
717
|
+
<xsl:value-of select="key('targetptr-key', $olink.key)[1]/@element" />
|
|
718
|
+
</xsl:for-each>
|
|
719
|
+
</xsl:variable>
|
|
720
|
+
|
|
721
|
+
<xsl:variable name="lang">
|
|
722
|
+
<xsl:variable name="candidate">
|
|
723
|
+
<xsl:for-each select="$target.database" >
|
|
724
|
+
<xsl:value-of
|
|
725
|
+
select="key('targetptr-key', $olink.key)[1]/@lang" />
|
|
726
|
+
</xsl:for-each>
|
|
727
|
+
</xsl:variable>
|
|
728
|
+
<xsl:choose>
|
|
729
|
+
<xsl:when test="$candidate != ''">
|
|
730
|
+
<xsl:value-of select="$candidate"/>
|
|
731
|
+
</xsl:when>
|
|
732
|
+
<xsl:otherwise>
|
|
733
|
+
<xsl:value-of select="$olink.lang"/>
|
|
734
|
+
</xsl:otherwise>
|
|
735
|
+
</xsl:choose>
|
|
736
|
+
</xsl:variable>
|
|
737
|
+
|
|
738
|
+
<xsl:variable name="targetdoc">
|
|
739
|
+
<xsl:value-of select="substring-before($olink.key, '/')"/>
|
|
740
|
+
</xsl:variable>
|
|
741
|
+
|
|
742
|
+
<xsl:choose>
|
|
743
|
+
<xsl:when test="$xrefstyle != '' and
|
|
744
|
+
starts-with(normalize-space($xrefstyle), 'select:') and
|
|
745
|
+
(contains($xrefstyle, 'nodocname') or
|
|
746
|
+
contains($xrefstyle, 'nopage')) and
|
|
747
|
+
not(contains($xrefstyle, 'title')) and
|
|
748
|
+
not(contains($xrefstyle, 'label'))">
|
|
749
|
+
<xsl:copy-of select="$xref.text"/>
|
|
750
|
+
</xsl:when>
|
|
751
|
+
<xsl:when test="$xrefstyle != ''">
|
|
752
|
+
<xsl:if test="$olink.debug != 0">
|
|
753
|
+
<xsl:message>
|
|
754
|
+
<xsl:text>xrefstyle is '</xsl:text>
|
|
755
|
+
<xsl:value-of select="$xrefstyle"/>
|
|
756
|
+
<xsl:text>'.</xsl:text>
|
|
757
|
+
</xsl:message>
|
|
758
|
+
</xsl:if>
|
|
759
|
+
<xsl:variable name="template">
|
|
760
|
+
<xsl:choose>
|
|
761
|
+
<xsl:when test="starts-with(normalize-space($xrefstyle),
|
|
762
|
+
'select:')">
|
|
763
|
+
<xsl:call-template name="make.gentext.template">
|
|
764
|
+
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
|
|
765
|
+
<xsl:with-param name="purpose" select="'olink'"/>
|
|
766
|
+
<xsl:with-param name="referrer" select="."/>
|
|
767
|
+
<xsl:with-param name="target.elem" select="$target.elem"/>
|
|
768
|
+
</xsl:call-template>
|
|
769
|
+
</xsl:when>
|
|
770
|
+
<xsl:when test="starts-with(normalize-space($xrefstyle),
|
|
771
|
+
'template:')">
|
|
772
|
+
<xsl:value-of select="substring-after(
|
|
773
|
+
normalize-space($xrefstyle), 'template:')"/>
|
|
774
|
+
</xsl:when>
|
|
775
|
+
<xsl:otherwise>
|
|
776
|
+
<!-- Look for Gentext template with @style attribute -->
|
|
777
|
+
<!-- Must compare to no style value because gentext.template
|
|
778
|
+
falls back to no style -->
|
|
779
|
+
|
|
780
|
+
<xsl:variable name="xref-context">
|
|
781
|
+
<xsl:call-template name="gentext.template">
|
|
782
|
+
<xsl:with-param name="context" select="'xref'"/>
|
|
783
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
784
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
785
|
+
</xsl:call-template>
|
|
786
|
+
</xsl:variable>
|
|
787
|
+
|
|
788
|
+
<xsl:variable name="styled-xref-context">
|
|
789
|
+
<xsl:call-template name="gentext.template">
|
|
790
|
+
<xsl:with-param name="context" select="'xref'"/>
|
|
791
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
792
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
793
|
+
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
|
|
794
|
+
</xsl:call-template>
|
|
795
|
+
</xsl:variable>
|
|
796
|
+
|
|
797
|
+
<xsl:variable name="xref-number-context">
|
|
798
|
+
<xsl:call-template name="gentext.template">
|
|
799
|
+
<xsl:with-param name="context" select="'xref-number'"/>
|
|
800
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
801
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
802
|
+
</xsl:call-template>
|
|
803
|
+
</xsl:variable>
|
|
804
|
+
|
|
805
|
+
<xsl:variable name="styled-xref-number-context">
|
|
806
|
+
<xsl:call-template name="gentext.template">
|
|
807
|
+
<xsl:with-param name="context" select="'xref-number'"/>
|
|
808
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
809
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
810
|
+
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
|
|
811
|
+
</xsl:call-template>
|
|
812
|
+
</xsl:variable>
|
|
813
|
+
|
|
814
|
+
<xsl:variable name="xref-number-and-title-context">
|
|
815
|
+
<xsl:call-template name="gentext.template">
|
|
816
|
+
<xsl:with-param name="context"
|
|
817
|
+
select="'xref-number-and-title'"/>
|
|
818
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
819
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
820
|
+
</xsl:call-template>
|
|
821
|
+
</xsl:variable>
|
|
822
|
+
|
|
823
|
+
<xsl:variable name="styled-xref-number-and-title-context">
|
|
824
|
+
<xsl:call-template name="gentext.template">
|
|
825
|
+
<xsl:with-param name="context"
|
|
826
|
+
select="'xref-number-and-title'"/>
|
|
827
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
828
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
829
|
+
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
|
|
830
|
+
</xsl:call-template>
|
|
831
|
+
</xsl:variable>
|
|
832
|
+
|
|
833
|
+
<xsl:choose>
|
|
834
|
+
<xsl:when test="$xref-number-and-title-context !=
|
|
835
|
+
$styled-xref-number-and-title-context and
|
|
836
|
+
$xref.number != '' and
|
|
837
|
+
$xref.with.number.and.title != 0">
|
|
838
|
+
<xsl:value-of
|
|
839
|
+
select="$styled-xref-number-and-title-context"/>
|
|
840
|
+
</xsl:when>
|
|
841
|
+
<xsl:when test="$xref-number-context !=
|
|
842
|
+
$styled-xref-number-context and
|
|
843
|
+
$xref.number != ''">
|
|
844
|
+
<xsl:value-of select="$styled-xref-number-context"/>
|
|
845
|
+
</xsl:when>
|
|
846
|
+
<xsl:when test="$xref-context != $styled-xref-context">
|
|
847
|
+
<xsl:value-of select="$styled-xref-context"/>
|
|
848
|
+
</xsl:when>
|
|
849
|
+
<xsl:when test="$xref-number-and-title-context != '' and
|
|
850
|
+
$xref.number != '' and
|
|
851
|
+
$xref.with.number.and.title != 0">
|
|
852
|
+
<xsl:value-of
|
|
853
|
+
select="$xref-number-and-title-context"/>
|
|
854
|
+
<xsl:if test="$olink.debug">
|
|
855
|
+
<xsl:call-template name="olink.warning">
|
|
856
|
+
<xsl:with-param name="message">
|
|
857
|
+
<xsl:text>no gentext template</xsl:text>
|
|
858
|
+
<xsl:text> exists for xrefstyle '</xsl:text>
|
|
859
|
+
<xsl:value-of select="$xrefstyle"/>
|
|
860
|
+
<xsl:text>' for element '</xsl:text>
|
|
861
|
+
<xsl:value-of select="$target.elem"/>
|
|
862
|
+
<xsl:text>' in language '</xsl:text>
|
|
863
|
+
<xsl:value-of select="$lang"/>
|
|
864
|
+
<xsl:text>' in context 'xref-number-and-title</xsl:text>
|
|
865
|
+
<xsl:text>'. Using template without @style.</xsl:text>
|
|
866
|
+
</xsl:with-param>
|
|
867
|
+
</xsl:call-template>
|
|
868
|
+
</xsl:if>
|
|
869
|
+
</xsl:when>
|
|
870
|
+
<xsl:when test="$xref-number-context != '' and
|
|
871
|
+
$xref.number != ''">
|
|
872
|
+
<xsl:value-of select="$xref-number-context"/>
|
|
873
|
+
<xsl:if test="$olink.debug">
|
|
874
|
+
<xsl:call-template name="olink.warning">
|
|
875
|
+
<xsl:with-param name="message">
|
|
876
|
+
<xsl:text>no gentext template</xsl:text>
|
|
877
|
+
<xsl:text> exists for xrefstyle '</xsl:text>
|
|
878
|
+
<xsl:value-of select="$xrefstyle"/>
|
|
879
|
+
<xsl:text>' for element '</xsl:text>
|
|
880
|
+
<xsl:value-of select="$target.elem"/>
|
|
881
|
+
<xsl:text>' in language '</xsl:text>
|
|
882
|
+
<xsl:value-of select="$lang"/>
|
|
883
|
+
<xsl:text>' in context 'xref-number</xsl:text>
|
|
884
|
+
<xsl:text>'. Using template without @style.</xsl:text>
|
|
885
|
+
</xsl:with-param>
|
|
886
|
+
</xsl:call-template>
|
|
887
|
+
</xsl:if>
|
|
888
|
+
</xsl:when>
|
|
889
|
+
<xsl:when test="$xref-context != ''">
|
|
890
|
+
<xsl:value-of select="$xref-context"/>
|
|
891
|
+
<xsl:if test="$olink.debug">
|
|
892
|
+
<xsl:call-template name="olink.warning">
|
|
893
|
+
<xsl:with-param name="message">
|
|
894
|
+
<xsl:text>no gentext template</xsl:text>
|
|
895
|
+
<xsl:text> exists for xrefstyle '</xsl:text>
|
|
896
|
+
<xsl:value-of select="$xrefstyle"/>
|
|
897
|
+
<xsl:text>' for element '</xsl:text>
|
|
898
|
+
<xsl:value-of select="$target.elem"/>
|
|
899
|
+
<xsl:text>' in language '</xsl:text>
|
|
900
|
+
<xsl:value-of select="$lang"/>
|
|
901
|
+
<xsl:text>' in context 'xref</xsl:text>
|
|
902
|
+
<xsl:text>'. Using template without @style.</xsl:text>
|
|
903
|
+
</xsl:with-param>
|
|
904
|
+
</xsl:call-template>
|
|
905
|
+
</xsl:if>
|
|
906
|
+
</xsl:when>
|
|
907
|
+
<xsl:otherwise>
|
|
908
|
+
<xsl:call-template name="olink.warning">
|
|
909
|
+
<xsl:with-param name="message">
|
|
910
|
+
<xsl:text>no gentext template</xsl:text>
|
|
911
|
+
<xsl:text> exists for xrefstyle '</xsl:text>
|
|
912
|
+
<xsl:value-of select="$xrefstyle"/>
|
|
913
|
+
<xsl:text>' for element '</xsl:text>
|
|
914
|
+
<xsl:value-of select="$target.elem"/>
|
|
915
|
+
<xsl:text>' in language '</xsl:text>
|
|
916
|
+
<xsl:value-of select="$lang"/>
|
|
917
|
+
<xsl:text>'. Trying '%t'.</xsl:text>
|
|
918
|
+
</xsl:with-param>
|
|
919
|
+
</xsl:call-template>
|
|
920
|
+
<xsl:value-of select="'%t'"/>
|
|
921
|
+
</xsl:otherwise>
|
|
922
|
+
</xsl:choose>
|
|
923
|
+
</xsl:otherwise>
|
|
924
|
+
</xsl:choose>
|
|
925
|
+
</xsl:variable>
|
|
926
|
+
|
|
927
|
+
<xsl:if test="$olink.debug != 0">
|
|
928
|
+
<xsl:message>
|
|
929
|
+
<xsl:text>Olink debug: xrefstyle template is '</xsl:text>
|
|
930
|
+
<xsl:value-of select="$template"/>
|
|
931
|
+
<xsl:text>'.</xsl:text>
|
|
932
|
+
</xsl:message>
|
|
933
|
+
</xsl:if>
|
|
934
|
+
|
|
935
|
+
<xsl:call-template name="substitute-markup">
|
|
936
|
+
<xsl:with-param name="template" select="$template"/>
|
|
937
|
+
<xsl:with-param name="title">
|
|
938
|
+
<xsl:for-each select="$target.database" >
|
|
939
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
940
|
+
<xsl:with-param name="data"
|
|
941
|
+
select="key('targetptr-key', $olink.key)/ttl/node()"/>
|
|
942
|
+
</xsl:call-template>
|
|
943
|
+
</xsl:for-each>
|
|
944
|
+
</xsl:with-param>
|
|
945
|
+
<xsl:with-param name="label">
|
|
946
|
+
<xsl:for-each select="$target.database" >
|
|
947
|
+
<xsl:value-of
|
|
948
|
+
select="key('targetptr-key', $olink.key)[1]/@number" />
|
|
949
|
+
</xsl:for-each>
|
|
950
|
+
</xsl:with-param>
|
|
951
|
+
<xsl:with-param name="pagenumber">
|
|
952
|
+
<xsl:for-each select="$target.database" >
|
|
953
|
+
<xsl:value-of
|
|
954
|
+
select="key('targetptr-key', $olink.key)[1]/@page" />
|
|
955
|
+
</xsl:for-each>
|
|
956
|
+
</xsl:with-param>
|
|
957
|
+
<xsl:with-param name="docname">
|
|
958
|
+
<xsl:for-each select="$target.database" >
|
|
959
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
960
|
+
<xsl:with-param name="data"
|
|
961
|
+
select="key('targetdoc-key', $targetdoc)[1]/div[1]/ttl/node()" />
|
|
962
|
+
</xsl:call-template>
|
|
963
|
+
</xsl:for-each>
|
|
964
|
+
</xsl:with-param>
|
|
965
|
+
</xsl:call-template>
|
|
966
|
+
</xsl:when>
|
|
967
|
+
|
|
968
|
+
<xsl:when test="$use.local.olink.style != 0">
|
|
969
|
+
|
|
970
|
+
<!-- Is autonumbering on? -->
|
|
971
|
+
<xsl:variable name="target.number">
|
|
972
|
+
<xsl:for-each select="$target.database" >
|
|
973
|
+
<xsl:value-of
|
|
974
|
+
select="key('targetptr-key', $olink.key)[1]/@number" />
|
|
975
|
+
</xsl:for-each>
|
|
976
|
+
</xsl:variable>
|
|
977
|
+
|
|
978
|
+
<xsl:variable name="autonumber">
|
|
979
|
+
<xsl:choose>
|
|
980
|
+
<xsl:when test="$target.number != ''">1</xsl:when>
|
|
981
|
+
<xsl:otherwise>0</xsl:otherwise>
|
|
982
|
+
</xsl:choose>
|
|
983
|
+
</xsl:variable>
|
|
984
|
+
|
|
985
|
+
<xsl:variable name="number-and-title-template">
|
|
986
|
+
<xsl:call-template name="gentext.template.exists">
|
|
987
|
+
<xsl:with-param name="context" select="'xref-number-and-title'"/>
|
|
988
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
989
|
+
</xsl:call-template>
|
|
990
|
+
</xsl:variable>
|
|
991
|
+
|
|
992
|
+
<xsl:variable name="number-template">
|
|
993
|
+
<xsl:call-template name="gentext.template.exists">
|
|
994
|
+
<xsl:with-param name="context" select="'xref-number'"/>
|
|
995
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
996
|
+
</xsl:call-template>
|
|
997
|
+
</xsl:variable>
|
|
998
|
+
|
|
999
|
+
<xsl:variable name="context">
|
|
1000
|
+
<xsl:choose>
|
|
1001
|
+
<xsl:when test="string($autonumber) != 0
|
|
1002
|
+
and $number-and-title-template != 0
|
|
1003
|
+
and $xref.with.number.and.title != 0">
|
|
1004
|
+
<xsl:value-of select="'xref-number-and-title'"/>
|
|
1005
|
+
</xsl:when>
|
|
1006
|
+
<xsl:when test="string($autonumber) != 0
|
|
1007
|
+
and $number-template != 0">
|
|
1008
|
+
<xsl:value-of select="'xref-number'"/>
|
|
1009
|
+
</xsl:when>
|
|
1010
|
+
<xsl:otherwise>
|
|
1011
|
+
<xsl:value-of select="'xref'"/>
|
|
1012
|
+
</xsl:otherwise>
|
|
1013
|
+
</xsl:choose>
|
|
1014
|
+
</xsl:variable>
|
|
1015
|
+
|
|
1016
|
+
<xsl:variable name="template">
|
|
1017
|
+
<xsl:call-template name="gentext.template">
|
|
1018
|
+
<xsl:with-param name="context" select="$context"/>
|
|
1019
|
+
<xsl:with-param name="name" select="$target.elem"/>
|
|
1020
|
+
<xsl:with-param name="lang" select="$lang"/>
|
|
1021
|
+
</xsl:call-template>
|
|
1022
|
+
</xsl:variable>
|
|
1023
|
+
|
|
1024
|
+
<xsl:call-template name="substitute-markup">
|
|
1025
|
+
<xsl:with-param name="template" select="$template"/>
|
|
1026
|
+
<xsl:with-param name="title">
|
|
1027
|
+
<xsl:for-each select="$target.database" >
|
|
1028
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
1029
|
+
<xsl:with-param name="data"
|
|
1030
|
+
select="key('targetptr-key', $olink.key)[1]/ttl/node()" />
|
|
1031
|
+
</xsl:call-template>
|
|
1032
|
+
</xsl:for-each>
|
|
1033
|
+
</xsl:with-param>
|
|
1034
|
+
<xsl:with-param name="label">
|
|
1035
|
+
<xsl:for-each select="$target.database" >
|
|
1036
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
1037
|
+
<xsl:with-param name="data"
|
|
1038
|
+
select="key('targetptr-key', $olink.key)[1]/@number" />
|
|
1039
|
+
</xsl:call-template>
|
|
1040
|
+
</xsl:for-each>
|
|
1041
|
+
</xsl:with-param>
|
|
1042
|
+
</xsl:call-template>
|
|
1043
|
+
</xsl:when>
|
|
1044
|
+
<xsl:when test="$xref.text !=''">
|
|
1045
|
+
<xsl:copy-of select="$xref.text"/>
|
|
1046
|
+
</xsl:when>
|
|
1047
|
+
<xsl:otherwise>
|
|
1048
|
+
<xsl:call-template name="olink.error">
|
|
1049
|
+
<xsl:with-param name="message">
|
|
1050
|
+
<xsl:text>no generated text for targetdoc/targetptr/lang = '</xsl:text>
|
|
1051
|
+
<xsl:value-of select="$olink.key"/>
|
|
1052
|
+
<xsl:text>'.</xsl:text>
|
|
1053
|
+
</xsl:with-param>
|
|
1054
|
+
</xsl:call-template>
|
|
1055
|
+
<xsl:text>????</xsl:text>
|
|
1056
|
+
</xsl:otherwise>
|
|
1057
|
+
</xsl:choose>
|
|
1058
|
+
</xsl:when>
|
|
1059
|
+
<xsl:otherwise>
|
|
1060
|
+
<xsl:if test="$olink.key != ''">
|
|
1061
|
+
<xsl:call-template name="olink.error">
|
|
1062
|
+
<xsl:with-param name="message">
|
|
1063
|
+
<xsl:text>no generated text for targetdoc/targetptr/lang = '</xsl:text>
|
|
1064
|
+
<xsl:value-of select="$olink.key"/>
|
|
1065
|
+
<xsl:text>'.</xsl:text>
|
|
1066
|
+
</xsl:with-param>
|
|
1067
|
+
</xsl:call-template>
|
|
1068
|
+
</xsl:if>
|
|
1069
|
+
<xsl:text>????</xsl:text>
|
|
1070
|
+
</xsl:otherwise>
|
|
1071
|
+
</xsl:choose>
|
|
1072
|
+
</xsl:template>
|
|
1073
|
+
|
|
1074
|
+
<xsl:template name="insert.targetdb.data">
|
|
1075
|
+
<xsl:param name="data"/>
|
|
1076
|
+
<!-- Customize this to massage data further -->
|
|
1077
|
+
<xsl:copy-of select="$data"/>
|
|
1078
|
+
</xsl:template>
|
|
1079
|
+
|
|
1080
|
+
<xsl:template match="*" mode="olink.docname.markup">
|
|
1081
|
+
<!-- No-op for now -->
|
|
1082
|
+
</xsl:template>
|
|
1083
|
+
|
|
1084
|
+
<xsl:template name="targetpath">
|
|
1085
|
+
<xsl:param name="dirnode" />
|
|
1086
|
+
<xsl:param name="targetdoc" select="''"/>
|
|
1087
|
+
|
|
1088
|
+
<!--
|
|
1089
|
+
<xsl:message>dirnode is <xsl:value-of select="$dirnode/@name"/></xsl:message>
|
|
1090
|
+
<xsl:message>targetdoc is <xsl:value-of select="$targetdoc"/></xsl:message>
|
|
1091
|
+
-->
|
|
1092
|
+
<!-- recursive template generates path to olink target directory -->
|
|
1093
|
+
<xsl:choose>
|
|
1094
|
+
<!-- Have we arrived at the final path step? -->
|
|
1095
|
+
<xsl:when test="$dirnode/child::document[@targetdoc = $targetdoc]">
|
|
1096
|
+
<!-- We are done -->
|
|
1097
|
+
</xsl:when>
|
|
1098
|
+
<!-- Have we reached the top without a match? -->
|
|
1099
|
+
<xsl:when test="local-name($dirnode) != 'dir'" >
|
|
1100
|
+
<xsl:call-template name="olink.error">
|
|
1101
|
+
<xsl:with-param name="message">
|
|
1102
|
+
<xsl:text>cannot locate targetdoc </xsl:text>
|
|
1103
|
+
<xsl:value-of select="$targetdoc"/>
|
|
1104
|
+
<xsl:text> in sitemap</xsl:text>
|
|
1105
|
+
</xsl:with-param>
|
|
1106
|
+
</xsl:call-template>
|
|
1107
|
+
</xsl:when>
|
|
1108
|
+
<!-- Is the target in a descendant? -->
|
|
1109
|
+
<xsl:when test="$dirnode/descendant::document/@targetdoc = $targetdoc">
|
|
1110
|
+
<xsl:variable name="step" select="$dirnode/child::dir[descendant::document/@targetdoc = $targetdoc]"/>
|
|
1111
|
+
<xsl:if test = "$step">
|
|
1112
|
+
<xsl:value-of select="$step/@name"/>
|
|
1113
|
+
<xsl:text>/</xsl:text>
|
|
1114
|
+
</xsl:if>
|
|
1115
|
+
<!-- Now recurse with the child -->
|
|
1116
|
+
<xsl:call-template name="targetpath" >
|
|
1117
|
+
<xsl:with-param name="dirnode" select="$step"/>
|
|
1118
|
+
<xsl:with-param name="targetdoc" select="$targetdoc"/>
|
|
1119
|
+
</xsl:call-template>
|
|
1120
|
+
</xsl:when>
|
|
1121
|
+
<!-- Otherwise we need to move up a step -->
|
|
1122
|
+
<xsl:otherwise>
|
|
1123
|
+
<xsl:if test="$dirnode/parent::dir">
|
|
1124
|
+
<xsl:text>../</xsl:text>
|
|
1125
|
+
</xsl:if>
|
|
1126
|
+
<xsl:call-template name="targetpath" >
|
|
1127
|
+
<xsl:with-param name="dirnode" select="$dirnode/parent::*"/>
|
|
1128
|
+
<xsl:with-param name="targetdoc" select="$targetdoc"/>
|
|
1129
|
+
</xsl:call-template>
|
|
1130
|
+
</xsl:otherwise>
|
|
1131
|
+
</xsl:choose>
|
|
1132
|
+
</xsl:template>
|
|
1133
|
+
|
|
1134
|
+
<xsl:template name="olink.page.citation">
|
|
1135
|
+
<xsl:param name="olink.key" select="''"/>
|
|
1136
|
+
<xsl:param name="olink.lang" select="'en'"/>
|
|
1137
|
+
<xsl:param name="referrer" select="."/>
|
|
1138
|
+
<xsl:param name="target.database"/>
|
|
1139
|
+
<xsl:param name="linkend" select="''"/>
|
|
1140
|
+
<xsl:param name="xrefstyle">
|
|
1141
|
+
<xsl:apply-templates select="." mode="xrefstyle">
|
|
1142
|
+
<xsl:with-param name="olink.key" select="$olink.key"/>
|
|
1143
|
+
<xsl:with-param name="referrer" select="$referrer"/>
|
|
1144
|
+
</xsl:apply-templates>
|
|
1145
|
+
</xsl:param>
|
|
1146
|
+
|
|
1147
|
+
<xsl:variable name="targetdoc">
|
|
1148
|
+
<xsl:value-of select="substring-before($olink.key, '/')"/>
|
|
1149
|
+
</xsl:variable>
|
|
1150
|
+
|
|
1151
|
+
<xsl:choose>
|
|
1152
|
+
<xsl:when test="$linkend != ''">
|
|
1153
|
+
<xsl:call-template name="xref.page.citation">
|
|
1154
|
+
<xsl:with-param name="linkend" select="$linkend"/>
|
|
1155
|
+
<xsl:with-param name="target" select="key('id', $linkend)"/>
|
|
1156
|
+
<xsl:with-param name="xrefstyle" select="$xrefstyle"/>
|
|
1157
|
+
</xsl:call-template>
|
|
1158
|
+
</xsl:when>
|
|
1159
|
+
<xsl:when test="not(starts-with(normalize-space($xrefstyle),
|
|
1160
|
+
'select:')
|
|
1161
|
+
and (contains($xrefstyle, 'page')
|
|
1162
|
+
or contains($xrefstyle, 'Page')))
|
|
1163
|
+
and $current.docid != ''
|
|
1164
|
+
and $current.docid != $targetdoc
|
|
1165
|
+
and $insert.olink.page.number = 'yes' ">
|
|
1166
|
+
|
|
1167
|
+
<xsl:variable name="page-number">
|
|
1168
|
+
<xsl:for-each select="$target.database" >
|
|
1169
|
+
<xsl:value-of
|
|
1170
|
+
select="key('targetptr-key', $olink.key)[1]/@page" />
|
|
1171
|
+
</xsl:for-each>
|
|
1172
|
+
</xsl:variable>
|
|
1173
|
+
|
|
1174
|
+
<xsl:if test="$page-number != ''">
|
|
1175
|
+
<xsl:call-template name="substitute-markup">
|
|
1176
|
+
<xsl:with-param name="template">
|
|
1177
|
+
<xsl:call-template name="gentext.template">
|
|
1178
|
+
<xsl:with-param name="name" select="'olink.page.citation'"/>
|
|
1179
|
+
<xsl:with-param name="context" select="'xref'"/>
|
|
1180
|
+
<xsl:with-param name="lang" select="$olink.lang"/>
|
|
1181
|
+
</xsl:call-template>
|
|
1182
|
+
</xsl:with-param>
|
|
1183
|
+
<xsl:with-param name="pagenumber" select="$page-number"/>
|
|
1184
|
+
</xsl:call-template>
|
|
1185
|
+
</xsl:if>
|
|
1186
|
+
|
|
1187
|
+
</xsl:when>
|
|
1188
|
+
</xsl:choose>
|
|
1189
|
+
</xsl:template>
|
|
1190
|
+
|
|
1191
|
+
<xsl:template name="olink.document.citation">
|
|
1192
|
+
<xsl:param name="referrer" select="."/>
|
|
1193
|
+
<xsl:param name="olink.key" select="''"/>
|
|
1194
|
+
<xsl:param name="olink.lang" select="'en'"/>
|
|
1195
|
+
<xsl:param name="target.database"/>
|
|
1196
|
+
<xsl:param name="xrefstyle">
|
|
1197
|
+
<xsl:apply-templates select="." mode="xrefstyle">
|
|
1198
|
+
<xsl:with-param name="olink.key" select="$olink.key"/>
|
|
1199
|
+
<xsl:with-param name="referrer" select="$referrer"/>
|
|
1200
|
+
</xsl:apply-templates>
|
|
1201
|
+
</xsl:param>
|
|
1202
|
+
|
|
1203
|
+
<xsl:variable name="page">
|
|
1204
|
+
<xsl:for-each select="$target.database" >
|
|
1205
|
+
<xsl:value-of
|
|
1206
|
+
select="key('targetptr-key', $olink.key)[1]/@page" />
|
|
1207
|
+
</xsl:for-each>
|
|
1208
|
+
</xsl:variable>
|
|
1209
|
+
|
|
1210
|
+
<xsl:variable name="targetdoc">
|
|
1211
|
+
<xsl:value-of select="substring-before($olink.key, '/')"/>
|
|
1212
|
+
</xsl:variable>
|
|
1213
|
+
|
|
1214
|
+
<xsl:variable name="targetptr">
|
|
1215
|
+
<xsl:value-of
|
|
1216
|
+
select="substring-before(substring-after($olink.key, '/'), '/')"/>
|
|
1217
|
+
</xsl:variable>
|
|
1218
|
+
|
|
1219
|
+
<!-- Don't add docname if pointing to root element -->
|
|
1220
|
+
<xsl:variable name="rootptr">
|
|
1221
|
+
<xsl:for-each select="$target.database" >
|
|
1222
|
+
<xsl:value-of
|
|
1223
|
+
select="key('targetdoc-key', $targetdoc)[1]/div[1]/@targetptr" />
|
|
1224
|
+
</xsl:for-each>
|
|
1225
|
+
</xsl:variable>
|
|
1226
|
+
|
|
1227
|
+
<xsl:variable name="docname">
|
|
1228
|
+
<xsl:for-each select="$target.database" >
|
|
1229
|
+
<xsl:call-template name="insert.targetdb.data">
|
|
1230
|
+
<xsl:with-param name="data"
|
|
1231
|
+
select="key('targetdoc-key', $targetdoc)[1]/div[1]/ttl/node()" />
|
|
1232
|
+
</xsl:call-template>
|
|
1233
|
+
</xsl:for-each>
|
|
1234
|
+
</xsl:variable>
|
|
1235
|
+
|
|
1236
|
+
<xsl:if test="not(starts-with(normalize-space($xrefstyle), 'select:')
|
|
1237
|
+
and (contains($xrefstyle, 'docname')))
|
|
1238
|
+
and ($olink.doctitle = 'yes' or $olink.doctitle = '1')
|
|
1239
|
+
and $current.docid != ''
|
|
1240
|
+
and $rootptr != $targetptr
|
|
1241
|
+
and $current.docid != $targetdoc
|
|
1242
|
+
and $docname != ''">
|
|
1243
|
+
<xsl:call-template name="substitute-markup">
|
|
1244
|
+
<xsl:with-param name="template">
|
|
1245
|
+
<xsl:call-template name="gentext.template">
|
|
1246
|
+
<xsl:with-param name="name" select="'olink.document.citation'"/>
|
|
1247
|
+
<xsl:with-param name="context" select="'xref'"/>
|
|
1248
|
+
<xsl:with-param name="lang" select="$olink.lang"/>
|
|
1249
|
+
</xsl:call-template>
|
|
1250
|
+
</xsl:with-param>
|
|
1251
|
+
<xsl:with-param name="docname" select="$docname"/>
|
|
1252
|
+
<xsl:with-param name="pagenumber" select="$page"/>
|
|
1253
|
+
</xsl:call-template>
|
|
1254
|
+
</xsl:if>
|
|
1255
|
+
</xsl:template>
|
|
1256
|
+
|
|
1257
|
+
<xsl:template name="xref.page.citation">
|
|
1258
|
+
<!-- Determine if this xref should have a page citation.
|
|
1259
|
+
Context node is the xref or local olink element -->
|
|
1260
|
+
<xsl:param name="referrer" select="."/>
|
|
1261
|
+
<xsl:param name="linkend" select="@linkend"/>
|
|
1262
|
+
<xsl:param name="target" select="key('id', $linkend)"/>
|
|
1263
|
+
<xsl:param name="xrefstyle">
|
|
1264
|
+
<xsl:apply-templates select="." mode="xrefstyle">
|
|
1265
|
+
<xsl:with-param name="target" select="$target"/>
|
|
1266
|
+
<xsl:with-param name="referrer" select="$referrer"/>
|
|
1267
|
+
</xsl:apply-templates>
|
|
1268
|
+
</xsl:param>
|
|
1269
|
+
|
|
1270
|
+
<xsl:if test="not(starts-with(normalize-space($xrefstyle),'select:')
|
|
1271
|
+
and (contains($xrefstyle, 'page')
|
|
1272
|
+
or contains($xrefstyle, 'Page')))
|
|
1273
|
+
and ( $insert.xref.page.number = 'yes'
|
|
1274
|
+
or $insert.xref.page.number = '1')
|
|
1275
|
+
or ( local-name($target) = 'para'
|
|
1276
|
+
and $insert.xref.page.number.para = 'yes')">
|
|
1277
|
+
<xsl:apply-templates select="$target" mode="page.citation">
|
|
1278
|
+
<xsl:with-param name="id" select="$linkend"/>
|
|
1279
|
+
</xsl:apply-templates>
|
|
1280
|
+
</xsl:if>
|
|
1281
|
+
</xsl:template>
|
|
1282
|
+
|
|
1283
|
+
</xsl:stylesheet>
|
|
1284
|
+
|