1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:xs="http://www.w3.org/2001/XMLSchema"
4                xmlns:bcf="https://sourceforge.net/projects/biblatex"
5                xmlns="http://www.w3.org/1999/xhtml"
6                exclude-result-prefixes="xs xsl bcf"
7                version="1.0">
8
9  <!-- Use strict Doctype otherwise IE7 is too stupid to do tables correctly -->
10  <xsl:output method="html"
11              media-type="text/html"
12              doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
13              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
14              indent="yes"
15              encoding="UTF-8"/>
16
17  <xsl:template name="generate-string">
18    <xsl:param name="text"/>
19    <xsl:param name="count"/>
20    <xsl:choose>
21      <xsl:when test="string(number($count))='NaN'"/>
22      <xsl:when test="string-length($text) = 0 or $count &lt;= 0"/>
23      <xsl:otherwise>
24	      <xsl:value-of select="$text"/>
25	      <xsl:call-template name="generate-string">
26	        <xsl:with-param name="text" select="$text"/>
27	        <xsl:with-param name="count" select="$count - 1"/>
28	      </xsl:call-template>
29      </xsl:otherwise>
30    </xsl:choose>
31  </xsl:template>
32
33  <xsl:template name="sorting-spec">
34    <xsl:param name="spec"/>
35    <table>
36      <thead>
37        <tr>
38          <xsl:for-each select="$spec/bcf:sort">
39            <xsl:sort select="./@order"/>
40            <td>
41              <xsl:if test="./@final='1'">
42                <xsl:attribute name="class">sort_final</xsl:attribute>
43              </xsl:if>
44              <xsl:choose>
45                <xsl:when test="./@sort_direction='descending'">
46                  <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text>
47                </xsl:when>
48                <xsl:otherwise>
49                  <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text>
50                </xsl:otherwise>
51              </xsl:choose>
52              <tt>
53                <!-- sortupper -->
54                <xsl:choose>
55                  <xsl:when test="./@sortupper">
56                    <!-- Field setting -->
57                    <xsl:choose>
58                      <xsl:when test="./@sortupper='1'">Aa/</xsl:when>
59                      <xsl:otherwise>aA/</xsl:otherwise>
60                    </xsl:choose>
61                  </xsl:when>
62                  <xsl:otherwise>
63                    <!-- Global setting -->
64                    <xsl:choose>
65                      <xsl:when test="/bcf:controlfile/bcf:options[@component='biber']/bcf:option/bcf:key[text()='sortupper']/../bcf:value/text()">Aa/</xsl:when>
66                      <xsl:otherwise>aA/</xsl:otherwise>
67                    </xsl:choose>
68
69                  </xsl:otherwise>
70                </xsl:choose>
71                <!-- sortcase -->
72                <xsl:choose>
73                  <xsl:when test ="./@sortcase">
74                    <!-- Field setting -->
75                    <xsl:choose>
76                      <xsl:when test="./@sortcase='1'">A</xsl:when>
77                      <xsl:otherwise>a</xsl:otherwise>
78                    </xsl:choose>
79                  </xsl:when>
80                  <xsl:otherwise>
81                    <!-- Global setting -->
82                    <xsl:choose>
83                      <xsl:when test="/bcf:controlfile/bcf:options[@component='biber']/bcf:option/bcf:key[text()='sortcase']/../bcf:value/text()">A</xsl:when>
84                      <xsl:otherwise>a</xsl:otherwise>
85                    </xsl:choose>
86
87                  </xsl:otherwise>
88                </xsl:choose>
89              </tt>
90            </td>
91          </xsl:for-each>
92        </tr>
93      </thead>
94      <tbody>
95        <tr>
96          <xsl:for-each select="$spec/bcf:sort">
97            <xsl:sort select="./@order"/>
98            <td>
99              <ul>
100                <xsl:for-each select="./bcf:sortitem">
101                  <xsl:sort select="./@order"/>
102                  <li>
103                    <!-- left padding -->
104                    <xsl:if test="./@pad_side='left'">
105                      <span class="sort_padding">
106                        <xsl:call-template name='generate-string'>
107                          <xsl:with-param name='text' select="./@pad_char"/>
108                          <xsl:with-param name='count' select="./@pad_width"/>
109                        </xsl:call-template>
110                      </span>
111                    </xsl:if>
112                    <!-- left substring -->
113                    <xsl:if test="./@substring_side='left'">
114                      <span class="sort_substring">
115                        <xsl:call-template name="generate-string">
116                          <xsl:with-param name="text">&gt;</xsl:with-param>
117                          <xsl:with-param name="count" select="./@substring_width"/>
118                        </xsl:call-template>
119                      </span>
120                    </xsl:if>
121                    <xsl:value-of select="./text()"/>
122                    <!-- right padding -->
123                    <xsl:if test="./@pad_side='right'">
124                      <span class="sort_padding">
125                        <xsl:call-template name="generate-string">
126                          <xsl:with-param name="text" select="./@pad_char"/>
127                          <xsl:with-param name="count" select="./@pad_width"/>
128                        </xsl:call-template>
129                      </span>
130                    </xsl:if>
131                    <!-- right substring -->
132                    <xsl:if test="./@substring_side='right'">
133                      <span class="sort_substring">
134                        <xsl:call-template name="generate-string">
135                          <xsl:with-param name="text">&lt;</xsl:with-param>
136                          <xsl:with-param name="count" select="./@substring_width"/>
137                        </xsl:call-template>
138                      </span>
139                    </xsl:if>
140                  </li>
141                </xsl:for-each>
142              </ul>
143            </td>
144          </xsl:for-each>
145        </tr>
146      </tbody>
147    </table>
148    <div class="key"><u>Key</u>
149    <ul>
150      <li><b>Heading Format</b>: (sort-direction)(case-order)/(case-sensitivity)</li>
151      <li><b>Heading key</b>: <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text> = ascending sort, <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text> = descending sort, <tt>Aa</tt> = sort uppercase before lower, <tt>aA</tt> = sort lowercase before upper, <tt>A</tt> = case-sensitive sorting, <tt>a</tt> = case-insensitive sorting, <span class="sort_final">sort fieldset is final master key if defined</span></li>
152      <li><b>Field key</b>: <span class="sort_padding">Padding specification</span> e.g. <span class="sort_padding">0000</span>field = pad field &quot;field&quot; from left with &quot;0&quot; to width 4. <span class="sort_substring">Substring specification</span> e.g. field<span class="sort_substring">&lt;&lt;&lt;&lt;</span> = take width 4 substring from right side of field &quot;field&quot;</li>
153    </ul>
154    </div>
155  </xsl:template>
156
157  <xsl:template match="/">
158    <html>
159      <head>
160        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
161        <title>BibLaTeX control file</title>
162        <style type="text/css">
163          h2,h3,h4 {
164            font-family: Arial,sans-serif;
165          }
166          .key {
167            font-size: 70%;
168            padding-top: 2ex;
169          }
170          .map_meta {
171            color: #6699CC;
172          }
173          .sort_padding {
174            color: #6699CC;
175          }
176          .sort_substring {
177            color: #FF9933;
178          }
179          .sort_final {
180            background-color: #FFAAAA;
181          }
182          .map_final {
183            color: #FF0000;
184          }
185          .map_origentrytype {
186            color: #04FF04;
187          }
188          .map_origfield {
189            color: #6699CC;
190          }
191          .map_origfieldval {
192            color: #FF9933;
193          }
194          .map_null {
195            text-decoration: line-through;
196          }
197          .map_regexp {
198            font-size: 60%;
199            font-family: "Courier New",monospace;
200          }
201          .la_final {
202            color: #FF0000;
203          }
204          .la_substring {
205            color: #FF9933;
206          }
207          .la_compound {
208            color: #6699CC;
209          }
210          .la_namecount {
211            color: #04FF04;
212          }
213          .field_xor_coerce {
214            color: #FF0000;
215          }
216          .inherit_override {
217            color: #FF0000;
218          }
219          .field_nullok {
220            background-color: #99FF99;
221          }
222          .field_skip {
223            background-color: #D0D0D0;
224          }
225          .global_entrytype_fields {
226            color: #666666;
227          }
228          ul {
229            list-style-type: none;
230            margin-left: 0;
231            margin-right: 0;
232            margin-top: 0;
233            margin-bottom: 0;
234            padding-left: 0;
235            padding-top: 0;
236            padding-bottom: 0;
237            padding-right: 0;
238          }
239          table {
240            border-width: 1px;
241            border-spacing: 2px;
242            border-style: hidden;
243            border-color: gray;
244            border-collapse: collapse;
245            background-color: white;
246          }
247          table thead {
248            background-color: #FAF0E6;
249            text-align: center;
250          }
251          table td {
252            wrap: soft;
253            vertical-align: text-top;
254            line-height: 1;
255            padding: 0px 5px 0px 5px;
256            border-width: 1px;
257            border-style: inset;
258            border-color: gray;
259          }
260        </style>
261      </head>
262      <body>
263        <h2><tt>BibLaTeX</tt> Control File (format version: <xsl:value-of select="/bcf:controlfile/@version"/>)</h2>
264        <!-- OPTIONS -->
265        <hr/>
266        <xsl:for-each select="/bcf:controlfile/bcf:options">
267          <h3><xsl:value-of select="./@type"/> options for <tt><xsl:value-of select="./@component"/></tt></h3>
268          <table>
269            <thead>
270              <tr><td>Option</td><td>Value</td></tr>
271            </thead>
272            <tbody>
273              <xsl:for-each select="./bcf:option">
274                <xsl:choose>
275                  <xsl:when test="./@type='singlevalued'">
276                    <tr>
277                      <td><xsl:value-of select="./bcf:key/text()"/></td>
278                      <td><tt><xsl:value-of select="./bcf:value/text()"/></tt></td>
279                    </tr>
280                  </xsl:when>
281                  <xsl:when test="./@type='multivalued'">
282                    <tr>
283                      <td><xsl:value-of select="./bcf:key/text()"/></td>
284                      <td><tt><xsl:for-each select="./bcf:value">
285                        <xsl:sort select="./@order"/>
286                        <xsl:value-of select="./text()"/>
287                        <xsl:if test="not(position()=last())">
288                          <xsl:text disable-output-escaping="yes">,&amp;nbsp;</xsl:text>
289                        </xsl:if>
290                      </xsl:for-each></tt></td>
291                    </tr>
292                  </xsl:when>
293                </xsl:choose>
294              </xsl:for-each>
295            </tbody>
296          </table>
297        </xsl:for-each>
298        <!-- DATASOURCE MAPPINGS -->
299        <xsl:if test="/bcf:controlfile/bcf:sourcemap">
300          <hr/>
301          <h3>Datasource Mappings</h3>
302          <xsl:for-each select="/bcf:controlfile/bcf:sourcemap/bcf:maps">
303            <h4><xsl:value-of select="./@level"/> Mappings for datatype <xsl:value-of select="./@datatype"/> (default overwrite =
304            <xsl:choose>
305              <xsl:when test="./@map_overwrite">1</xsl:when>
306              <xsl:otherwise>0</xsl:otherwise>
307            </xsl:choose>)</h4>
308            <xsl:for-each select="./bcf:map">
309              <table>
310                <thead>
311                  <tr>
312                  <td align="left">Mapping (<xsl:choose>
313                    <xsl:when test="./@map_overwrite">overwrite = <xsl:value-of select="./@map_overwrite"/></xsl:when>
314                    <xsl:otherwise>default overwrite</xsl:otherwise>
315                  </xsl:choose>
316                  <xsl:if test="./bcf:per_type">
317                    , <b>for types</b>:
318                    <xsl:for-each select="./bcf:per_type">
319                      <xsl:sort select="./text()"/>
320                      <xsl:value-of select="./text()"/>
321                      <xsl:if test="not(position()=last())">, </xsl:if>
322                    </xsl:for-each>
323                  </xsl:if>
324                  <xsl:if test="./bcf:per_datasource">
325                    , <b>for datasources</b>:
326                    <xsl:for-each select="./bcf:per_datasource">
327                      <xsl:sort select="./text()"/>
328                      <xsl:value-of select="./text()"/>
329                      <xsl:if test="not(position()=last())">, </xsl:if>
330                    </xsl:for-each>
331                  </xsl:if>)</td>
332                  </tr>
333                </thead>
334                <tbody>
335                  <xsl:for-each select="./bcf:map_step">
336                    <tr><td>
337                      <xsl:if test="./@map_type_source">
338                        <span><xsl:if test="./@map_final='1'">
339                          <xsl:attribute name="class">map_final</xsl:attribute>
340                        </xsl:if>
341                        @<xsl:value-of select="./@map_type_source"/></span>
342                        <xsl:if test="./@map_type_target">
343                          <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>@<xsl:value-of select="./@map_type_target"/>
344                        </xsl:if>
345                      </xsl:if>
346                      <xsl:if test="./@map_field_source">
347                        <span><xsl:if test="./@map_final='1'">
348                          <xsl:attribute name="class">map_final</xsl:attribute>
349                        </xsl:if>
350                        <xsl:value-of select="./@map_field_source"/></span>
351                        <xsl:if test="./@map_field_target">
352                          <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text><xsl:value-of select="./@map_field_target"/>
353                        </xsl:if>
354                        <xsl:if test="./@map_match"> <xsl:text disable-output-escaping="yes">&amp;asymp;</xsl:text> <span class="map_regexp"><xsl:value-of select="./@map_match"/></span></xsl:if>
355                        <xsl:if test="./@map_replace"> <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text> <span class="map_regexp"><xsl:value-of select="./@map_replace"/></span></xsl:if>
356                      </xsl:if>
357
358                      <xsl:if test="./@map_field_set">
359                        <span><xsl:if test="./@map_null='1'">
360                          <xsl:attribute name="class">map_null</xsl:attribute>
361                        </xsl:if>
362                        <xsl:value-of select="./@map_field_set"/></span>
363                        <xsl:if test="./@map_field_value">=&quot;<xsl:value-of select="./@map_field_value"/>&quot;</xsl:if>
364                        <xsl:if test="./@map_origentrytype='1'">=<span class="map_origentrytype">TYPE</span></xsl:if>
365                        <xsl:if test="./@map_origfield='1'">=<span class="map_origfield">FIELD</span></xsl:if>
366                        <xsl:if test="./@map_origfieldval='1'">=<span class="map_origfieldval">FIELDVAL</span></xsl:if></xsl:if></td></tr>
367                  </xsl:for-each>
368                </tbody>
369              </table>
370              <br/>
371            </xsl:for-each>
372          </xsl:for-each>
373          <div class="key"><u>Key</u>
374          <ul>
375            <li><b><span class="map_final">@entrytype</span></b>: Entrytype for entry must match or mapping terminates</li>
376            <li><b><span class="map_final">field</span></b>: Entry must have field or mapping terminates</li>
377            <li><b>@source<xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>@target</b>: Change source entrytype to target entrytype</li>
378            <li><b>source<xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>target</b>: Change source field to target field</li>
379            <li><b><span class="map_null">field</span></b>: Delete field</li>
380            <li><b>field=&quot;string&quot;</b>: Set field to &quot;string&quot;</li>
381            <li><b><span class="map_origentrytype">TYPE</span></b>: Most recently mentioned source entrytype</li>
382            <li><b><span class="map_origfield">FIELD</span></b>: Most recently source field</li>
383            <li><b><span class="map_origfieldval">FIELDVAL</span></b>: Most recently source field value</li>
384            <li><b>field<xsl:text disable-output-escaping="yes">&amp;asymp;</xsl:text>MATCH</b>: field must match Regular Expression MATCH</li>
385            <li><b>field<xsl:text disable-output-escaping="yes">&amp;asymp;</xsl:text>MATCH <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text> REPLACE</b>: Perform Regular Expression match/replace on field</li>
386          </ul>
387          </div>
388        </xsl:if>
389        <!-- LABELALPHA TEMPLATES -->
390        <xsl:if test="/bcf:controlfile/bcf:labelalphatemplate">
391          <hr/>
392          <h3>Labelalpha Templates</h3>
393          <xsl:for-each select="/bcf:controlfile/bcf:labelalphatemplate">
394            <h4>Template for type <xsl:value-of select="./@type"/></h4>
395            <table>
396              <thead>
397                <tr>
398                  <xsl:for-each select="./bcf:labelelement">
399                    <xsl:sort select="./@order"/>
400                    <td>Part <xsl:value-of select="./@order"/></td>
401                  </xsl:for-each>
402                </tr>
403              </thead>
404              <tbody>
405                <tr>
406                  <xsl:for-each select="./bcf:labelelement">
407                    <xsl:sort select="./@order"/>
408                    <td>
409                      <ul>
410                        <xsl:for-each select="./bcf:labelpart">
411                          <li>
412                            <span>
413                              <xsl:if test="./@final='1'">
414                                <xsl:attribute name="class">la_final</xsl:attribute>
415                              </xsl:if>
416                              <xsl:if test="./@substring_compound='1'">
417                                <xsl:attribute name="class">la_compound</xsl:attribute>
418                              </xsl:if>
419                              <xsl:if test="./@ifnamecount">
420                                namecount&gt;<xsl:value-of select="./@ifnamecount"/><xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>
421                              </xsl:if>
422                              <!-- left substring -->
423                              <xsl:if test="./@substring_side='left'">
424                                <span class="la_substring">
425                                  <xsl:call-template name="generate-string">
426                                    <xsl:with-param name="text">&gt;</xsl:with-param>
427                                    <xsl:with-param name="count" select="./@substring_width"/>
428                                  </xsl:call-template>
429                                </span>
430                              </xsl:if>
431                              <xsl:value-of select="./text()"/>
432                              <xsl:if test="./@namecount">
433                                <span><xsl:attribute name="class">la_namecount</xsl:attribute>=<xsl:value-of select="./@namecount"/></span>
434                              </xsl:if>
435                              <!-- right substring -->
436                              <xsl:if test="./@substring_side='right'">
437                                <span class="la_substring">
438                                  <xsl:call-template name="generate-string">
439                                    <xsl:with-param name="text">&lt;</xsl:with-param>
440                                    <xsl:with-param name="count" select="./@substring_width"/>
441                                  </xsl:call-template>
442                                </span>
443                              </xsl:if>
444                              <xsl:if test="./@substring_width='v'">
445                                <span class="la_substring">v<xsl:if test="./@substring_width_max">/<xsl:value-of select="./@substring_width_max"/></xsl:if></span>
446                              </xsl:if>
447                              <xsl:if test="./@substring_width='vf'">
448                                <span class="la_substring">vf<xsl:if test="./@substring_fixed_threshold">/<xsl:value-of select="./@substring_fixed_threshold"/></xsl:if></span>
449                              </xsl:if>
450                              <xsl:if test="./@substring_width='l'">
451                                <span class="la_substring">l</span>
452                              </xsl:if>
453                            </span>
454                          </li>
455                        </xsl:for-each>
456                      </ul>
457                    </td>
458                  </xsl:for-each>
459                </tr>
460              </tbody>
461            </table>
462          </xsl:for-each>
463          <div class="key"><u>Key</u>
464          <ul>
465            <li><b>Heading key</b>: Label parts are concatenated together in part order shown</li>
466            <li><b>Labelpart key</b>: <span class="la_final">Final label, no more parts are considered</span>. &quot;namecount&gt;n<xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>field&quot; - conditional field part, only used if there are more than n names. Substring specification: <span class="la_substring">&gt;&gt;&gt;</span>field = use three chars from left side of field, field<span class="la_substring">&lt;&lt;</span> = use two chars from right side of field, field<span class="la_substring">v/n</span> = variable-width substring, max n chars, field<span class="la_substring">vf/n</span> = variable-width substring fixed to same length as longest string occuring at least n times, field<span class="la_substring">l</span> = list scope disambiguation where the label as a whole is unique, not necessarily the individual parts. <span class="la_compound">field with compound substring extraction enabled</span>. field<span class="la_namecount">=n</span> = only use the first n names to form the labelpart</li>
467          </ul>
468          </div>
469        </xsl:if>
470        <!-- INHERITANCE -->
471        <xsl:if test="/bcf:controlfile/bcf:inheritance">
472          <hr/>
473          <h3>Inheritance</h3>
474          <h4>Defaults</h4>
475          <!-- Defaults -->
476          <table>
477            <thead>
478              <tr><td>Child type <xsl:text disable-output-escaping="yes">&amp;asymp;</xsl:text> Parent type</td><td>Source field <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text> Target field</td></tr>
479            </thead>
480            <tbody>
481              <!-- Defaults for all types -->
482              <tr>
483                <td>* <xsl:text disable-output-escaping="yes"> &amp;asymp; </xsl:text> *</td>
484                <xsl:choose>
485                  <xsl:when test="/bcf:controlfile/bcf:inheritance/bcf:defaults/@inherit_all='true'">
486                    <td>
487                    <span>
488                      <xsl:if test="/bcf:controlfile/bcf:inheritance/bcf:defaults/@override_target='true'">
489                        <xsl:attribute name="class">inherit_override</xsl:attribute>
490                      </xsl:if>
491                    * </span>
492                    <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>
493                    <span>
494                      <xsl:if test="/bcf:controlfile/bcf:inheritance/bcf:defaults/@override_target='false'">
495                        <xsl:attribute name="class">inherit_override</xsl:attribute>
496                      </xsl:if>
497                    * </span>
498                    </td>
499                  </xsl:when>
500                  <xsl:otherwise>
501                    <td>
502                      <span>
503                        <xsl:if test="/bcf:controlfile/bcf:inheritance/bcf:defaults/@override_target='true'">
504                          <xsl:attribute name="class">inherit_override</xsl:attribute>
505                        </xsl:if>
506                      *</span>
507                      <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>
508                      <span>
509                        <xsl:if test="/bcf:controlfile/bcf:inheritance/bcf:defaults/@override_target='false'">
510                          <xsl:attribute name="class">inherit_override</xsl:attribute>
511                        </xsl:if>
512                        <xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text>
513                      </span>
514                    </td>
515                  </xsl:otherwise>
516                </xsl:choose>
517              </tr>
518              <!-- Defaults for certain types -->
519              <xsl:for-each select="/bcf:controlfile/bcf:inheritance/bcf:defaults/bcf:type_pair">
520                <tr>
521                  <td>
522                    <xsl:choose>
523                      <xsl:when test ="./@target='all'">*</xsl:when>
524                      <xsl:otherwise><xsl:value-of select="./@target"/></xsl:otherwise>
525                    </xsl:choose>
526                    <xsl:text disable-output-escaping="yes"> &amp;asymp; </xsl:text>
527                    <xsl:choose>
528                      <xsl:when test ="./@source='all'">*</xsl:when>
529                      <xsl:otherwise><xsl:value-of select="./@source"/></xsl:otherwise>
530                    </xsl:choose>
531                  </td>
532                  <xsl:choose>
533                    <xsl:when test="./@inherit_all='true'">
534                      <td>
535                        <span>
536                          <xsl:if test="./@override_target='true'">
537                            <xsl:attribute name="class">inherit_override</xsl:attribute>
538                          </xsl:if>
539                        *</span>
540                        <xsl:text disable-output-escaping="yes"> &amp;asymp; </xsl:text>
541                        <span>
542                          <xsl:if test="./@override_target='false'">
543                            <xsl:attribute name="class">inherit_override</xsl:attribute>
544                          </xsl:if>
545                        *</span>
546                      </td>
547                    </xsl:when>
548                    <xsl:otherwise>
549                      <td>
550                        <span>
551                          <xsl:if test="./@override_target='true'">
552                            <xsl:attribute name="class">inherit_override</xsl:attribute>
553                          </xsl:if>
554                        *</span>
555                        <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text>
556                        <span>
557                          <xsl:if test="./@override_target='false'">
558                            <xsl:attribute name="class">inherit_override</xsl:attribute>
559                          </xsl:if>
560                          <xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text>
561                        </span>
562                      </td>
563                    </xsl:otherwise>
564                  </xsl:choose>
565                </tr>
566              </xsl:for-each>
567            </tbody>
568          </table>
569          <h4>Specifications</h4>
570          <table>
571            <thead>
572              <tr><td>Child type <xsl:text disable-output-escaping="yes">&amp;asymp;</xsl:text> Parent type</td><td>Source field <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text> Target field</td></tr>
573            </thead>
574            <tbody>
575              <xsl:for-each select="/bcf:controlfile/bcf:inheritance/bcf:inherit">
576                <tr>
577                  <td>
578                    <ul>
579                      <xsl:for-each select="./bcf:type_pair">
580                        <li>
581                          <xsl:choose>
582                            <xsl:when test ="./@target='all'">*</xsl:when>
583                            <xsl:otherwise><xsl:value-of select="./@target"/></xsl:otherwise>
584                          </xsl:choose>
585                          <xsl:text disable-output-escaping="yes"> &amp;asymp; </xsl:text>
586                          <xsl:choose>
587                            <xsl:when test ="./@source='all'">*</xsl:when>
588                            <xsl:otherwise><xsl:value-of select="./@source"/></xsl:otherwise>
589                          </xsl:choose>
590                        </li>
591                      </xsl:for-each>
592                    </ul>
593                  </td>
594                  <td>
595                    <ul>
596                      <xsl:for-each select="./bcf:field">
597                        <li>
598                          <xsl:choose>
599                            <!-- A field skip specification -->
600                            <xsl:when test ="./@skip='true'">
601                              <xsl:value-of select="./@source"/> <xsl:text disable-output-escaping="yes"> &amp;rarr; </xsl:text> <xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text>
602                            </xsl:when>
603                            <!-- A normal field inherit specification -->
604                            <xsl:otherwise>
605                              <span>
606                                <xsl:if test="./@override_target='true'">
607                                  <xsl:attribute name="class">inherit_override</xsl:attribute>
608                                </xsl:if>
609                                <xsl:value-of select="./@source"/>
610                              </span>
611                              <xsl:text disable-output-escaping="yes"> &amp;rarr; </xsl:text>
612                              <span>
613                                <xsl:if test="./@override_target='false'">
614                                  <xsl:attribute name="class">inherit_override</xsl:attribute>
615                                </xsl:if>
616                                <xsl:value-of select="./@target"/>
617                              </span>
618                            </xsl:otherwise>
619                          </xsl:choose>
620                        </li>
621                      </xsl:for-each>
622                    </ul>
623                  </td>
624                </tr>
625              </xsl:for-each>
626            </tbody>
627          </table>
628          <div class="key"><u>Key</u>
629            <ul>
630              <li><tt>*</tt> matches all entrytypes or fields</li>
631              <li><tt>X</tt><xsl:text disable-output-escaping="yes"> &amp;asymp; </xsl:text><tt>Y</tt>: <tt>X</tt> inherits from<tt> Y</tt></li>
632              <li><tt>X</tt><xsl:text disable-output-escaping="yes"> &amp;rarr; &amp;empty;</xsl:text>: Field <tt>X</tt> is suppressed</li>
633              <li><tt>F</tt><xsl:text disable-output-escaping="yes"> &amp;rarr; </xsl:text><tt>F'</tt>: Field <tt>F</tt> in parent becomes field <tt>F'</tt> in child. If both field <tt>F</tt> and field <tt>F'</tt> exist, field in <span class="inherit_override">red</span> overrides the other.</li>
634            </ul>
635          </div>
636        </xsl:if>
637        <!-- SORTING -->
638        <hr/>
639        <h3>Global Default Sorting Options</h3>
640        <h4>Presort defaults</h4>
641        <table>
642          <thead>
643            <tr><td>Entrytype</td><td>Presort default</td></tr>
644          </thead>
645          <tbody>
646            <xsl:for-each select="/bcf:controlfile/bcf:sorting/bcf:presort">
647              <tr>
648                <td>
649                  <xsl:choose>
650                    <xsl:when test="./@type">
651                      <xsl:value-of select="./@type"/>
652                    </xsl:when>
653                    <xsl:otherwise>
654                      ALL
655                    </xsl:otherwise>
656                  </xsl:choose>
657                </td>
658                <td><tt><xsl:value-of select="./text()"/></tt></td>
659              </tr>
660            </xsl:for-each>
661          </tbody>
662        </table>
663        <h4>Sorting exclusions</h4>
664        <table>
665          <thead>
666            <tr><td>Entrytype</td><td>Fields excluded from sorting</td></tr>
667          </thead>
668          <tbody>
669            <xsl:for-each select="/bcf:controlfile/bcf:sorting/bcf:sortexclusion">
670              <tr>
671                <td>
672                  <xsl:value-of select="./@type"/>
673                </td>
674                <td>
675                  <xsl:for-each select="./bcf:exclusion">
676                    <xsl:value-of select="./text()"/>
677                    <xsl:if test="not(position()=last())">
678                      <xsl:text disable-output-escaping="yes">,&amp;nbsp;</xsl:text>
679                    </xsl:if>
680                  </xsl:for-each>
681                </td>
682              </tr>
683            </xsl:for-each>
684          </tbody>
685        </table>
686        <h4>Sorting Specification</h4>
687	      <xsl:call-template name="sorting-spec">
688	        <xsl:with-param name="spec" select="/bcf:controlfile/bcf:sorting"/>
689	      </xsl:call-template>
690        <xsl:if test="/bcf:controlfile/bcf:datamodel">
691          <hr/>
692          <h3>Data Model</h3>
693          <h4>Legal entrytypes</h4>
694          <table>
695            <thead>
696              <tr><td>Entrytype</td><td>Legal fields for entrytype</td></tr>
697            </thead>
698            <tbody>
699              <tr>
700                <td>GLOBAL</td>
701                <td>
702                  <div class="global_entrytype_fields">
703                    <xsl:for-each select="/bcf:controlfile/bcf:datamodel/bcf:entryfields[not(bcf:entrytype)]/bcf:field">
704                      <xsl:sort select="./text()"/>
705                      <xsl:value-of select="./text()"/>
706                      <xsl:if test="not(position()=last())">, </xsl:if>
707                    </xsl:for-each>
708                  </div>
709                </td>
710              </tr>
711              <xsl:for-each select="/bcf:controlfile/bcf:datamodel/bcf:entrytypes/bcf:entrytype">
712                <tr>
713                  <td><xsl:value-of select="./text()"/></td>
714                  <!-- Save a varible pointing to the entrytype node -->
715                  <xsl:variable name="entrynode" select="current()"/>
716                  <!-- Fields which are valid for this entrytype -->
717                  <td>
718                    <!-- If no fields explicitly listed for entrytype, just global fields -->
719                    <xsl:if test="not(/bcf:controlfile/bcf:datamodel/bcf:entryfields/bcf:entrytype[text()=$entrynode/text()])">
720                      <div class="global_entrytype_fields">GLOBAL fields</div>
721                    </xsl:if>
722                    <xsl:for-each select="/bcf:controlfile/bcf:datamodel/bcf:entryfields">
723                      <!-- fields valid just for this entrytype -->
724                      <xsl:if test="./bcf:entrytype[text()=$entrynode/text()]">
725                        <!-- List global fields for all entrytypes first -->
726                        <div class="global_entrytype_fields">GLOBAL fields</div>
727                        <xsl:for-each select="./bcf:field">
728                          <xsl:sort select="./text()"/>
729                          <xsl:value-of select="./text()"/>
730                          <xsl:if test="not(position()=last())">, </xsl:if>
731                        </xsl:for-each>
732                      </xsl:if>
733                    </xsl:for-each>
734                  </td>
735                </tr>
736              </xsl:for-each>
737            </tbody>
738          </table>
739          <h4>Field Types</h4>
740          <table>
741            <thead>
742              <tr><td>Field</td><td>Field Format</td><td>Data type</td></tr>
743            </thead>
744            <tbody>
745              <xsl:for-each select="/bcf:controlfile/bcf:datamodel/bcf:fields/bcf:field">
746                <tr>
747                  <td>
748                    <xsl:value-of select="./text()"/>
749                    <xsl:if test="./@nullok='true'"><xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text></xsl:if>
750                    <xsl:if test="./@skip_output='true'"><xsl:text disable-output-escaping="yes">&amp;loz;</xsl:text></xsl:if>
751                  </td>
752                  <td>
753                    <xsl:choose>
754                      <xsl:when test="./@format"><xsl:value-of select="./@format"/></xsl:when>
755                      <xsl:otherwise>standard</xsl:otherwise>
756                    </xsl:choose>
757                  </td>
758                  <td>
759                    <xsl:value-of select="./@datatype"/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-of select="./@fieldtype"/>
760                  </td>
761                </tr>
762              </xsl:for-each>
763            </tbody>
764          </table>
765          <div class="key"><u>Key</u>
766            <ul>
767              <li><xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text> = field can null in <tt>.bbl</tt>, <xsl:text disable-output-escaping="yes">&amp;loz;</xsl:text> = field is not output to <tt>.bbl</tt></li>
768            </ul>
769          </div>
770          <xsl:if test="/bcf:controlfile/bcf:datamodel/bcf:constraints">
771            <hr/>
772            <h3>Constraints</h3>
773            <table>
774              <thead>
775                <tr><td>Entrytypes</td><td>Constraint</td></tr>
776              </thead>
777              <tbody>
778                <xsl:for-each select="/bcf:controlfile/bcf:datamodel/bcf:constraints">
779                  <tr>
780                    <td>
781                      <ul>
782                        <xsl:for-each select="./bcf:entrytype">
783                          <li>
784                            <xsl:value-of select="./text()"/>
785                          </li>
786                        </xsl:for-each>
787                      </ul>
788                    </td>
789                    <td>
790                      <ul>
791                        <xsl:for-each select="./bcf:constraint">
792                          <li>
793                            <xsl:choose>
794                              <xsl:when test="./@type='conditional'">
795                                <xsl:choose>
796                                  <xsl:when test="./bcf:antecedent/@quant='all'"><xsl:text disable-output-escaping="yes">&amp;forall;</xsl:text></xsl:when>
797                                  <xsl:when test="./bcf:antecedent/@quant='one'"><xsl:text disable-output-escaping="yes">&amp;exist;</xsl:text></xsl:when>
798                                  <xsl:when test="./bcf:antecedent/@quant='none'"><xsl:text disable-output-escaping="yes">&amp;not;&amp;exist;</xsl:text></xsl:when>
799                                </xsl:choose>
800                                (
801                                <xsl:for-each select="./bcf:antecedent/bcf:field">
802                                  <xsl:value-of select="./text()"/>
803                                  <xsl:if test="not(position()=last())">,</xsl:if>
804                                </xsl:for-each>
805                                )
806                                <xsl:text disable-output-escaping="yes">&amp;rarr; </xsl:text>
807                                <xsl:choose>
808                                  <xsl:when test="./bcf:consequent/@quant='all'"><xsl:text disable-output-escaping="yes">&amp;forall;</xsl:text></xsl:when>
809                                  <xsl:when test="./bcf:consequent/@quant='one'"><xsl:text disable-output-escaping="yes">&amp;exist;</xsl:text></xsl:when>
810                                  <xsl:when test="./bcf:consequent/@quant='none'"><xsl:text disable-output-escaping="yes">&amp;not;&amp;exist;</xsl:text></xsl:when>
811                                </xsl:choose>
812                                (
813                                <xsl:for-each select="./bcf:consequent/bcf:field">
814                                  <xsl:value-of select="./text()"/>
815                                  <xsl:if test="not(position()=last())">,</xsl:if>
816                                </xsl:for-each>
817                                )
818                              </xsl:when>
819                              <xsl:when test="./@type='data'">
820                                <xsl:choose>
821                                  <xsl:when test="./@datatype='integer'">
822                                    <xsl:value-of select="./@rangemin"/><xsl:text disable-output-escaping="yes">&amp;le;</xsl:text>
823                                    (
824                                    <xsl:for-each select="./bcf:field">
825                                      <xsl:value-of select="./text()"/>
826                                      <xsl:if test="not(position()=last())">,</xsl:if>
827                                    </xsl:for-each>
828                                    )
829                                    <xsl:text disable-output-escaping="yes">&amp;le;</xsl:text><xsl:value-of select="./@rangemax"/>
830                                  </xsl:when>
831                                  <xsl:when test="./@datatype='datespec'">
832                                    (
833                                    <xsl:for-each select="./bcf:field">
834                                      <xsl:value-of select="./text()"/>
835                                      <xsl:if test="not(position()=last())">,</xsl:if>
836                                    </xsl:for-each>
837                                    )
838                                    must be dates
839                                  </xsl:when>
840                                </xsl:choose>
841                              </xsl:when>
842                            </xsl:choose>
843                            <xsl:choose>
844                              <xsl:when test="./@type='mandatory'">
845                                <xsl:for-each select="./bcf:fieldxor">
846                                  <xsl:text disable-output-escaping="yes">&amp;oplus;</xsl:text>
847                                  (
848                                  <xsl:for-each select="./bcf:field">
849                                    <span>
850                                      <xsl:if test="./@coerce='true'">
851                                        <xsl:attribute name="class">field_xor_coerce</xsl:attribute>
852                                      </xsl:if>
853                                      <xsl:value-of select="./text()"/>
854                                    </span>
855                                    <xsl:if test="not(position()=last())">,</xsl:if>
856                                  </xsl:for-each>
857                                  )
858                                </xsl:for-each>
859                                <xsl:for-each select="./bcf:fieldor">
860                                  <xsl:text disable-output-escaping="yes">&amp;or;</xsl:text>
861                                  (
862                                  <xsl:for-each select="./bcf:field">
863                                    <xsl:value-of select="./text()"/>
864                                    <xsl:if test="not(position()=last())">,</xsl:if>
865                                  </xsl:for-each>
866                                  )
867                                </xsl:for-each>
868                              </xsl:when>
869                            </xsl:choose>
870                          </li>
871                        </xsl:for-each>
872                      </ul>
873                    </td>
874                  </tr>
875                </xsl:for-each>
876              </tbody>
877            </table>
878            <div class="key"><u>Key</u>
879              <ul>
880               <li><tt>C</tt> <xsl:text disable-output-escaping="yes">&amp;rarr;</xsl:text> <tt>C'</tt>: If condition <tt>C</tt> is met then condition <tt>C'</tt> must also be met</li>
881               <li><xsl:text disable-output-escaping="yes">&amp;forall;</xsl:text> ( ... ): True if all fields in list exist</li>
882               <li><xsl:text disable-output-escaping="yes">&amp;exist;</xsl:text> ( ... ): True if one field in list exists</li>
883               <li><xsl:text disable-output-escaping="yes">&amp;not;&amp;exist;</xsl:text> ( ... ): True if no fields in list exist</li>
884               <li><tt>n</tt> <xsl:text disable-output-escaping="yes">&amp;le;</xsl:text> ( ... ) <xsl:text disable-output-escaping="yes">&amp;le;</xsl:text> <tt>m</tt>: True if fields in list are have values in the range <tt>n</tt>-<tt>m</tt></li>
885               <li><xsl:text disable-output-escaping="yes">&amp;oplus;</xsl:text> ( ... ): True if at least and at most one of the fields in the list exists (XOR). If more than field in the set exists, all will be ignored except for the one in <span class="field_xor_coerce">red</span></li>
886               <li><xsl:text disable-output-escaping="yes">&amp;or;</xsl:text> ( ... ): True if at least one of the fields in the list exists (OR)</li>
887              </ul>
888            </div>
889          </xsl:if>
890        </xsl:if>
891        <hr/>
892        <h3>Reference Sections</h3>
893        <!-- Section 0 is special as it can be empty and there can be many of them -->
894        <h4>Section 0</h4>
895        <table>
896          <thead>
897            <tr><td>Data sources</td><td>Citekeys</td><td>Dynamic sets</td></tr>
898          </thead>
899          <tbody>
900            <tr>
901              <td>
902                <ul>
903                  <xsl:for-each select="/bcf:controlfile/bcf:bibdata[@section='0']">
904                    <xsl:for-each select="./bcf:datasource">
905                      <li>
906                        <xsl:value-of select="./text()"/> (<xsl:value-of select="./@datatype"/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-of select="./@type"/>)
907                      </li>
908                    </xsl:for-each>
909                  </xsl:for-each>
910                </ul>
911              </td>
912              <td>
913                <ul>
914                  <xsl:for-each
915                      select="/bcf:controlfile/bcf:section[@number='0']/bcf:citekey[not(@type='set')]">
916                    <li><tt><xsl:value-of select="./text()"/></tt></li>
917                  </xsl:for-each>
918                </ul>
919              </td>
920              <td>
921                <ul>
922                  <xsl:for-each
923                      select="/bcf:controlfile/bcf:section[@number='0']/bcf:citekey[@type='set']">
924                    <li><tt><xsl:value-of select="./text()"/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>(<xsl:value-of select="./@members"/>)</tt></li>
925                  </xsl:for-each>
926                </ul>
927              </td>
928            </tr>
929          </tbody>
930        </table>
931        <xsl:for-each select="/bcf:controlfile/bcf:section[@number != '0']">
932          <!-- Save a varible pointing to the section number -->
933          <xsl:variable name="secnum" select="./@number"/>
934          <h4>Section <xsl:value-of select="$secnum"/></h4>
935          <table>
936            <thead>
937              <tr><td>Data sources</td><td>Citekeys</td></tr>
938            </thead>
939            <tbody>
940              <tr>
941                <td>
942                  <ul>
943                    <xsl:for-each select="/bcf:controlfile/bcf:bibdata[@section=$secnum]">
944                      <xsl:for-each select="./bcf:datasource">
945                        <li>
946                          <xsl:value-of select="./text()"/> (<xsl:value-of select="./@datatype"/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-of select="./@type"/>)
947                        </li>
948                      </xsl:for-each>
949                    </xsl:for-each>
950                  </ul>
951                </td>
952                <td>
953                  <ul>
954                    <xsl:for-each select="./bcf:citekey">
955                      <li><tt><xsl:value-of select="./text()"/></tt></li>
956                    </xsl:for-each>
957                  </ul>
958                </td>
959              </tr>
960            </tbody>
961          </table>
962        </xsl:for-each>
963        <h3>Sorting Lists</h3>
964        <xsl:for-each select="/bcf:controlfile/bcf:sortlist">
965          <h4><u>Sorting list &quot;<xsl:value-of select="./@name"/>&quot;</u></h4>
966          <div>
967            <h6>Filters</h6>
968            <table>
969              <thead>
970                <tr><td>Filter type</td><td>Filter value</td></tr>
971              </thead>
972              <tbody>
973                <xsl:for-each select="./bcf:filter">
974                  <tr><td><xsl:value-of select="./@type"/></td><td><xsl:value-of select="./text()"/></td></tr>
975                </xsl:for-each>
976              </tbody>
977            </table>
978          </div>
979          <div>
980            <h6>Sorting Specification</h6>
981            <xsl:choose>
982              <xsl:when test="./bcf:sorting">
983                <xsl:call-template name="sorting-spec">
984                  <xsl:with-param name="spec" select="./bcf:sorting"/>
985                </xsl:call-template>
986              </xsl:when>
987              <xsl:otherwise>
988                (global default)
989              </xsl:otherwise>
990            </xsl:choose>
991          </div>
992        </xsl:for-each>
993      </body>
994    </html>
995  </xsl:template>
996</xsl:stylesheet>
997<!--
998    Copyright 2009-2015 François Charette and Philip Kime, all rights reserved.
999
1000    This code is free software.  You can redistribute it and/or
1001    modify it under the terms of the Artistic License 2.0.
1002
1003    This program is distributed in the hope that it will be useful,
1004    but without any warranty; without even the implied warranty of
1005    merchantability or fitness for a particular purpose.
1006-->
1007