Source

SCons / src / engine / SCons / Tool / docbook / docbook-xsl-1.76.1 / common / refentry.xsl

Full commit
   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
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
                xmlns:date="http://exslt.org/dates-and-times"
                exclude-result-prefixes="doc date"
                version='1.0'>

<!-- ********************************************************************
     $Id: refentry.xsl 7867 2008-03-07 09:54:25Z xmldoc $
     ********************************************************************

     This file is part of the XSL DocBook Stylesheet distribution.
     See ../README or http://docbook.sf.net/release/xsl/current/ for
     copyright and other information.

     ******************************************************************** -->

<!-- ==================================================================== -->
<doc:reference xmlns="" xml:id="refentry">
  <info>
    <title>Common » Refentry Metadata Template Reference</title>
    <releaseinfo role="meta">
      $Id: refentry.xsl 7867 2008-03-07 09:54:25Z xmldoc $
    </releaseinfo>
  </info>
  <!-- * yes, partintro is a valid child of a reference... -->
  <partintro xml:id="partintro">
    <title>Introduction</title>
    <para>This is technical reference documentation for the “refentry
    metadata” templates in the DocBook XSL Stylesheets.</para>
    <para>This is not intended to be user documentation. It is provided
    for developers writing customization layers for the stylesheets.</para>
    <note>
      <para>Currently, only the manpages stylesheets make use of these
      templates. They are, however, potentially useful elsewhere.</para>
    </note>
  </partintro>
</doc:reference>

