File: apichanges.xsl

package info (click to toggle)
libnb-platform18-java 7.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 81,288 kB
  • ctags: 101,418
  • sloc: java: 682,018; xml: 117,409; ansic: 6,281; sh: 3,982; cpp: 2,458; objc: 288; perl: 276; makefile: 252
file content (595 lines) | stat: -rw-r--r-- 29,773 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.

Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.


The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://www.netbeans.org/cddl-gplv2.html
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
specific language governing permissions and limitations under the
License.  When distributing the software, include this License Header
Notice in each file and include the License file at
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"

Contributor(s):

The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.

If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 2, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 2] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 2 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 2 code and therefore, elected the GPL
Version 2 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
-->

<!--
This DOCTYPE assumes that the pseudo-DTD given at the end of the
XSLT specification is present in the named location. It cannot be
committed to the repository for legal reasons. You need to download it:
<!DOCTYPE xsl:stylesheet [
<!ENTITY % result-elements "
| a | abbr | acronym | address | area
| b | base | bdo | big | blockquote
| body | br | button | caption | cite
| code | col | colgroup | dd | del
| dfn | div | dl | dt | em
| fieldset | form | h1 | h2 | h3
| h4 | h5 | h6 | head | hr
| html | i | img | input | ins
| kbd | label | legend | li | link
| map | meta | noscript | object | ol
| optgroup | option | p | param | pre
| q | samp | script | select | small
| span | strong | style | sub | sup
| table | tbody | td | textarea | tfoot
| th | thead | title | tr | tt
| ul | var
">
<!ENTITY % xsl-struct SYSTEM "xsl.dtd">
%xsl-struct;
]>
-->

<!-- TODO:
- in details of a change, list all branches it applies to
- create separate lists for all changes between one branch and the next
- clearly mark incompatible bits in details of a change, besides text contents
- warn about any changes made after a certain date which incl. additions but
  have no associated API version
- ability to display authors in pretty format
- kill $api-list and select from /apichanges/apidefs/apidef instead to get an
  API list (but the hack is still needed for index by affected class)
