]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/common/utility.xml
Capitalized the start of a sentence in the bucket section of cataloging.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / common / utility.xml
1 <?xml version="1.0"?>\r
2 \r
3 <reference xml:id="utility">\r
4   <info>\r
5     <title>Common » Utility Template Reference</title>\r
6     <releaseinfo role="meta">\r
7       $Id: utility.xsl 7101 2007-07-20 15:32:12Z xmldoc $\r
8     </releaseinfo>\r
9   </info>\r
10   \r
11   <partintro xml:id="partintro">\r
12     <title>Introduction</title>\r
13     \r
14 <para>This is technical reference documentation for the\r
15       miscellaneous utility templates in the DocBook XSL\r
16       Stylesheets.</para>\r
17 \r
18     <note>\r
19       \r
20 <para>These templates are defined in a separate file from the set\r
21         of “common” templates because some of the common templates\r
22         reference DocBook XSL stylesheet parameters, requiring the\r
23         entire set of parameters to be imported/included in any\r
24         stylesheet that imports/includes the common templates.</para>\r
25 \r
26       \r
27 <para>The utility templates don’t import or include any DocBook\r
28         XSL stylesheet parameters, so the utility templates can be used\r
29         without importing the whole set of parameters.</para>\r
30 \r
31     </note>\r
32     \r
33 <para>This is not intended to be user documentation. It is\r
34       provided for developers writing customization layers for the\r
35       stylesheets.</para>\r
36 \r
37   </partintro>\r
38 \r
39 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.log.message">\r
40 <refnamediv>\r
41 <refname>log.message</refname>\r
42 <refpurpose>Logs/emits formatted notes and warnings</refpurpose>\r
43 </refnamediv>\r
44 <refsynopsisdiv>\r
45 <synopsis>&lt;xsl:template name="log.message"&gt;\r
46 &lt;xsl:param name="level"/&gt;\r
47 &lt;xsl:param name="source"/&gt;\r
48 &lt;xsl:param name="context-desc"/&gt;\r
49 &lt;xsl:param name="context-desc-field-length"&gt;12&lt;/xsl:param&gt;\r
50 &lt;xsl:param name="context-desc-padded"&gt;\r
51     &lt;xsl:if test="not($context-desc = '')"&gt;\r
52       &lt;xsl:call-template name="pad-string"&gt;\r
53         &lt;xsl:with-param name="leftRight"&gt;right&lt;/xsl:with-param&gt;\r
54         &lt;xsl:with-param name="padVar" select="substring($context-desc, 1, $context-desc-field-length)"/&gt;\r
55         &lt;xsl:with-param name="length" select="$context-desc-field-length"/&gt;\r
56       &lt;/xsl:call-template&gt;\r
57     &lt;/xsl:if&gt;\r
58   &lt;/xsl:param&gt;\r
59 &lt;xsl:param name="message"/&gt;\r
60 &lt;xsl:param name="message-field-length" select="45"/&gt;\r
61 &lt;xsl:param name="message-padded"&gt;\r
62     &lt;xsl:variable name="spaces-for-blank-level"&gt;\r
63       &lt;!-- * if the level field is blank, we'll need to pad out --&gt;\r
64       &lt;!-- * the message field with spaces to compensate --&gt;\r
65       &lt;xsl:choose&gt;\r
66         &lt;xsl:when test="$level = ''"&gt;\r
67           &lt;xsl:value-of select="4 + 2"/&gt;\r
68           &lt;!-- * 4 = hard-coded length of comment text ("Note" or "Warn") --&gt;\r
69           &lt;!-- * + 2 = length of colon-plus-space separator ": " --&gt;\r
70         &lt;/xsl:when&gt;\r
71         &lt;xsl:otherwise&gt;\r
72           &lt;xsl:value-of select="0"/&gt;\r
73         &lt;/xsl:otherwise&gt;\r
74       &lt;/xsl:choose&gt;\r
75     &lt;/xsl:variable&gt;\r
76     &lt;xsl:variable name="spaces-for-blank-context-desc"&gt;\r
77       &lt;!-- * if the context-description field is blank, we'll need --&gt;\r
78       &lt;!-- * to pad out the message field with spaces to compensate --&gt;\r
79       &lt;xsl:choose&gt;\r
80         &lt;xsl:when test="$context-desc = ''"&gt;\r
81           &lt;xsl:value-of select="$context-desc-field-length + 2"/&gt;\r
82           &lt;!-- * + 2 = length of colon-plus-space separator ": " --&gt;\r
83         &lt;/xsl:when&gt;\r
84         &lt;xsl:otherwise&gt;\r
85           &lt;xsl:value-of select="0"/&gt;\r
86         &lt;/xsl:otherwise&gt;\r
87       &lt;/xsl:choose&gt;\r
88     &lt;/xsl:variable&gt;\r
89     &lt;xsl:variable name="extra-spaces" select="$spaces-for-blank-level + $spaces-for-blank-context-desc"/&gt;\r
90     &lt;xsl:call-template name="pad-string"&gt;\r
91       &lt;xsl:with-param name="leftRight"&gt;right&lt;/xsl:with-param&gt;\r
92       &lt;xsl:with-param name="padVar" select="substring($message, 1, ($message-field-length + $extra-spaces))"/&gt;\r
93       &lt;xsl:with-param name="length" select="$message-field-length + $extra-spaces"/&gt;\r
94     &lt;/xsl:call-template&gt;\r
95   &lt;/xsl:param&gt;\r
96   ...\r
97 &lt;/xsl:template&gt;</synopsis>\r
98 </refsynopsisdiv>\r
99 <refsect1><title>Description</title>\r
100     \r
101 <para>The <function>log.message</function> template is a utility\r
102     template for logging/emitting formatted messages – that is,\r
103     notes and warnings, along with a given log “level” and an\r
104     identifier for the “source” that the message relates to.</para>\r
105 \r
106   </refsect1><refsect1><title>Parameters</title>\r
107     \r
108 <variablelist>\r
109       <varlistentry><term>level</term>\r
110         <listitem>\r
111           \r
112 <para>Text to log/emit in the message-level field to\r
113             indicate the message level\r
114           (<literal>Note</literal> or\r
115           <literal>Warning</literal>)</para>\r
116 \r
117         </listitem>\r
118       </varlistentry>\r
119       <varlistentry><term>source</term>\r
120         <listitem>\r
121           \r
122 <para>Text to log/emit in the source field to identify the\r
123             “source” to which the notification/warning relates.\r
124             This can be any arbitrary string, but because the\r
125             message lacks line and column numbers to identify the\r
126             exact part of the source document to which it\r
127             relates, the intention is that the value you pass\r
128             into the <literal>source</literal> parameter should\r
129             give the user some way to identify the portion of\r
130             their source document on which to take potentially\r
131             take action in response to the log message (for\r
132             example, to edit, change, or add content).</para>\r
133 \r
134           \r
135 <para>So the <literal>source</literal> value should be,\r
136             for example, an ID, book/chapter/article title, title\r
137             of some formal object, or even a string giving an\r
138             XPath expression.</para>\r
139 \r
140         </listitem>\r
141       </varlistentry>\r
142       <varlistentry><term>context-desc</term>\r
143         <listitem>\r
144           \r
145 <para>Text to log/emit in the context-description field to\r
146             describe the context for the message.</para>\r
147 \r
148         </listitem>\r
149       </varlistentry>\r
150       <varlistentry><term>context-desc-field-length</term>\r
151         <listitem>\r
152           \r
153 <para>Specifies length of the context-description field\r
154             (in characters); default is 12</para>\r
155 \r
156           \r
157 <para>If the text specified by the\r
158             <literal>context-desc</literal> parameter is longer\r
159             than the number of characters specified in\r
160             <literal>context-desc-field-length</literal>, it is\r
161             truncated to <literal>context-desc-field-length</literal>\r
162             (12 characters by default).</para>\r
163 \r
164           \r
165 <para>If the specified text is shorter than\r
166             <literal>context-desc-field-length</literal>,\r
167           it is right-padded out to\r
168           <literal>context-desc-field-length</literal> (12 by\r
169           default).</para>\r
170 \r
171         \r
172 <para>If no value has been specified for the\r
173           <literal>context-desc</literal> parameter, the field is\r
174           left empty and the text of the log message begins with\r
175           the value of the <literal>message</literal>\r
176           parameter.</para>\r
177 \r
178         </listitem>\r
179       </varlistentry>\r
180       <varlistentry><term>message</term>\r
181         <listitem>\r
182           \r
183 <para>Text to log/emit in the actual message field</para>\r
184 \r
185         </listitem>\r
186       </varlistentry>\r
187       <varlistentry><term>message-field-length</term>\r
188         <listitem>\r
189           \r
190 <para>Specifies length of the message\r
191             field (in characters); default is 45</para>\r
192 \r
193         </listitem>\r
194       </varlistentry>\r
195     </variablelist>\r
196 \r
197   </refsect1><refsect1><title>Returns</title>\r
198   \r
199 <para>Outputs a message (generally, to standard error).</para>\r
200 </refsect1></refentry>\r
201 \r
202 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.doc.title">\r
203 <refnamediv>\r
204 <refname>get.doc.title</refname>\r
205 <refpurpose>Gets a title from the current document</refpurpose>\r
206 </refnamediv>\r
207 <refsynopsisdiv>\r
208 <synopsis>&lt;xsl:template name="get.doc.title"/&gt;</synopsis>\r
209 </refsynopsisdiv>\r
210 <refsect1><title>Description</title>\r
211     \r
212 <para>The <function>get.doc.title</function> template is a\r
213       utility template for returning the first title found in the\r
214       current document.</para>\r
215 \r
216   </refsect1><refsect1><title>Returns</title>\r
217   \r
218 <para>Returns a string containing some identifying title for the\r
219     current document .</para>\r
220 </refsect1></refentry>\r
221 \r
222 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.pad-string">\r
223 <refnamediv>\r
224 <refname>pad-string</refname>\r
225 <refpurpose>Right-pads or left-pads a string out to a certain length</refpurpose>\r
226 </refnamediv>\r
227 <refsynopsisdiv>\r
228 <synopsis>&lt;xsl:template name="pad-string"&gt;\r
229 &lt;xsl:param name="padChar" select="' '"/&gt;\r
230 &lt;xsl:param name="leftRight"&gt;left&lt;/xsl:param&gt;\r
231 &lt;xsl:param name="padVar"/&gt;\r
232 &lt;xsl:param name="length"/&gt;\r
233   ...\r
234 &lt;/xsl:template&gt;</synopsis>\r
235 </refsynopsisdiv>\r
236 <refsect1><title>Description</title>\r
237     \r
238 <para>This function takes string <parameter>padVar</parameter> and\r
239       pads it out in the direction <parameter>rightLeft</parameter> to\r
240       the string-length <parameter>length</parameter>, using string\r
241       <parameter>padChar</parameter> (a space character by default) as\r
242       the padding string (note that <parameter>padChar</parameter> can\r
243       be a string; it is not limited to just being a single\r
244       character).</para>\r
245 \r
246     <note>\r
247       \r
248 <para>This function began as a copy of Nate Austin's\r
249         <function>prepend-pad</function> function in the <link xlink:href="http://www.dpawson.co.uk/xsl/sect2/padding.html">Padding\r
250           Content</link> section of Dave Pawson's <link xlink:href="http://www.dpawson.co.uk/xsl/index.html">XSLT\r
251           FAQ</link>.</para>\r
252 \r
253     </note>\r
254   </refsect1><refsect1><title>Returns</title>\r
255   \r
256 <para>Returns a (padded) string.</para>\r
257 </refsect1></refentry>\r
258 </reference>\r
259 \r