<!-- ==================================================================== -->
<doc:template name="get.refentry.metadata" xmlns="">
  <refpurpose>Gathers metadata from a refentry and its ancestors</refpurpose>
  <refdescription id="get.refentry.metadata-desc">
    <para>Reference documentation for particular commands, functions,
    etc., is sometimes viewed in isolation from its greater "context". For
    example, users view Unix man pages as, well, individual pages, not as
    part of a "book" of some kind. Therefore, it is sometimes necessary to
    embed "context" information in output for each <tag>refentry</tag>.</para>

    <para>However, one problem is that different users mark up that
    context information in different ways. Often (usually), the
    context information is not actually part of the content of the
    <tag>refentry</tag> itself, but instead part of the content of a
    parent or ancestor element to the <tag>refentry</tag>. And
    even then, DocBook provides a variety of elements that users might
    potentially use to mark up the same kind of information. One user
    might use the <tag>productnumber</tag> element to mark up version
    information about a particular product, while another might use
    the <tag>releaseinfo</tag> element.</para>

    <para>Taking all that in mind, the
    <function>get.refentry.metadata</function> template tries to gather
    metadata from a <tag>refentry</tag> element and its ancestor
    elements in an intelligent and user-configurable way. The basic
    mechanism used in the XPath expressions throughout this stylesheet
    is to select the relevant metadata from the *info element that is
    closest to the actual <tag>refentry</tag>&#160;– either on the
    <tag>refentry</tag> itself, or on its nearest ancestor.</para>

    <note>
      <para>The <function>get.refentry.metadata</function>
        template is actually just sort of a "driver" template; it
        calls other templates that do the actual data collection,
        then returns the data as a set.</para>
    </note>

  </refdescription>
  <refparameter id="get.refentry.metadata-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing user preferences (from global
          stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.metadata-returns">
    <para>Returns a node set with the following elements. The
    descriptions are verbatim from the <literal>man(7)</literal> man
    page.
    <variablelist>
      <varlistentry>
        <term>title</term>
        <listitem>
          <para>the title of the man page (e.g., <literal>MAN</literal>)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>section</term>
        <listitem>
          <para>the section number the man page should be placed in (e.g.,
          <literal>7</literal>)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>date</term>
        <listitem>
          <para>the date of the last revision</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>source</term>
        <listitem>
          <para>the source of the command</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>manual</term>
        <listitem>
          <para>the title of the manual (e.g., <citetitle>Linux
          Programmer's Manual</citetitle>)</para>
        </listitem>
      </varlistentry>
    </variablelist>
    </para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.metadata">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <title>
    <xsl:call-template name="get.refentry.title">
      <xsl:with-param name="refname" select="$refname"/>
    </xsl:call-template>
  </title>
  <section>
    <xsl:call-template name="get.refentry.section">
      <xsl:with-param name="refname" select="$refname"/>
    </xsl:call-template>
  </section>
  <date>
    <xsl:call-template name="get.refentry.date">
      <xsl:with-param name="info" select="$info"/>
      <xsl:with-param name="refname" select="$refname"/>
      <xsl:with-param name="prefs" select="$prefs/DatePrefs"/>
    </xsl:call-template>
  </date>
  <source>
    <xsl:call-template name="get.refentry.source">
      <xsl:with-param name="info" select="$info"/>
      <xsl:with-param name="refname" select="$refname"/>
      <xsl:with-param name="prefs" select="$prefs/SourcePrefs"/>
    </xsl:call-template>
  </source>
  <manual>
    <xsl:call-template name="get.refentry.manual">
      <xsl:with-param name="info" select="$info"/>
      <xsl:with-param name="refname" select="$refname"/>
      <xsl:with-param name="prefs" select="$prefs/ManualPrefs"/>
    </xsl:call-template>
  </manual>
</xsl:template>

<!-- ====================================================================== -->
<doc:template name="get.refentry.title" xmlns="">
  <refpurpose>Gets title metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.title-desc">
    <para>The <literal>man(7)</literal> man page describes this as "the
    title of the man page (e.g., <literal>MAN</literal>). This differs
    from <tag>refname</tag> in that, if the <tag>refentry</tag> has a
    <tag>refentrytitle</tag>, we use that as the <tag>title</tag>;
    otherwise, we just use first <tag>refname</tag> in the first
    <tag>refnamediv</tag> in the source.</para>
  </refdescription>
  <refparameter id="get.refentry.title-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.title-returns">
  <para>Returns a <tag>title</tag> node.</para></refreturn>
</doc:template>
<xsl:template name="get.refentry.title">
  <xsl:param name="refname"/>
  <xsl:choose>
    <xsl:when test="refmeta/refentrytitle">
      <xsl:copy>
        <xsl:apply-templates select="refmeta/refentrytitle/node()"/>
      </xsl:copy>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="$refname"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.section" xmlns="">
  <refpurpose>Gets section metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.section-desc">
    <para>The <literal>man(7)</literal> man page describes this as "the
    section number the man page should be placed in (e.g.,
    <literal>7</literal>)". If we do not find a <tag>manvolnum</tag>
    specified in the source, and we find that the <tag>refentry</tag> is
    for a function, we use the section number <literal>3</literal>
    ["Library calls (functions within program libraries)"]; otherwise, we
    default to using <literal>1</literal> ["Executable programs or shell
    commands"].</para>
  </refdescription>
  <refparameter id="get.refentry.section-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>quiet</term>
        <listitem>
          <para>If non-zero, no "missing" message is emitted</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.section-returns">
  <para>Returns a string representing a section number.</para></refreturn>
</doc:template>
<xsl:template name="get.refentry.section">
  <xsl:param name="refname"/>
  <xsl:param name="quiet" select="0"/>
  <xsl:choose>
    <xsl:when test="refmeta/manvolnum">
      <xsl:value-of select="refmeta/manvolnum"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:if test="$quiet = 0">
        <xsl:if test="$refentry.meta.get.quietly = 0">
          <xsl:call-template name="log.message">
            <xsl:with-param name="level">Note</xsl:with-param>
            <xsl:with-param name="source" select="$refname"/>
            <xsl:with-param name="context-desc">meta manvol</xsl:with-param>
            <xsl:with-param name="message">
              <xsl:text>no refentry/refmeta/manvolnum</xsl:text>
            </xsl:with-param>
          </xsl:call-template>
          <xsl:call-template name="log.message">
            <xsl:with-param name="level">Note</xsl:with-param>
            <xsl:with-param name="source" select="$refname"/>
            <xsl:with-param name="context-desc">meta manvol</xsl:with-param>
            <xsl:with-param name="message">
              <xsl:text>see http://docbook.sf.net/el/manvolnum</xsl:text>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:if>
      </xsl:if>
      <xsl:choose>
        <xsl:when test=".//funcsynopsis">
          <xsl:if test="$quiet = 0">
            <xsl:if test="$refentry.meta.get.quietly = 0">
              <xsl:call-template name="log.message">
                <xsl:with-param name="level">Note</xsl:with-param>
                <xsl:with-param name="source" select="$refname"/>
                <xsl:with-param name="context-desc">meta manvol</xsl:with-param>
                <xsl:with-param name="message">
                  <xsl:text>Setting man section to 3</xsl:text>
                </xsl:with-param>
              </xsl:call-template>
            </xsl:if>
          </xsl:if>
          <xsl:text>3</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>1</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.date" xmlns="">
  <refpurpose>Gets date metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.date-desc">
    <para>The <literal>man(7)</literal> man page describes this as "the
    date of the last revision". If we cannot find a date in the source, we
    generate one.</para>
  </refdescription>
  <refparameter id="get.refentry.date-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing users preferences (from global stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.date-returns">
    <para>Returns a <tag>date</tag> node.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.date">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <xsl:variable name="Date">
    <xsl:choose>
      <!-- * if profiling is enabled for date, and the date -->
      <!-- * profile is non-empty, use it -->
      <xsl:when test="not($prefs/@profileEnabled = 0) and
                      not($prefs/@profile = '')">
        <xsl:call-template name="evaluate.info.profile">
          <xsl:with-param name="profile" select="$prefs/@profile"/>
          <xsl:with-param name="info" select="$info"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- * either profiling is not enabled for date, or the-->
        <!-- * date profile is empty, so we need to look for date -->
        <!-- * in *info -->
        <xsl:choose>
          <!-- * look for date or pubdate in *info -->
          <xsl:when test="$info/date/node()
                          |$info/pubdate/node()">
            <xsl:apply-templates
                select="(($info[date])[last()]/date)[1]|
                        (($info[pubdate])[last()]/pubdate)[1]"/>
          </xsl:when>
          <xsl:otherwise>
            <!-- * found no Date or Pubdate -->
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="not($Date = '')">
      <xsl:value-of select="$Date"/>
    </xsl:when>
    <!-- * We couldn't find a date, so we generate a date. -->
    <!-- * And we make it an appropriately localized date. -->
    <xsl:otherwise>
      <!-- * The following block is commented out because: -->
      <!-- *  -->
      <!-- * - having a missing date in the source doesn’t result in -->
      <!-- *   any information being missing from the generated man -->
      <!-- *   page (since we generate the needed date) -->
      <!-- *  -->
      <!-- * - experience has shown the many users omit the date -->
      <!-- *   intentionally, because they want to be it generated -->
      <!-- *  -->
      <!-- * - in practice it’s not really a condition that most users -->
      <!-- *   want reported to them -->
      <!-- *  -->
      <!-- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      <!-- * <xsl:if test="$refentry.meta.get.quietly = 0"> -->
        <!-- * <xsl:call-template name="log.message"> -->
          <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
          <!-- * <xsl:with-param name="source" select="$refname"/> -->
          <!-- * <xsl:with-param name="context-desc">meta date</xsl:with-param> -->
          <!-- * <xsl:with-param name="message"> -->
            <!-- * <xsl:text>no date; using generated date</xsl:text> -->
          <!-- * </xsl:with-param> -->
        <!-- * </xsl:call-template> -->
        <!-- * <xsl:call-template name="log.message"> -->
          <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
          <!-- * <xsl:with-param name="source" select="$refname"/> -->
          <!-- * <xsl:with-param name="context-desc">meta date</xsl:with-param> -->
          <!-- * <xsl:with-param name="message"> -->
            <!-- * <xsl:text>see http://docbook.sf.net/el/date</xsl:text> -->
          <!-- * </xsl:with-param> -->
        <!-- * </xsl:call-template> -->
      <!-- * </xsl:if> -->
      <!-- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      <xsl:call-template name="datetime.format">
        <xsl:with-param name="date">
          <xsl:choose>
            <xsl:when test="function-available('date:date-time')">
              <xsl:value-of select="date:date-time()"/>
            </xsl:when>
            <xsl:when test="function-available('date:dateTime')">
              <!-- Xalan quirk -->
              <xsl:value-of select="date:dateTime()"/>
            </xsl:when>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="format">
          <xsl:call-template name="gentext.template">
            <xsl:with-param name="context" select="'datetime'"/>
            <xsl:with-param name="name" select="'format'"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.source" xmlns="">
  <refpurpose>Gets source metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.source-desc">
    <para>The <literal>man(7)</literal> man page describes this as "the
    source of the command", and provides the following examples:
    <itemizedlist>
      <listitem>
        <para>For binaries, use something like: GNU, NET-2, SLS
        Distribution, MCC Distribution.</para>
      </listitem>
      <listitem>
        <para>For system calls, use the version of the kernel that you are
        currently looking at: Linux 0.99.11.</para>
      </listitem>
      <listitem>
        <para>For library calls, use the source of the function: GNU, BSD
        4.3, Linux DLL 4.4.1.</para>
      </listitem>
    </itemizedlist>
    </para>

    <para>The <literal>solbook(5)</literal> man page describes
    something very much like what <literal>man(7)</literal> calls
    "source", except that <literal>solbook(5)</literal> names it
    "software" and describes it like this:
    <blockquote>
      <para>This is the name of the software product that the topic
      discussed on the reference page belongs to. For example UNIX
      commands are part of the <literal>SunOS x.x</literal>
      release.</para>
    </blockquote>
    </para>

    <para>In practice, there are many pages that simply have a version
    number in the "source" field. So, it looks like what we have is a
    two-part field,
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>,
    where:
    <variablelist>
      <varlistentry>
        <term>Name</term>
        <listitem>
          <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>Version</term>
        <listitem>
          <para>version name</para>
        </listitem>
      </varlistentry>
    </variablelist>
    Each part is optional. If the <replaceable>Name</replaceable> is a
    product name, then the <replaceable>Version</replaceable> is probably
    the version of the product. Or there may be no
    <replaceable>Name</replaceable>, in which case, if there is a
    <replaceable>Version</replaceable>, it is probably the version of the
    item itself, not the product it is part of. Or, if the
    <replaceable>Name</replaceable> is an organization name, then there
    probably will be no <replaceable>Version</replaceable>.
    </para>
  </refdescription>
  <refparameter id="get.refentry.source-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing users preferences (from global
          stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.source-returns">
    <para>Returns a <tag>source</tag> node.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.source">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <xsl:variable name="Name">
    <xsl:if test="$prefs/Name/@suppress = 0">
      <xsl:call-template name="get.refentry.source.name">
        <xsl:with-param name="info" select="$info"/>
        <xsl:with-param name="refname" select="$refname"/>
        <xsl:with-param name="prefs" select="$prefs/Name"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:variable>
  <xsl:variable name="Version">
    <xsl:if test="$prefs/Version/@suppress = 0">
      <xsl:call-template name="get.refentry.version">
        <xsl:with-param name="info" select="$info"/>
        <xsl:with-param name="refname" select="$refname"/>
        <xsl:with-param name="prefs" select="$prefs/Version"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:variable>
  <xsl:choose>
    <!-- * if we have a Name and/or Version, use either or both -->
    <!-- * of those, in the form "Name Version" or just "Name" -->
    <!-- * or just "Version" -->
    <xsl:when test="not($Name = '') or not($Version = '')">
      <xsl:choose>
        <xsl:when test="not($Name = '') and not($Version = '')">
          <xsl:copy-of select="$Name"/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="$Name"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:copy-of select="$Version"/>
    </xsl:when>
    <!-- * if no Name and no Version, use fallback (if any) -->
    <xsl:when test="not($prefs/@fallback = '')">
      <xsl:variable name="source.fallback">
        <xsl:call-template name="evaluate.info.profile">
          <xsl:with-param name="profile" select="$prefs/@fallback"/>
          <xsl:with-param name="info" select="$info"/>
        </xsl:call-template>
      </xsl:variable>
      <!-- * At this point, we know that we don't have properly marked-up -->
      <!-- * source metadata, so even if we do have source fallback -->
      <!-- * content, we still report to the user that it should be -->
      <!-- * marked up properly instead. -->
      <xsl:if test="$refentry.meta.get.quietly = 0">
        <xsl:call-template name="report.missing.source.name">
          <xsl:with-param name="refname" select="$refname"/>
        </xsl:call-template>
        <xsl:call-template name="report.missing.version">
          <xsl:with-param name="refname" select="$refname"/>
        </xsl:call-template>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="not($source.fallback = '')">
          <xsl:value-of select="$source.fallback"/>
          <xsl:if test="$refentry.meta.get.quietly = 0">
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Warn</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">meta source</xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>using</xsl:text>
                <xsl:text> "</xsl:text>
                <xsl:value-of select="$source.fallback"/>
                <xsl:text>" </xsl:text>
                <xsl:text>for "source"</xsl:text>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>
          <!-- * we have no Name, no Version, and no fallback content, so -->
          <!-- * insert a fixme -->
          <xsl:text>[FIXME: source]</xsl:text>
          <xsl:if test="$refentry.meta.get.quietly = 0">
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Warn</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">meta source</xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>no fallback for source, so inserted a fixme</xsl:text>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <!-- * we have no Name, no Version, and no fallback given, so -->
      <!-- * insert a fixme -->
      <xsl:text>[FIXME: source]</xsl:text>
      <xsl:if test="$refentry.meta.get.quietly = 0">
        <xsl:call-template name="log.message">
          <xsl:with-param name="level">Warn</xsl:with-param>
          <xsl:with-param name="source" select="$refname"/>
          <xsl:with-param name="context-desc">meta source</xsl:with-param>
          <xsl:with-param name="message">
            <xsl:text>no source fallback given, so inserted a fixme</xsl:text>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.source.name" xmlns="">
  <refpurpose>Gets source-name metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.source.name-desc">
    <para>A "source name" is one part of a (potentially) two-part
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
    source field. For more details, see the documentation for the
    <function>get.refentry.source</function> template.</para>
  </refdescription>
  <refparameter id="get.refentry.source.name-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing users preferences (from global
          stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.source.name-returns">
    <para>Depending on what output method is used for the
  current stylesheet, either returns a text node or possibly an element
  node, containing "source name" data.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.source.name">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <xsl:choose>
    <!-- * if profiling is enabled for source.name, and the -->
    <!-- * source.name profile is non-empty, use it -->
    <xsl:when test="not($prefs/@profileEnabled = 0) and
                    not($prefs/@profile = '')">
      <xsl:call-template name="evaluate.info.profile">
        <xsl:with-param name="profile" select="$prefs/@profile"/>
        <xsl:with-param name="info" select="$info"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <!-- * either profiling for source.name is not enabled, or-->
      <!-- * the source.name profile is empty; so we need to look -->
      <!-- * for a name to use -->
      <xsl:choose>
        <xsl:when test="refmeta/refmiscinfo[@class = 'source' or @class = 'software']">
          <xsl:apply-templates 
              select="refmeta/refmiscinfo[@class = 'source' or @class='software'][1]/node()"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="$info/productname">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[productname])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[productname])[last()]/productname)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info/corpname">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[corpname])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[corpname])[last()]/corpname)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
                <xsl:with-param name="preferred">productname</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info/corpcredit">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[corpcredit])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[corpcredit])[last()]/corpcredit)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
                <xsl:with-param name="preferred">productname</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info/corpauthor">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[corpauthor])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[corpauthor])[last()]/corpauthor)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
                <xsl:with-param name="preferred">productname</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info//orgname">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[//orgname])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[//orgname])[last()]//orgname)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
                <xsl:with-param name="preferred">productname</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info//publishername">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[//publishername])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[//publishername])[last()]//publishername)[1]"/>
                <xsl:with-param name="context">source</xsl:with-param>
                <xsl:with-param name="preferred">productname</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="report.missing.source.name">
  <xsl:param name="refname"/>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta source</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no *info/productname or alternative</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta source</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>see http://docbook.sf.net/el/productname</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta source</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no refentry/refmeta/refmiscinfo@class=source</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta source</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.version" xmlns="">
  <refpurpose>Gets version metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.version-desc">
    <para>A "version" is one part of a (potentially) two-part
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
    source field. For more details, see the documentation for the
    <function>get.refentry.source</function> template.</para>
  </refdescription>
  <refparameter id="get.refentry.version-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing users preferences (from global
          stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.version-returns">
    <para>Depending on what output method is used for the
  current stylesheet, either returns a text node or possibly an element
  node, containing "version" data.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.version">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <xsl:choose>
    <!-- * if profiling is enabled for version, and the -->
    <!-- * version profile is non-empty, use it -->
    <xsl:when test="not($prefs/@profileEnabled = 0) and
                    not($prefs/@profile = '')">
      <xsl:call-template name="evaluate.info.profile">
        <xsl:with-param name="profile" select="$prefs/@profile"/>
        <xsl:with-param name="info" select="$info"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <!-- * either profiling for source.name is not enabled, or-->
      <!-- * the source.name profile is empty; so we need to look -->
      <!-- * for a name to use -->
      <xsl:choose>
        <xsl:when test="refmeta/refmiscinfo[@class = 'version']">
          <xsl:apply-templates 
              select="refmeta/refmiscinfo[@class = 'version'][1]/node()"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="$info/productnumber">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[productnumber])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[productnumber])[last()]/productnumber)[1]"/>
                <xsl:with-param name="context">version</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info/edition">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[edition])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[edition])[last()]/edition)[1]"/>
                <xsl:with-param name="context">version</xsl:with-param>
                <xsl:with-param name="preferred">productnumber</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$info/releaseinfo">
              <xsl:call-template name="set.refentry.metadata">
                <xsl:with-param name="refname" select="$refname"/>
                <xsl:with-param
                    name="info"
                    select="($info[releaseinfo])[last()]"/>
                <xsl:with-param
                    name="contents"
                    select="(($info[releaseinfo])[last()]/releaseinfo)[1]"/>
                <xsl:with-param name="context">version</xsl:with-param>
                <xsl:with-param name="preferred">productnumber</xsl:with-param>
              </xsl:call-template>
            </xsl:when>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="report.missing.version">
  <xsl:param name="refname"/>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta version</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no *info/productnumber or alternative</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta version</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>see http://docbook.sf.net/el/productnumber</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta version</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no refentry/refmeta/refmiscinfo@class=version</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta version</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- ==================================================================== -->