- whenever <hN> tags are used as part of a changelist template, the proper
  header level should be computed based on the surrounding context
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <!-- Overridable parameters: -->
    <xsl:param name="issue-url-base" select="'https://netbeans.org/bugzilla/show_bug.cgi?id='"/>
    <xsl:param name="javadoc-url-base" select="'???'"/>

    <!-- Main document structure: -->
    <xsl:template match="/">
        <html>
            <xsl:apply-templates select="apichanges/htmlcontents/node()"/>
        </html>
    </xsl:template>

    <!-- Summarizing links to changes: -->
    <xsl:template match="change" mode="summary">
        <li>
            <xsl:if test="date">(<xsl:apply-templates select="date"/>)<xsl:text> </xsl:text></xsl:if>
            <a><xsl:attribute name="href">#<xsl:call-template name="change-id"/></xsl:attribute><xsl:apply-templates select="summary/node()"/></a>
        </li>
    </xsl:template>

    <!-- Showing API version: -->
    <xsl:template match="change" mode="summary-show-version">
        <li>
            (<xsl:apply-templates select="version"/>)<xsl:text> </xsl:text>
            <a><xsl:attribute name="href">#<xsl:call-template name="change-id"/></xsl:attribute><xsl:apply-templates select="summary/node()"/></a>
        </li>
    </xsl:template>

    <!-- Hack to get XSLT to group things automatically: -->
    <xsl:variable name="all-apis">
        <xsl:for-each select="/apichanges/changes/change[api]">
            <xsl:sort data-type="text" order="ascending" select="api/@name"/>
            <xsl:value-of select="position()"/><xsl:text>!</xsl:text><xsl:value-of select="api/@name"/><xsl:text>!</xsl:text>
        </xsl:for-each>
    </xsl:variable>

    <!-- Summarizing links to changes; show API headers: -->
    <!-- (currently unused) -->
    <xsl:template match="change" mode="summary-group-api">
        <!--
        Tricky. We list all of the changes as usual, sorted by API and date.
        We have already computed what all of the API names are (incl. duplicates)
        in order and have this indexed by position in the list. To tell if it
        is necessary to start a new group we calculate whether the API of this
        change is different from that of the preceding one (and use the same trick
        to tell if the bullet needs to be closed). XSLT does not seem to have facilities
        to manipulate doc fragments sanely (i.e. use of for-each or array indexing) so
        we have to keep the info in a string and use string functions to do it, alas.
        -->
        <xsl:variable name="this-api" select="api/@name"/>
        <xsl:variable name="prev-api" select="substring-after(substring-before($all-apis, concat('!', position(), '!')), concat(position() - 1, '!'))"/>
        <xsl:variable name="next-api" select="substring-before(substring-after($all-apis, concat('!', position() + 1, '!')), '!')"/>
        <xsl:variable name="is-first" select="position() = 1 or $prev-api != $this-api"/>
        <xsl:variable name="is-last" select="position() = last() or $this-api != $next-api"/>
        <xsl:if test="$is-first">
            <h2>
                <xsl:apply-templates select="api"/>
            </h2>
            <!-- Need to use the slinky disable-output-escaping because we do not close the ul here: -->
            <xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
        </xsl:if>
        <xsl:apply-templates select="." mode="summary"/>
        <xsl:if test="$is-last">
            <xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="change" mode="details-group-api">
        <xsl:variable name="this-api" select="api/@name"/>
        <xsl:variable name="prev-api" select="substring-after(substring-before($all-apis, concat('!', position(), '!')), concat(position() - 1, '!'))"/>
        <!--<xsl:variable name="next-api" select="substring-before(substring-after($all-apis, concat('!', position() + 1, '!')), '!')"/>-->
        <xsl:variable name="is-first" select="position() = 1 or $prev-api != $this-api"/>
        <!--<xsl:variable name="is-last" select="position() = last() or $this-api != $next-api"/>-->
        <xsl:if test="$is-first">
            <hr style="width:50%"/>
            <h2>
                <a>
                    <xsl:attribute name="name"><xsl:value-of select="$this-api"/></xsl:attribute>
                    <xsl:apply-templates select="api"/>
                </a>
            </h2>
        </xsl:if>
        <xsl:apply-templates select="." mode="details"/>
    </xsl:template>

    <!-- Similar stuff but by class changed: -->
    <xsl:variable name="all-classes">
        <xsl:for-each select="/apichanges/changes/change/class">
            <!--<xsl:sort data-type="text" order="ascending" select="@package"/>-->
            <xsl:sort data-type="text" order="ascending" select="@name"/>
            <xsl:value-of select="position()"/><xsl:text>!</xsl:text><xsl:value-of select="@package"/>.<xsl:value-of select="@name"/><xsl:text>!</xsl:text>
        </xsl:for-each>
    </xsl:variable>

    <xsl:template match="change/class" mode="summary-group-class">
        <xsl:variable name="this-class" select="concat(@package, '.', @name)"/>
        <xsl:variable name="prev-class" select="substring-after(substring-before($all-classes, concat('!', position(), '!')), concat(position() - 1, '!'))"/>
        <xsl:variable name="next-class" select="substring-before(substring-after($all-classes, concat('!', position() + 1, '!')), '!')"/>
        <xsl:variable name="is-first" select="position() = 1 or $prev-class != $this-class"/>
        <xsl:variable name="is-last" select="position() = last() or $this-class != $next-class"/>
        <xsl:if test="$is-first">
            <xsl:if test="contains(@name, '.') or contains(@name, '$')">
                <xsl:message terminate="yes">No inner classes permitted in &lt;class/&gt;: <xsl:value-of select="@name"/></xsl:message>
            </xsl:if>
            <h2>
                <a><xsl:attribute name="name"><xsl:value-of select="$this-class"/></xsl:attribute>
                    <code><span style="color:gray"><xsl:value-of select="@package"/>.</span><xsl:value-of select="@name"/></code>
                </a>
            </h2>
            <xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
        </xsl:if>
        <xsl:apply-templates select=".." mode="summary"/>
        <xsl:if test="$is-last">
            <xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
        </xsl:if>
    </xsl:template>

    <!-- The details of a change: -->
    <xsl:template match="change" mode="details">
        <xsl:comment> AUTOMATICALLY GENERATED - DO NOT EDIT ME! </xsl:comment>
        <h3><a><xsl:attribute name="name"><xsl:call-template name="change-id"/></xsl:attribute><xsl:apply-templates select="summary/node()"/></a></h3>
        <em>
            <xsl:choose>
                <xsl:when test="date">
                    <xsl:apply-templates select="date"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>(date unknown)</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="version">
                <xsl:text>; API spec. version: </xsl:text>
                <xsl:apply-templates select="version"/>
            </xsl:if>
            <xsl:if test="class">
                <xsl:text>; affected top-level classes:</xsl:text>
                <xsl:for-each select="class">
                    <xsl:text> </xsl:text>
                    <xsl:apply-templates select="."/>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="package">
                <xsl:text>; affected packages:</xsl:text>
                <xsl:for-each select="package">
                    <xsl:text> </xsl:text>
                    <xsl:apply-templates select="."/>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="author">
                <xsl:text>; made by:</xsl:text>
                <xsl:for-each select="author">
                    <xsl:text> </xsl:text>
                    <xsl:apply-templates select="."/>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="issue">
                <xsl:text>; issues:</xsl:text>
                <xsl:for-each select="issue">
                    <xsl:text> </xsl:text>
                    <xsl:apply-templates select="."/>
                </xsl:for-each>
            </xsl:if>
        </em>
        <br/>
        <xsl:apply-templates select="description/node()"/>
        <xsl:if test="compatibility/node()">
            <br/><strong>Compatibility: </strong> <xsl:apply-templates select="compatibility/node()"/>
        </xsl:if>
        <xsl:if test="compatibility/@source = 'incompatible' and compatibility/@binary = 'compatible'">
            <br/><em><a href="http://wiki.netbeans.org/VersioningPolicy#Compatible_change_on_the_trunk">Binary-compatible</a></em>
        </xsl:if>
    </xsl:template>

    <!-- Link to one API group: -->
    <xsl:template match="api" mode="api-summary">
        <xsl:variable name="this-api" select="@name"/>
        <xsl:variable name="prev-api" select="substring-after(substring-before($all-apis, concat('!', position(), '!')), concat(position() - 1, '!'))"/>
        <xsl:variable name="is-first" select="position() = 1 or $prev-api != $this-api"/>
        <xsl:if test="$is-first">
            <li>
                <a>
                    <xsl:attribute name="href">#<xsl:value-of select="$this-api"/></xsl:attribute>
                    <xsl:apply-templates select="."/>
                </a>
            </li>
        </xsl:if>
    </xsl:template>

    <!-- Show various lists: -->

    <xsl:template match="changelist[@style = 'list-all-apis']">
        <xsl:call-template name="changelist-list-all-apis"/>
    </xsl:template>
    <xsl:template name="changelist-list-all-apis">
        <ul>
            <xsl:apply-templates select="/apichanges/changes/change/api" mode="api-summary">
                <xsl:sort data-type="text" order="ascending" select="@name"/>
            </xsl:apply-templates>
            <xsl:if test="/apichanges/changes/change[count(api) = 0]">
                <li><a href="#uncategorized-api">Uncategorized changes</a></li>
            </xsl:if>
        </ul>
    </xsl:template>

    <xsl:template match="changelist[@style = 'incompat-by-date']">
        <xsl:call-template name="changelist-incompat-by-date"/>
    </xsl:template>
    <xsl:template name="changelist-incompat-by-date">
        <ul>
            <xsl:apply-templates select="/apichanges/changes/change[compatibility/@binary='incompatible' or compatibility/@source='incompatible' or compatibility/@semantic='incompatible']" mode="summary">
                <xsl:sort data-type="number" order="descending" select="date/@year"/>
                <xsl:sort data-type="number" order="descending" select="date/@month"/>
                <xsl:sort data-type="number" order="descending" select="date/@day"/>
            </xsl:apply-templates>
        </ul>
    </xsl:template>

    <xsl:template match="changelist[@style = 'compat-by-date']">
        <ul>
            <xsl:apply-templates select="/apichanges/changes/change[compatibility/@binary='compatible' and compatibility/@source='compatible' and compatibility/@semantic='compatible']" mode="summary">
                <xsl:sort data-type="number" order="descending" select="date/@year"/>
                <xsl:sort data-type="number" order="descending" select="date/@month"/>
                <xsl:sort data-type="number" order="descending" select="date/@day"/>
            </xsl:apply-templates>
        </ul>
    </xsl:template>

    <xsl:template match="changelist[@style = 'all-by-date']">
        <xsl:call-template name="changelist-all-by-date"/>
    </xsl:template>
    <xsl:template name="changelist-all-by-date">
        <ul>
            <xsl:apply-templates select="/apichanges/changes/change" mode="summary">
                <xsl:sort data-type="number" order="descending" select="date/@year"/>
                <xsl:sort data-type="number" order="descending" select="date/@month"/>
                <xsl:sort data-type="number" order="descending" select="date/@day"/>
            </xsl:apply-templates>
        </ul>
    </xsl:template>

    <xsl:template match="changelist[@style = 'all-by-version']">
        <xsl:call-template name="changelist-all-by-version"/>
    </xsl:template>
    <xsl:template name="changelist-all-by-version">
        <ul>
            <xsl:apply-templates select="/apichanges/changes/change[version]" mode="summary-show-version">
                <xsl:sort data-type="number" order="descending" select="version/@major"/>
                <xsl:sort data-type="number" order="descending" select="version/@minor"/>
            </xsl:apply-templates>
        </ul>
    </xsl:template>

    <xsl:template match="changelist[@style = 'all-by-api']">
        <xsl:apply-templates select="/apichanges/changes/change[api]" mode="summary-group-api">
            <xsl:sort data-type="text" order="ascending" select="api/@name"/>
            <xsl:sort data-type="number" order="descending" select="date/@year"/>
            <xsl:sort data-type="number" order="descending" select="date/@month"/>
            <xsl:sort data-type="number" order="descending" select="date/@day"/>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="changelist[@style = 'all-by-class']">
        <xsl:call-template name="changelist-all-by-class"/>
    </xsl:template>
    <xsl:template name="changelist-all-by-class">
        <xsl:apply-templates select="/apichanges/changes/change/class" mode="summary-group-class">
            <xsl:sort data-type="text" order="ascending" select="@name"/>
            <xsl:sort data-type="number" order="descending" select="../date/@year"/>
            <xsl:sort data-type="number" order="descending" select="../date/@month"/>
            <xsl:sort data-type="number" order="descending" select="../date/@day"/>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="changelist[@style = 'details-by-date']">
        <xsl:apply-templates select="/apichanges/changes/change" mode="details">
            <xsl:sort data-type="number" order="descending" select="date/@year"/>
            <xsl:sort data-type="number" order="descending" select="date/@month"/>
            <xsl:sort data-type="number" order="descending" select="date/@day"/>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="changelist[@style = 'details-by-api']">
        <xsl:call-template name="changelist-details-by-api"/>
    </xsl:template>
    <xsl:template name="changelist-details-by-api">
        <xsl:apply-templates select="/apichanges/changes/change[api]" mode="details-group-api">
            <xsl:sort data-type="text" order="ascending" select="api/@name"/>
            <xsl:sort data-type="number" order="descending" select="date/@year"/>
            <xsl:sort data-type="number" order="descending" select="date/@month"/>
            <xsl:sort data-type="number" order="descending" select="date/@day"/>
        </xsl:apply-templates>
        <xsl:if test="/apichanges/changes/change[count(api) = 0]">
            <hr style="width:50%"/><h2><a name="uncategorized-api">Uncategorized changes</a></h2>
            <xsl:apply-templates select="/apichanges/changes/change[count(api) = 0]" mode="details">
                <xsl:sort data-type="number" order="descending" select="date/@year"/>
                <xsl:sort data-type="number" order="descending" select="date/@month"/>
                <xsl:sort data-type="number" order="descending" select="date/@day"/>
            </xsl:apply-templates>
        </xsl:if>
    </xsl:template>

    <!-- Fallback: -->
    <xsl:template match="changelist" priority="-0.1">
        <xsl:message terminate="yes">
            Unrecognized changelist style: <xsl:value-of select="@style"/>
        </xsl:message>
    </xsl:template>
    
    <!-- Show all change lists usually needed: -->
    
    <xsl:template match="standard-changelists">
      <h1><a name="list-all-apis">Index of APIs</a></h1>
      <xsl:call-template name="changelist-list-all-apis"/>

      <h1><a name="incompat-by-date">Incompatible changes by date</a></h1>
      <p>Fuller descriptions of all changes can be found below (follow links).</p>
      <p>Not all deprecations are listed here, assuming that the deprecated
        APIs continue to essentially work. For a full deprecation list, please
        consult the
        <a href="deprecated-list.html">Javadoc</a>.</p>
      <xsl:call-template name="changelist-incompat-by-date"/>

      <h1><a name="all-by-date">All changes by date</a></h1>
      <xsl:call-template name="changelist-all-by-date"/>

      <h1><a name="all-by-version">Changes by version</a></h1>
      <p>
        These API specification versions may be used to indicate that a module
        requires a certain API feature in order to function. For example, if you
        see here a feature you need which is labelled <samp>1.20</samp>, your
        manifest should contain in its main attributes the line:
      </p>
      <pre>OpenIDE-Module-Module-Dependencies: <xsl:value-of select="@module-code-name"/> &gt; 1.20</pre>
      <xsl:call-template name="changelist-all-by-version"/>

      <h1><a name="all-by-class">Changes by affected class</a></h1>
      <xsl:call-template name="changelist-all-by-class"/>

      <hr/><h1><a name="details-by-api">Details of all changes by API and date</a></h1>
      <xsl:call-template name="changelist-details-by-api"/>
    </xsl:template>

    <!-- Format dates readably: -->
    <xsl:template match="date">
        <xsl:choose>
            <xsl:when test="@month=1">Jan</xsl:when>
            <xsl:when test="@month=2">Feb</xsl:when>
            <xsl:when test="@month=3">Mar</xsl:when>
            <xsl:when test="@month=4">Apr</xsl:when>
            <xsl:when test="@month=5">May</xsl:when>
            <xsl:when test="@month=6">Jun</xsl:when>
            <xsl:when test="@month=7">Jul</xsl:when>
            <xsl:when test="@month=8">Aug</xsl:when>
            <xsl:when test="@month=9">Sep</xsl:when>
            <xsl:when test="@month=10">Oct</xsl:when>
            <xsl:when test="@month=11">Nov</xsl:when>
            <xsl:when test="@month=12">Dec</xsl:when>
        </xsl:choose><xsl:text> </xsl:text>
        <xsl:value-of select="@day"/> '<xsl:value-of select="substring(@year, 3, 2)"/>
    </xsl:template>

    <xsl:template match="version" >
        <xsl:apply-templates mode="print-version" select="." />
    </xsl:template>
    
    <xsl:template match="version" mode="print-version" >
        <xsl:value-of select="@major"/>.<xsl:value-of select="@minor"/>
        <xsl:if test="@subminor">.<xsl:value-of select="@subminor"/></xsl:if>
        <xsl:if test="@subsubminor">.<xsl:value-of select="@subsubminor"/></xsl:if>
    </xsl:template>

    <xsl:template match="api">
        <xsl:variable name="apiname" select="@name"/>
        <xsl:variable name="def" select="/apichanges/apidefs/apidef[@name = $apiname]"/>
        <xsl:if test="count($def) = 0 or count($def) > 1">
            <xsl:message terminate="yes">Unknown API: <xsl:value-of select="$apiname"/> (in #<xsl:call-template name="change-id"><xsl:with-param name="node" select=".."/></xsl:call-template>)</xsl:message>
        </xsl:if>
        <xsl:apply-templates select="$def/node()"/>
    </xsl:template>

    <xsl:template match="class">
        <xsl:if test="@package = '' or @name = ''">
            <xsl:message terminate="yes">
                Classes must have both package and name specified: <xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>
            </xsl:message>
        </xsl:if>
        <xsl:choose>
            <xsl:when test="@link = 'no'">
                <code><xsl:value-of select="@package"/>.<xsl:value-of select="@name"/></code>
            </xsl:when>
            <xsl:otherwise>
                <a>
                    <xsl:attribute name="href"><xsl:value-of select="$javadoc-url-base"/>/<xsl:value-of select="translate(@package, '.', '/')"/>/<xsl:value-of select="@name"/>.html</xsl:attribute>
                    <code><!--<xsl:value-of select="@package"/>.--><xsl:value-of select="@name"/></code>
                </a>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="package">
        <xsl:choose>
            <xsl:when test="@link = 'no'">
                <code><xsl:value-of select="@name"/></code>
            </xsl:when>
            <xsl:otherwise>
                <a>
                    <xsl:attribute name="href"><xsl:value-of select="$javadoc-url-base"/>/<xsl:value-of select="translate(@name, '.', '/')"/>/package-summary.html</xsl:attribute>
                    <code><xsl:value-of select="@name"/></code>
                </a>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="author">
        <xsl:value-of select="@login"/>
    </xsl:template>

    <xsl:template match="issue">
        <a>
            <xsl:attribute name="href"><xsl:value-of select="$issue-url-base"/><xsl:value-of select="@number"/></xsl:attribute>
            #<xsl:value-of select="@number"/>
        </a>
    </xsl:template>

    <!-- Format random HTML elements as is: -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <!-- Get or create a unique ID for a change node: -->
    <xsl:template name="change-id">
        <xsl:param name="node" select="."/>
        <xsl:choose>
            <xsl:when test="$node/@id"><xsl:value-of select="$node/@id"/></xsl:when>
            <xsl:when test="count($node/issue) = 1">
                <xsl:variable name="issue" select="$node/issue"/>
                <xsl:variable name="number" select="$issue/@number"/>
                <xsl:variable name="dupes" select="$node/../change/issue[@number = $number and generate-id() != generate-id($issue) and not(../@id)]"/>
                <xsl:variable name="genid">issue-<xsl:value-of select="$number"/></xsl:variable>
                <xsl:if test="$dupes">
                    <xsl:message terminate="yes">
                        "<xsl:value-of select="$genid"/>" cannot be used as the generated ID for change
                        "<xsl:value-of select="normalize-space($node/summary)"/>"
                        because it is not unique; shared also with
                        <xsl:for-each select="$dupes/../summary"><xsl:if test="position() &gt; 1"> and
                            </xsl:if>"<xsl:value-of select="normalize-space()"/>"</xsl:for-each>.
                        Please give an explicit "id" attribute for this change element.
                    </xsl:message>
                </xsl:if>
                <!-- XXX could also check that the generated ID does not clash with id attrs, but this is much less likely -->
                <xsl:value-of select="$genid"/>
            </xsl:when>
            <xsl:when test="$node/version">
                <xsl:variable name="version" select="$node/version"/>
                <xsl:variable name="dupes" select="//change/version[generate-id() != generate-id($version) and @major = $version/@major and @minor = $version/@minor and (@subminor = $version/@subminor or not(@subminor) and not($version/@subminor)) and (@subsubminor = $version/@subsubminor or not(@subsubminor) and not ($version/@subsubminor)) and not(../@id)]"/>
                <xsl:variable name="genid">version-<xsl:apply-templates select="$version" mode="print-version" /></xsl:variable>
                <xsl:if test="$dupes">
                    <xsl:message terminate="yes">
                        "<xsl:value-of select="$genid"/>" cannot be used as the generated ID for change
                        "<xsl:value-of select="normalize-space($node/summary)"/>"
                        because it is not unique; shared also with
                        <xsl:for-each select="$dupes/../summary"><xsl:if test="position() &gt; 1"> and
                            </xsl:if>"<xsl:value-of select="normalize-space()"/>"</xsl:for-each>.
                        Please give an explicit "id" attribute for this change element.
                    </xsl:message>
                </xsl:if>
                <xsl:value-of select="$genid"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="print-hash" >
                    <xsl:with-param name="text" select="translate($node/summary/text(),
                        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
                        '0503925827109823481784209824566547291478206519807439')" />
                    <xsl:with-param name="hash" select="'3'" />
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="print-hash" >
        <xsl:param name="text" />
        <xsl:param name="hash" />
        
        <xsl:variable name="first-char" select="substring($text,1,1)" />
        <xsl:choose>
            <xsl:when test="$text and number($first-char) >= 0">
                <xsl:call-template name="print-hash">
                    <xsl:with-param name="text" select="substring($text, 2)" />
                    <xsl:with-param name="hash" select="$hash * 2 + number($first-char)" />
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$text">
                <xsl:call-template name="print-hash">
                    <xsl:with-param name="text" select="substring($text, 2)" />
                    <xsl:with-param name="hash" select="$hash * 2" />
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$hash" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>