2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: pi.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <xsl:template match=
"processing-instruction()">
18 <xsl:template match=
"processing-instruction('dbhtml')">
22 <!-- ==================================================================== -->
24 <xsl:template name=
"dbhtml-attribute">
25 <xsl:param name=
"pis" select=
"processing-instruction('dbhtml')"/>
26 <xsl:param name=
"attribute">filename
</xsl:param>
28 <xsl:call-template name=
"pi-attribute">
29 <xsl:with-param name=
"pis" select=
"$pis"/>
30 <xsl:with-param name=
"attribute" select=
"$attribute"/>
34 <xsl:template name=
"dbhtml-filename">
35 <xsl:param name=
"pis" select=
"./processing-instruction('dbhtml')"/>
36 <xsl:call-template name=
"dbhtml-attribute">
37 <xsl:with-param name=
"pis" select=
"$pis"/>
38 <xsl:with-param name=
"attribute">filename
</xsl:with-param>
43 <xsl:template name="dbhtml-dir">
44 <xsl:param name="pis" select="./processing-instruction('dbhtml')"/>
45 <xsl:call-template name="dbhtml-attribute">
46 <xsl:with-param name="pis" select="$pis"/>
47 <xsl:with-param name="attribute">dir</xsl:with-param>
52 <xsl:template name=
"dbhtml-dir">
53 <xsl:param name=
"context" select=
"."/>
55 <!-- directories are now inherited from previous levels -->
57 <xsl:variable name=
"ppath">
58 <xsl:if test=
"$context/parent::*">
59 <xsl:call-template name=
"dbhtml-dir">
60 <xsl:with-param name=
"context" select=
"$context/parent::*"/>
65 <xsl:variable name=
"path">
66 <xsl:call-template name=
"dbhtml-attribute">
67 <xsl:with-param name=
"pis" select=
"$context/processing-instruction('dbhtml')"/>
68 <xsl:with-param name=
"attribute">dir
</xsl:with-param>
73 <xsl:when test=
"$path = ''">
74 <xsl:if test=
"$ppath != ''">
75 <xsl:value-of select=
"$ppath"/>
79 <xsl:if test=
"$ppath != ''">
80 <xsl:value-of select=
"$ppath"/>
81 <xsl:if test=
"substring($ppath, string-length($ppath), 1) != '/'">
82 <xsl:text>/
</xsl:text>
85 <xsl:value-of select=
"$path"/>
86 <xsl:text>/
</xsl:text>
91 <!-- ==================================================================== -->
93 <xsl:template name=
"process.cmdsynopsis.list">
94 <xsl:param name=
"cmdsynopses"/><!-- empty node list by default -->
95 <xsl:param name=
"count" select=
"1"/>
98 <xsl:when test=
"$count>count($cmdsynopses)"></xsl:when>
100 <xsl:variable name=
"cmdsyn" select=
"$cmdsynopses[$count]"/>
104 <xsl:attribute name=
"href">
105 <xsl:call-template name=
"object.id">
106 <xsl:with-param name=
"object" select=
"$cmdsyn"/>
111 <xsl:when test=
"$cmdsyn/@xreflabel">
112 <xsl:call-template name=
"xref.xreflabel">
113 <xsl:with-param name=
"target" select=
"$cmdsyn"/>
117 <xsl:apply-templates select=
"$cmdsyn" mode=
"xref-to">
118 <xsl:with-param name=
"target" select=
"$cmdsyn"/>
119 </xsl:apply-templates>
125 <xsl:call-template name=
"process.cmdsynopsis.list">
126 <xsl:with-param name=
"cmdsynopses" select=
"$cmdsynopses"/>
127 <xsl:with-param name=
"count" select=
"$count+1"/>
133 <xsl:template match=
"processing-instruction('dbcmdlist')">
134 <xsl:variable name=
"cmdsynopses" select=
"..//cmdsynopsis"/>
136 <xsl:if test=
"count($cmdsynopses)<1">
137 <xsl:message><xsl:text>No cmdsynopsis elements matched dbcmdlist PI, perhaps it's nested too deep?
</xsl:text>
142 <xsl:call-template name=
"process.cmdsynopsis.list">
143 <xsl:with-param name=
"cmdsynopses" select=
"$cmdsynopses"/>
148 <!-- ==================================================================== -->
150 <xsl:template name=
"process.funcsynopsis.list">
151 <xsl:param name=
"funcsynopses"/><!-- empty node list by default -->
152 <xsl:param name=
"count" select=
"1"/>
155 <xsl:when test=
"$count>count($funcsynopses)"></xsl:when>
157 <xsl:variable name=
"cmdsyn" select=
"$funcsynopses[$count]"/>
161 <xsl:attribute name=
"href">
162 <xsl:call-template name=
"object.id">
163 <xsl:with-param name=
"object" select=
"$cmdsyn"/>
168 <xsl:when test=
"$cmdsyn/@xreflabel">
169 <xsl:call-template name=
"xref.xreflabel">
170 <xsl:with-param name=
"target" select=
"$cmdsyn"/>
174 <xsl:apply-templates select=
"$cmdsyn" mode=
"xref-to">
175 <xsl:with-param name=
"target" select=
"$cmdsyn"/>
176 </xsl:apply-templates>
182 <xsl:call-template name=
"process.funcsynopsis.list">
183 <xsl:with-param name=
"funcsynopses" select=
"$funcsynopses"/>
184 <xsl:with-param name=
"count" select=
"$count+1"/>
190 <xsl:template match=
"processing-instruction('dbfunclist')">
191 <xsl:variable name=
"funcsynopses" select=
"..//funcsynopsis"/>
193 <xsl:if test=
"count($funcsynopses)<1">
194 <xsl:message><xsl:text>No funcsynopsis elements matched dbfunclist PI, perhaps it's nested too deep?
</xsl:text>
199 <xsl:call-template name=
"process.funcsynopsis.list">
200 <xsl:with-param name=
"funcsynopses" select=
"$funcsynopses"/>
205 <!-- ==================================================================== -->
207 <!-- Copy well-formed external HTML content to the output. -->
208 <!-- An optional <html> wrapper will be removed before content is copied
209 to support multiple elements in output without a wrapper.
210 No other processing is done to the content. -->
211 <xsl:template match=
"processing-instruction('dbhtml-include')">
212 <xsl:param name=
"href">
213 <xsl:call-template name=
"dbhtml-attribute">
214 <xsl:with-param name=
"pis" select=
"."/>
215 <xsl:with-param name=
"attribute">href
</xsl:with-param>
220 <xsl:when test=
"$href != ''">
221 <xsl:variable name=
"content" select=
"document($href,/)"/>
223 <xsl:when test=
"$content/*">
225 <xsl:when test=
"$content/*[1][self::html]">
226 <!-- include just the children of html wrapper -->
227 <xsl:copy-of select=
"$content/*[1]/node()"/>
230 <xsl:copy-of select=
"$content"/>
236 <xsl:text>ERROR: dbhtml-include processing instruction
</xsl:text>
237 <xsl:text>href has no content.
</xsl:text>
244 <xsl:text>ERROR: dbhtml-include processing instruction has
</xsl:text>
245 <xsl:text>missing or empty href value.
</xsl:text>