<doc:template name="get.refentry.manual" xmlns="">
  <refpurpose>Gets source metadata for a refentry</refpurpose>
  <refdescription id="get.refentry.manual-desc">
    <para>The <literal>man(7)</literal> man page describes this as "the
    title of the manual (e.g., <citetitle>Linux Programmer's
    Manual</citetitle>)". Here are some examples from existing man pages:
    <itemizedlist>
      <listitem>
        <para><citetitle>dpkg utilities</citetitle>
        (<command>dpkg-name</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>User Contributed Perl Documentation</citetitle>
        (<command>GET</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>GNU Development Tools</citetitle>
        (<command>ld</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>Emperor Norton Utilities</citetitle>
        (<command>ddate</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>Debian GNU/Linux manual</citetitle>
        (<command>faked</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>GIMP Manual Pages</citetitle>
        (<command>gimp</command>)</para>
      </listitem>
      <listitem>
        <para><citetitle>KDOC Documentation System</citetitle>
        (<command>qt2kdoc</command>)</para>
      </listitem>
    </itemizedlist>
    </para>

    <para>The <literal>solbook(5)</literal> man page describes
    something very much like what <literal>man(7)</literal> calls
    "manual", except that <literal>solbook(5)</literal> names it
    "sectdesc" and describes it like this:
    <blockquote>
      <para>This is the section title of the reference page; for
      example <literal>User Commands</literal>.</para>
    </blockquote>
    </para>

  </refdescription>
  <refparameter id="get.refentry.manual-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A set of info nodes (from a <tag>refentry</tag>
          element and its ancestors)</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>prefs</term>
        <listitem>
          <para>A node containing users preferences (from global
          stylesheet parameters)</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="get.refentry.manual-returns">
    <para>Returns a <tag>manual</tag> node.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.manual">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="prefs"/>
  <xsl:variable name="Manual">
    <xsl:choose>
      <!-- * if profiling is enabled for manual, and the manual -->
      <!-- * profile is non-empty, use it -->
      <xsl:when test="not($prefs/@profileEnabled = 0) and
                      not($prefs/@profile = '')">
        <xsl:call-template name="evaluate.info.profile">
          <xsl:with-param name="profile" select="$prefs/@profile"/>
          <xsl:with-param name="info" select="$info"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc']">
            <xsl:apply-templates 
                select="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc'][1]/node()"/>
          </xsl:when>
          <xsl:otherwise>
            <!-- * only in the case of choosing appropriate -->
            <!-- * "manual" content do we select the furthest -->
            <!-- * (first) matching element instead of the -->
            <!-- * closest (last) matching one -->
            <xsl:choose>
              <xsl:when test="ancestor::*/title">
                <xsl:call-template name="set.refentry.metadata">
                  <xsl:with-param name="refname" select="$refname"/>
                  <xsl:with-param
                      name="info"
                      select="(ancestor::*[title])[1]"/>
                  <xsl:with-param
                      name="contents"
                      select="(ancestor::*[title])[1]/title"/>
                  <xsl:with-param name="context">manual</xsl:with-param>
                </xsl:call-template>
              </xsl:when>
              <xsl:when test="$info/title">
                <xsl:call-template name="set.refentry.metadata">
                  <xsl:with-param name="refname" select="$refname"/>
                  <xsl:with-param
                      name="info"
                      select="($info[title])[1]"/>
                  <xsl:with-param
                      name="contents"
                      select="(($info[title])[1]/title)[1]"/>
                  <xsl:with-param name="context">manual</xsl:with-param>
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="not($Manual = '')">
      <xsl:copy-of select="$Manual"/>
    </xsl:when>
    <!-- * if no Manual, use contents of specified fallback (if any) -->
    <xsl:when test="not($prefs/@fallback = '')">
      <xsl:variable name="manual.fallback">
        <xsl:call-template name="evaluate.info.profile">
          <xsl:with-param name="profile" select="$prefs/@fallback"/>
          <xsl:with-param name="info" select="$info"/>
        </xsl:call-template>
      </xsl:variable>
      <!-- * At this point, we know that we don't have properly marked-up -->
      <!-- * manual metadata, so even if we do have manual fallback -->
      <!-- * content, we still report to the user that it should be -->
      <!-- * marked up properly instead. -->
      <xsl:if test="$refentry.meta.get.quietly = 0">
        <xsl:call-template name="report.missing.manual">
          <xsl:with-param name="refname" select="$refname"/>
        </xsl:call-template>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="not($manual.fallback = '')">
          <xsl:value-of select="$manual.fallback"/>
          <xsl:if test="$refentry.meta.get.quietly = 0">
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Warn</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">meta manual</xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>using</xsl:text>
                <xsl:text> "</xsl:text>
                <xsl:value-of select="$manual.fallback"/>
                <xsl:text>" </xsl:text>
                <xsl:text>for "manual"</xsl:text>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>
          <!-- * we have nothing appropriate to use for manual, and no fallback -->
          <!-- * content, so report insert a fixme -->
          <xsl:text>[FIXME: manual]</xsl:text>
          <xsl:if test="$refentry.meta.get.quietly = 0">
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Warn</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">meta manual</xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>no fallback for manual, so inserted a fixme</xsl:text>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <!-- * we have nothing appropriate to use for manual, and no fallback -->
      <!-- * given, so insert a fixme -->
      <xsl:text>[FIXME: manual]</xsl:text>
      <xsl:if test="$refentry.meta.get.quietly = 0">
        <xsl:call-template name="log.message">
          <xsl:with-param name="level">Warn</xsl:with-param>
          <xsl:with-param name="source" select="$refname"/>
          <xsl:with-param name="context-desc">meta manual</xsl:with-param>
          <xsl:with-param name="message">
            <xsl:text>no manual fallback given, so inserted a fixme</xsl:text>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="report.missing.manual">
  <xsl:param name="refname"/>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta manual</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no titled ancestor of refentry</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta manual</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>no refentry/refmeta/refmiscinfo@class=manual</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="log.message">
    <xsl:with-param name="level">Note</xsl:with-param>
    <xsl:with-param name="source" select="$refname"/>
    <xsl:with-param name="context-desc">meta manual</xsl:with-param>
    <xsl:with-param name="message">
      <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<!-- ====================================================================== -->
<doc:template name="get.refentry.metadata.prefs" xmlns="">
  <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
  <refdescription id="get.refentry.metadata.prefs-desc">
    <para>The DocBook XSL stylesheets include several user-configurable
    global stylesheet parameters for controlling <tag>refentry</tag>
    metadata gathering. Those parameters are not read directly by the
    other <tag>refentry</tag> metadata-gathering
    templates. Instead, they are read only by the
    <function>get.refentry.metadata.prefs</function> template,
    which assembles them into a structure that is then passed to
    the other <tag>refentry</tag> metadata-gathering
    templates.</para>

    <para>So the, <function>get.refentry.metadata.prefs</function>
    template is the only interface to collecting stylesheet parameters for
    controlling <tag>refentry</tag> metadata gathering.</para>
  </refdescription>
  <refparameter id="get.refentry.metadata.prefs-params">
    <para>There are no local parameters for this template; however, it
    does rely on a number of global parameters.</para>
  </refparameter>
  <refreturn id="get.refentry.metadata.prefs-returns">
    <para>Returns a <tag>manual</tag> node.</para>
  </refreturn>
</doc:template>
<xsl:template name="get.refentry.metadata.prefs">
  <DatePrefs>
    <xsl:attribute name="profile">
      <xsl:value-of select="$refentry.date.profile"/>
    </xsl:attribute>
    <xsl:attribute name="profileEnabled">
      <xsl:value-of select="$refentry.date.profile.enabled"/>
    </xsl:attribute>
  </DatePrefs>
  <SourcePrefs>
    <xsl:attribute name="fallback">
      <xsl:value-of select="$refentry.source.fallback.profile"/>
    </xsl:attribute>
    <Name>
      <xsl:attribute name="profile">
        <xsl:value-of select="$refentry.source.name.profile"/>
      </xsl:attribute>
      <xsl:attribute name="profileEnabled">
        <xsl:value-of select="$refentry.source.name.profile.enabled"/>
      </xsl:attribute>
      <xsl:attribute name="suppress">
        <xsl:value-of select="$refentry.source.name.suppress"/>
      </xsl:attribute>
    </Name>
    <Version>
      <xsl:attribute name="profile">
        <xsl:value-of select="$refentry.version.profile"/>
      </xsl:attribute>
      <xsl:attribute name="profileEnabled">
        <xsl:value-of select="$refentry.version.profile.enabled"/>
      </xsl:attribute>
      <xsl:attribute name="suppress">
        <xsl:value-of select="$refentry.version.suppress"/>
      </xsl:attribute>
    </Version>
  </SourcePrefs>
  <ManualPrefs>
    <xsl:attribute name="fallback">
      <xsl:value-of select="$refentry.manual.fallback.profile"/>
    </xsl:attribute>
    <xsl:attribute name="profile">
      <xsl:value-of select="$refentry.manual.profile"/>
    </xsl:attribute>
    <xsl:attribute name="profileEnabled">
      <xsl:value-of select="$refentry.manual.profile.enabled"/>
    </xsl:attribute>
  </ManualPrefs>
</xsl:template>

<!-- ====================================================================== -->
<doc:template name="set.refentry.metadata" xmlns="">
  <refpurpose>Sets content of a refentry metadata item</refpurpose>
  <refdescription id="set.refentry.metadata-desc">
    <para>The <function>set.refentry.metadata</function> template is
    called each time a suitable source element is found for a certain
    metadata field.</para>
  </refdescription>
  <refparameter id="set.refentry.metadata-params">
    <variablelist>
      <varlistentry>
        <term>refname</term>
        <listitem>
          <para>The first <tag>refname</tag> in the refentry</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>info</term>
        <listitem>
          <para>A single *info node that contains the selected source element.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>contents</term>
        <listitem>
          <para>A node containing the selected source element.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>context</term>
        <listitem>
          <para>A string describing the metadata context in which the
          <function>set.refentry.metadata</function> template was
          called: either "date", "source", "version", or "manual".</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refreturn id="set.refentry.metadata-returns">
  <para>Returns formatted contents of a selected source element.</para></refreturn>
</doc:template>
<xsl:template name="set.refentry.metadata">
  <xsl:param name="refname"/>
  <xsl:param name="info"/>
  <xsl:param name="contents"/>
  <xsl:param name="context"/>
  <xsl:param name="preferred"/>
  <!-- * <xsl:if test="not($preferred = '')"> -->
    <!-- * <xsl:if test="$refentry.meta.get.quietly = 0"> -->
      <!-- * <xsl:call-template name="log.message"> -->
        <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
        <!-- * <xsl:with-param name="source" select="$refname"/> -->
        <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
        <!-- * <xsl:with-param name="message" select="concat('No ', $preferred)"/> -->
      <!-- * </xsl:call-template> -->
      <!-- * <xsl:call-template name="log.message"> -->
        <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
        <!-- * <xsl:with-param name="source" select="$refname"/> -->
        <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
        <!-- * <xsl:with-param name="message"> -->
          <!-- * <xsl:text>no refentry/refmeta/refmiscinfo@class=</xsl:text> -->
          <!-- * <xsl:value-of select="$context"/> -->
        <!-- * </xsl:with-param> -->
      <!-- * </xsl:call-template> -->
      <!-- * <xsl:call-template name="log.message"> -->
        <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
        <!-- * <xsl:with-param name="source" select="$refname"/> -->
        <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
        <!-- * <xsl:with-param name="message" select="concat('Using ', local-name($contents))"/> -->
      <!-- * </xsl:call-template> -->
    <!-- * </xsl:if> -->
  <!-- * </xsl:if> -->
  <xsl:value-of select="$contents"/>
</xsl:template>

</xsl:stylesheet>