File: 02-fix-manpages.diff

package info (click to toggle)
tclxml 3.3~svn11-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,392 kB
  • sloc: ansic: 13,292; tcl: 11,656; xml: 3,269; sh: 559; makefile: 15
file content (997 lines) | stat: -rw-r--r-- 53,515 bytes parent folder | download | duplicates (2)
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
Description: Fix manpages generation
Author: Andrew O. Shadoura <bugzilla@tut.by>

--- a/doc/tcldom.xml.in
+++ b/doc/tcldom.xml.in
@@ -26,25 +26,10 @@
   </d:info>
   <refmeta>
     <refentrytitle>TclDOM</refentrytitle>
-    <manvolnum>n</manvolnum>
+    <manvolnum>3tcl</manvolnum>
   </refmeta>
   <refnamediv>
-    <refname>::dom::DOMImplementation</refname>
-    <refname>::dom::hasfeature</refname>
-    <refname>::dom::create</refname>
-    <refname>::dom::destroy</refname>
-    <refname>::dom::parse</refname>
-    <refname>::dom::serialize</refname>
-    <refname>::dom::document</refname>
-    <refname>::dom::documenttype</refname>
-    <refname>::dom::node</refname>
-    <refname>::dom::element</refname>
-    <refname>::dom::event</refname>
-    <refname>::dom::selectNode</refname>
-    <refname>::dom::isNode</refname>
-    <refname>::dom::xinclude</refname>
-    <refname>::dom::prefix2namespaceURI</refname>
-    <refname>::dom::trim</refname>
+    <refname>TclDOM</refname>
     <refpurpose>Tcl language binding for the W3C Document Object Model</refpurpose>
   </refnamediv>
   <refsynopsisdiv>
--- a/doc/tclxml.xml.in
+++ b/doc/tclxml.xml.in
@@ -44,7 +44,7 @@
   </d:info>
   <refmeta>
     <refentrytitle>TclXML</refentrytitle>
-    <manvolnum>n</manvolnum>
+    <manvolnum>3tcl</manvolnum>
   </refmeta>
   <refnamediv>
     <refname>TclXML</refname>
--- a/doc/tclxslt.xml.in
+++ b/doc/tclxslt.xml.in
@@ -1 +1 @@
-<!DOCTYPE refentry [
  <!ENTITY version "@PACKAGE_VERSION@">
]>
<refentry xmlns="http://docbook.org/ns/docbook"
	  xmlns:tcl='http://tclxml.sourceforge.net/doc'>
  <info>
    <author xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.explain.com.au/staff/Steve.Ball/">
      <firstname>Steve</firstname>
      <surname>Ball</surname>
    </author>
    <copyright>
      <year>2009</year>
      <year>2008</year>
      <year>2007</year>
      <year>2005</year>
      <holder xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.explain.com.au/">Explain</holder>
    </copyright>
    <copyright>
      <year>2004</year>
      <year>2003</year>
      <year>2002</year>
      <holder xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.zveno.com/">Zveno Pty Ltd</holder>
      <legalnotice>
        <para>See the file <filename>LICENSE</filename> for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.</para>
      </legalnotice>
    </copyright>
  </info>
  <refmeta>
    <refentrytitle>TclXSLT</refentrytitle>
    <manvolnum>n</manvolnum>
  </refmeta>
  <refnamediv>
    <refname>::xslt::compile</refname>
    <refname>::xslt::extension</refname>
    <refname>::xslt::security</refname>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">package require xslt</command>
    </cmdsynopsis>
    <pkgsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <package xmlns="http://docbook.org/ns/docbook">xslt</package>
      <version xmlns="http://docbook.org/ns/docbook">&version;</version>
    </pkgsynopsis>
    <namespacesynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <namespace>::xslt</namespace>
    </namespacesynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::compile</command>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>doc</replaceable>
      </arg>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">
        <replaceable>ssheet</replaceable>
      </command>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>method</replaceable>
      </arg>
      <group xmlns="http://docbook.org/ns/docbook" choice="opt" rep="repeat">
        <arg>option</arg>
        <arg>value</arg>
      </group>
      <group xmlns="http://docbook.org/ns/docbook" choice="opt" rep="repeat">
        <arg>args</arg>
      </group>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::extension</command>
      <methodname xmlns="http://docbook.org/ns/docbook">add</methodname>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>nsuri</replaceable>
      </arg>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>tcl-namespace</replaceable>
      </arg>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::security</command>
      <methodname xmlns="http://docbook.org/ns/docbook">
        <replaceable>request</replaceable>
      </methodname>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>detail</replaceable>
      </arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Description</d:title>
    </d:info>
    <para>TclXSLT is a wrapper for the <d:link xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc" xlink:href="http://xmlsoft.org/">Gnome libxslt library</d:link> that allows an application to perform XSL transformations (XSLT).  The package also provides a binding to the XSLT extension mechanism so that XSLT extension may be implemented using Tcl scripts.</para>
    <para>Transformation only works with documents created by TclDOM/libxml2.</para>
    <para>The TclXSLT package makes extensive use of Tcl objects.  Compiled XSL stylesheets are stored as the internal representation of a Tcl object.  Source and result documents are accessed via TclDOM's C interface as Tcl objects.  This allows the application to cache parsed XML documents and compiled XSL stylesheets for better runtime performance.</para>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Packages and Namespaces</d:title>
    </d:info>
    <para>The TclXSLT package defines the <tcl:package>xslt</tcl:package> package and also a Tcl namespace using that name.</para>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Commands</d:title>
    </d:info>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command> command compiles a stylesheet document.  It returns a compiled stylesheet object and also defines a Tcl command to access the stylesheet.  This Tcl command may be used to transform XML documents.</para>
      <example>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Example</d:title>
        </d:info>
        <programlisting>
set source_doc [::dom::libxml2::parse $XML]
set ssheet_doc [::dom::libxml2::parse $XSLstylesheet]
set ssheet [::xslt::compile $ssheet_doc]
set result [$ssheet transform $source_doc]
</programlisting>
      </example>
      <para>NB.  It is advisable to use the <option>-baseuri</option> option when parsing the source and stylesheet documents to allow external resources to be resolved.</para>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Stylesheet Command</d:title>
      </d:info>
      <para>The stylesheet command created by <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command> command accesses a compiled stylesheet.</para>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Command Methods</d:title>
        </d:info>
        <para>The following command methods may be used:</para>
        <variablelist>
          <varlistentry>
            <term>
              <arg>cget</arg>
              <arg>
                <replaceable>option</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Returns the value of an option.  See below for the list of valid options.</para>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>configure</arg>
              <arg>
                <replaceable>option</replaceable>
                <replaceable>value</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Sets the value of an option.  Available options are as follows:</para>
              <variablelist>
                <varlistentry>
                  <term>
                    <option>-indent</option>
                  </term>
                  <listitem>
                    <para>Specifies whether the output being produced by the stylesheet should be idented (or "pretty-printed").  This is usually set by the styesheet's <tag>xsl:output</tag> element.  The result is a boolean value.</para>
                    <para>This is a read-only option.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-messagecommand</option>
                    <arg>
                      <replaceable>script</replaceable>
                    </arg>
                  </term>
                  <listitem>
                    <para>This option specifies a Tcl command to be evaluated when a message is produced by the stylesheet.  Messages may be produced when the stylesheet detects an error during processing, or when the stylesheet uses the <tag>xsl:message</tag> element.</para>
                    <para>It is currently not possible to distinguish between an error message and a message produced using <tag>xsl:message</tag>.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-method</option>
                  </term>
                  <listitem>
                    <para>Specifies the output being produced by the stylesheet.  This is usually set by the styesheet's <tag>xsl:output</tag> element.  May have the value <literal>xml</literal>, <literal>html</literal>, <literal>xhtml</literal>, <literal>text</literal> or an empty string.</para>
                    <para>If the result is an empty string, then the output method used depends on the type of the result document.  If the result document is of type "HTML" (ie. if [dom::node cget $resultdoc -nodeType] returns <literal>HTMLdocument</literal>), then the <literal>html</literal> output method should be used.  Otherwise the output method to use is <literal>xml</literal>.</para>
                    <para>This is a read-only option.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-profilechannel</option>
                  </term>
                  <listitem>
                    <para>Specifies the name of a channel into which profiling information is written.  The channel must have been opened for writing, or an error will be returned when attempting a transformation.  Only file channels may be used and only on Unix systems.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-resulturi</option>
                  </term>
                  <listitem>
                    <para>Specifies the target URI for the transformation, ie. where the result will be written to.  The result document is <emphasis>not</emphasis> written to this URI automatically; the application should write the result document to this URI itself.</para>
                    <para>Some transformation constructs resolve relative URIs against this URI.  For example, a subsidiary result document produced using the <tag>document</tag> element.</para>
                  </listitem>
                </varlistentry>
              </variablelist>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>get</arg>
              <arg>
                <replaceable>what</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Returns information from the stylesheet.  The following values may be used for <arg><replaceable>what</replaceable></arg>:</para>
              <variablelist>
                <varlistentry>
                  <term>
                    <arg>parameters</arg>
                  </term>
                  <listitem>
                    <para>Returns a Tcl list describing the parameters that the stylesheet accepts.  Each member of the list is itself a Tcl list with three members: <literal>{name ns select}</literal>.  <literal>name</literal> is the name of the parameter, <literal>ns</literal> is the XML namespace for the parameter and <literal>select</literal> is the value of the <tag role='attribute'>select</tag> attribute of the <tag>param</tag> element, if any (ie. the default value of the parameter).  This implementation is not able to return a default value set using the content of the <tag>param</tag> element.</para>
                    <para>All stylesheet parameters are returned by this method, including those in included/imported stylesheets.  Where more than one parameter is defined with the same name, only the parameter with the highest import precedence is included in the returned list.</para>
                  </listitem>
                </varlistentry>
              </variablelist>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>transform</arg>
              <arg>
                <replaceable>source</replaceable>
              </arg>
              <group opt="repeat">
                <arg>
                  <replaceable>name</replaceable>
                </arg>
                <arg>
                  <replaceable>value</replaceable>
                </arg>
              </group>
            </term>
            <listitem>
              <para>Performs an XSL transformation on the given source document.  Stylesheet parameters may be specified as name-value pairs.  The return result is the DOM token for the result document.</para>
            </listitem>
          </varlistentry>
        </variablelist>
      </refsect3>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Stylesheet Parameters</d:title>
        </d:info>
        <para>Any number of name-value pairs may be specified as arguments to the <command xmlns="http://tclxml.sourceforge.net/doc"><replaceable xmlns="http://docbook.org/ns/docbook">stylesheet</replaceable> transform</command> method.  These are passed as values for parameters in the stylesheet.  <application>libxslt</application> interprets the values as XPath expressions, where the context node is the root node for the source document.  To pass a value as a string it must be XPath-quoted, for example</para>
        <informalexample>
          <programlisting>
set library "Gnome libxslt"
$ssheet transform $source_doc \
	library '$library' \
	author "'Daniel Veillard'" \
	node {/*/Element[3]}
</programlisting>
        </informalexample>
      </refsect3>
      <para>Following is an example of how to use the <command xmlns="http://tclxml.sourceforge.net/doc"><replaceable xmlns="http://docbook.org/ns/docbook">stylesheet</replaceable> transform</command> method.</para>
      <example>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Example</d:title>
        </d:info>
        <programlisting>
set source_doc [::dom::libxml2::parse $XML]
set ssheet_doc [::dom::libxml2::parse $XSLstylesheet]
set ssheet [::xslt::compile $ssheet_doc]
set result_doc [$ssheet transform $source_doc]
set result_xml [::dom::libxml2::serialize $result_doc \
    -method [$ssheet cget -method]]
</programlisting>
      </example>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension</command> command is used to manage extensions of the <application>libxslt</application> library.  The <methodname>add</methodname> is used to register an extension.  The <methodname>remove</methodname> is used to unregister an extension.  See <link>EXTENSIONS</link> for more detail.</para>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command is a "call-in" used to manage the security of a stylesheet performing a transformation.  The TclXSLT package does not create this command.  A stylesheet may need to perform an operation on an external resource, such as reading or writing a file, or opening a network connection.  Before performing such an operation, TclXSLT will invoke the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command.  It interprets the result of the command as a boolean value, and only if the "true" value is returned will it instruct the <application>libxslt</application> library to continue.</para>
      <para>TclXSLT will invoke the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command in a different fashion depending on whether the current interpreter is safe or unsafe.</para>
      <itemizedlist>
        <listitem>
          <para>If the current interpeter is unsafe (ie. it is a trusted interpreter) then the command is invoked in the usual manner (see below for arguments).  If the command does not exist then the value "true" is the default, ie. the operation will be permitted.</para>
        </listitem>
        <listitem>
          <para>If the current interpreter is safe then the command is invoked as a hidden command.  This is to ensure that the untrusted script cannot intercept the invocation of the command.  If the hidden command does not exist then the value "false" is the default, ie. the operation will not be permitted.</para>
        </listitem>
      </itemizedlist>
      <para>When the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command is invoked two arguments are appended:</para>
      <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
        <command xmlns="http://docbook.org/ns/docbook">::xslt::security</command>
        <methodname xmlns="http://docbook.org/ns/docbook">
          <replaceable>request</replaceable>
        </methodname>
        <arg xmlns="http://docbook.org/ns/docbook">
          <replaceable>detail</replaceable>
        </arg>
      </cmdsynopsis>
      <variablelist>
        <varlistentry>
          <term>
            <methodname>
              <replaceable>request</replaceable>
            </methodname>
          </term>
          <listitem>
            <para>This indicates the operation being requested and may have one of the following values:</para>
            <itemizedlist>
              <listitem>
                <para>
                  <literal>readfile</literal>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
            </itemizedlist>
          </listitem>
        </varlistentry>
      </variablelist>
    </refsect2>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Extensions</d:title>
    </d:info>
    <para>The TclXSLT package allows an application to bind Tcl scripts to the extension mechanism of <application>libxslt</application>.  This means that Tcl scripts may provide the implementation of an XSLT extension element or function.  The binding is achieved to associating a Tcl namespace with an XML namespace.</para>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Implementing An Extension</d:title>
      </d:info>
      <para>The Tcl application uses the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension add</command> command to register an extension.  An XML Namespace for the extension is specified as an argument, along with a Tcl namespace that will provide implementations of extension elements and functions.  For example,</para>
      <informalexample>
        <programlisting>
::xslt::extension add http://tclxml.sourceforge.net/Example ::example
</programlisting>
      </informalexample>
      <para>Everytime the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::transform</command> command is executed, a newly-created XSLT engine is initialized.  For each registered extension, every procedure in the associated Tcl namespace is defined in the XSLT engine as either an extension element or an extension function.  The procedure is defined as an extension function if it has a variable argument list, otherwise it is defined as an extension element.  The procedure name is used as the local part of the extension name.  For example,</para>
      <informalexample>
        <programlisting>
namespace eval example {
    namespace export myfunc myelement
}

proc example::myfunc {name args} {
    global app
    return $app($name)
}
proc example::myelement {content node inst avts} {
    global app

    puts $app([dom::libxml2::node cget $node -nodeName])

    return {}
}
</programlisting>
      </informalexample>
      <para>"myfunc" is defined as an extension function and "myelement" is defined as an extension element.</para>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Extension Functions</d:title>
        </d:info>
        <para>The arguments to an extension function are passed as parameters to the Tcl procedure. Each argument may be passed as a string or as a nodeset. Nodesets are presented as TclDOM nodes.</para>
        <para>The return result of the Tcl procedure becomes the return value of the extension function.  The type of the result is preserved where possible, otherwise it is converted to a string value.</para>
      </refsect3>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Extension Elements</d:title>
        </d:info>
        <para>When an extension element associated with a registered namespace is instantiated all attributes of the extension element are evaluated as Attribute Value Templates and the content of the extension element is evaluated as a sequence constructor. The Tcl procedure associated with the extension element is then invoked. The Tcl procedure is passed four parameters:</para>
	<itemizedlist>
	  <listitem>
	    <para>The first parameter is a DOM document, an RVT, that is the result of the sequence constructor.</para>
	  </listitem>
	  <listitem>
	    <para>The second parameter is the current node in the source document.</para>
	  </listitem>
	  <listitem>
	    <para>The third parameter is the extension element in the stylesheet document.</para>
	  </listitem>
	  <listitem>
	    <para>The fourth parameter is a list. Each element in the list represents an attribute of the extension element. The list elements are each a sublist that has three values:</para>
	    <itemizedlist>
	      <listitem>
		<para>Attribute name</para>
	      </listitem>
	      <listitem>
		<para>Attribute XML namespace</para>
	      </listitem>
	      <listitem>
		<para>Attribute value after evaluation as an AVT</para>
	      </listitem>
	    </itemizedlist>
	  </listitem>
	</itemizedlist>
	<para>Any result returned by the Tcl procedure is discarded (in the current implementation).</para>
	<para>If the Tcl procedure raises an error then this is passed through to the XSL stylesheet as an XSLT exception condition.</para>
      </refsect3>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Using An Extension</d:title>
      </d:info>
      <para>To invoke an extension in an XSL stylesheet, use the normal XSLT extension mechanism.  The XML Namespace matches the extension to the registered Tcl namespace (NB. the stylesheet author is free to choose any prefix for the extension namespace).  For example,</para>
      <informalexample>
        <programlisting>
&lt;xsl:stylesheet version='1.0'
	xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
	xmlns:eg='http://tclxml.sourceforge.net/Example'&gt;

  &lt;xsl:template match='/'&gt;
    &lt;xsl:text&gt;Result of calling extension is "&lt;/xsl:text&gt;
    &lt;xsl:value-of select='eg:myfunc("foo")'/&gt;
    &lt;xsl:text&gt;".
&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</programlisting>
      </informalexample>
      <para>This stylesheet would result in the following Tcl script being evaluated:</para>
      <informalexample>
        <programlisting>
::example::myfunc foo
</programlisting>
      </informalexample>
    </refsect2>
  </refsect1>
</refentry>
\ No newline at end of file
+<!DOCTYPE refentry [
  <!ENTITY version "@PACKAGE_VERSION@">
]>
<refentry xmlns="http://docbook.org/ns/docbook"
	  xmlns:tcl='http://tclxml.sourceforge.net/doc'>
  <info>
    <author xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.explain.com.au/staff/Steve.Ball/">
      <firstname>Steve</firstname>
      <surname>Ball</surname>
    </author>
    <copyright>
      <year>2009</year>
      <year>2008</year>
      <year>2007</year>
      <year>2005</year>
      <holder xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.explain.com.au/">Explain</holder>
    </copyright>
    <copyright>
      <year>2004</year>
      <year>2003</year>
      <year>2002</year>
      <holder xmlns:xlink="http://www.w3.org/XLink" xlink:href="http://www.zveno.com/">Zveno Pty Ltd</holder>
      <legalnotice>
        <para>See the file <filename>LICENSE</filename> for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.</para>
      </legalnotice>
    </copyright>
  </info>
  <refmeta>
    <refentrytitle>TclXSLT</refentrytitle>
    <manvolnum>3tcl</manvolnum>
  </refmeta>
  <refnamediv>
    <refname>TclXSLT</refname>
    <refpurpose>XSLT support for Tcl</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">package require xslt</command>
    </cmdsynopsis>
    <pkgsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <package xmlns="http://docbook.org/ns/docbook">xslt</package>
      <version xmlns="http://docbook.org/ns/docbook">&version;</version>
    </pkgsynopsis>
    <namespacesynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <namespace>::xslt</namespace>
    </namespacesynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::compile</command>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>doc</replaceable>
      </arg>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">
        <replaceable>ssheet</replaceable>
      </command>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>method</replaceable>
      </arg>
      <group xmlns="http://docbook.org/ns/docbook" choice="opt" rep="repeat">
        <arg>option</arg>
        <arg>value</arg>
      </group>
      <group xmlns="http://docbook.org/ns/docbook" choice="opt" rep="repeat">
        <arg>args</arg>
      </group>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::extension</command>
      <methodname xmlns="http://docbook.org/ns/docbook">add</methodname>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>nsuri</replaceable>
      </arg>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>tcl-namespace</replaceable>
      </arg>
    </cmdsynopsis>
    <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
      <command xmlns="http://docbook.org/ns/docbook">::xslt::security</command>
      <methodname xmlns="http://docbook.org/ns/docbook">
        <replaceable>request</replaceable>
      </methodname>
      <arg xmlns="http://docbook.org/ns/docbook">
        <replaceable>detail</replaceable>
      </arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Description</d:title>
    </d:info>
    <para>TclXSLT is a wrapper for the <d:link xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc" xlink:href="http://xmlsoft.org/">Gnome libxslt library</d:link> that allows an application to perform XSL transformations (XSLT).  The package also provides a binding to the XSLT extension mechanism so that XSLT extension may be implemented using Tcl scripts.</para>
    <para>Transformation only works with documents created by TclDOM/libxml2.</para>
    <para>The TclXSLT package makes extensive use of Tcl objects.  Compiled XSL stylesheets are stored as the internal representation of a Tcl object.  Source and result documents are accessed via TclDOM's C interface as Tcl objects.  This allows the application to cache parsed XML documents and compiled XSL stylesheets for better runtime performance.</para>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Packages and Namespaces</d:title>
    </d:info>
    <para>The TclXSLT package defines the <tcl:package>xslt</tcl:package> package and also a Tcl namespace using that name.</para>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Commands</d:title>
    </d:info>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command> command compiles a stylesheet document.  It returns a compiled stylesheet object and also defines a Tcl command to access the stylesheet.  This Tcl command may be used to transform XML documents.</para>
      <example>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Example</d:title>
        </d:info>
        <programlisting>
set source_doc [::dom::libxml2::parse $XML]
set ssheet_doc [::dom::libxml2::parse $XSLstylesheet]
set ssheet [::xslt::compile $ssheet_doc]
set result [$ssheet transform $source_doc]
</programlisting>
      </example>
      <para>NB.  It is advisable to use the <option>-baseuri</option> option when parsing the source and stylesheet documents to allow external resources to be resolved.</para>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Stylesheet Command</d:title>
      </d:info>
      <para>The stylesheet command created by <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::compile</command> command accesses a compiled stylesheet.</para>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Command Methods</d:title>
        </d:info>
        <para>The following command methods may be used:</para>
        <variablelist>
          <varlistentry>
            <term>
              <arg>cget</arg>
              <arg>
                <replaceable>option</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Returns the value of an option.  See below for the list of valid options.</para>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>configure</arg>
              <arg>
                <replaceable>option</replaceable>
                <replaceable>value</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Sets the value of an option.  Available options are as follows:</para>
              <variablelist>
                <varlistentry>
                  <term>
                    <option>-indent</option>
                  </term>
                  <listitem>
                    <para>Specifies whether the output being produced by the stylesheet should be idented (or "pretty-printed").  This is usually set by the styesheet's <tag>xsl:output</tag> element.  The result is a boolean value.</para>
                    <para>This is a read-only option.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-messagecommand</option>
                    <arg>
                      <replaceable>script</replaceable>
                    </arg>
                  </term>
                  <listitem>
                    <para>This option specifies a Tcl command to be evaluated when a message is produced by the stylesheet.  Messages may be produced when the stylesheet detects an error during processing, or when the stylesheet uses the <tag>xsl:message</tag> element.</para>
                    <para>It is currently not possible to distinguish between an error message and a message produced using <tag>xsl:message</tag>.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-method</option>
                  </term>
                  <listitem>
                    <para>Specifies the output being produced by the stylesheet.  This is usually set by the styesheet's <tag>xsl:output</tag> element.  May have the value <literal>xml</literal>, <literal>html</literal>, <literal>xhtml</literal>, <literal>text</literal> or an empty string.</para>
                    <para>If the result is an empty string, then the output method used depends on the type of the result document.  If the result document is of type "HTML" (ie. if [dom::node cget $resultdoc -nodeType] returns <literal>HTMLdocument</literal>), then the <literal>html</literal> output method should be used.  Otherwise the output method to use is <literal>xml</literal>.</para>
                    <para>This is a read-only option.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-profilechannel</option>
                  </term>
                  <listitem>
                    <para>Specifies the name of a channel into which profiling information is written.  The channel must have been opened for writing, or an error will be returned when attempting a transformation.  Only file channels may be used and only on Unix systems.</para>
                  </listitem>
                </varlistentry>
                <varlistentry>
                  <term>
                    <option>-resulturi</option>
                  </term>
                  <listitem>
                    <para>Specifies the target URI for the transformation, ie. where the result will be written to.  The result document is <emphasis>not</emphasis> written to this URI automatically; the application should write the result document to this URI itself.</para>
                    <para>Some transformation constructs resolve relative URIs against this URI.  For example, a subsidiary result document produced using the <tag>document</tag> element.</para>
                  </listitem>
                </varlistentry>
              </variablelist>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>get</arg>
              <arg>
                <replaceable>what</replaceable>
              </arg>
            </term>
            <listitem>
              <para>Returns information from the stylesheet.  The following values may be used for <arg><replaceable>what</replaceable></arg>:</para>
              <variablelist>
                <varlistentry>
                  <term>
                    <arg>parameters</arg>
                  </term>
                  <listitem>
                    <para>Returns a Tcl list describing the parameters that the stylesheet accepts.  Each member of the list is itself a Tcl list with three members: <literal>{name ns select}</literal>.  <literal>name</literal> is the name of the parameter, <literal>ns</literal> is the XML namespace for the parameter and <literal>select</literal> is the value of the <tag role='attribute'>select</tag> attribute of the <tag>param</tag> element, if any (ie. the default value of the parameter).  This implementation is not able to return a default value set using the content of the <tag>param</tag> element.</para>
                    <para>All stylesheet parameters are returned by this method, including those in included/imported stylesheets.  Where more than one parameter is defined with the same name, only the parameter with the highest import precedence is included in the returned list.</para>
                  </listitem>
                </varlistentry>
              </variablelist>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>
              <arg>transform</arg>
              <arg>
                <replaceable>source</replaceable>
              </arg>
              <group opt="repeat">
                <arg>
                  <replaceable>name</replaceable>
                </arg>
                <arg>
                  <replaceable>value</replaceable>
                </arg>
              </group>
            </term>
            <listitem>
              <para>Performs an XSL transformation on the given source document.  Stylesheet parameters may be specified as name-value pairs.  The return result is the DOM token for the result document.</para>
            </listitem>
          </varlistentry>
        </variablelist>
      </refsect3>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Stylesheet Parameters</d:title>
        </d:info>
        <para>Any number of name-value pairs may be specified as arguments to the <command xmlns="http://tclxml.sourceforge.net/doc"><replaceable xmlns="http://docbook.org/ns/docbook">stylesheet</replaceable> transform</command> method.  These are passed as values for parameters in the stylesheet.  <application>libxslt</application> interprets the values as XPath expressions, where the context node is the root node for the source document.  To pass a value as a string it must be XPath-quoted, for example</para>
        <informalexample>
          <programlisting>
set library "Gnome libxslt"
$ssheet transform $source_doc \
	library '$library' \
	author "'Daniel Veillard'" \
	node {/*/Element[3]}
</programlisting>
        </informalexample>
      </refsect3>
      <para>Following is an example of how to use the <command xmlns="http://tclxml.sourceforge.net/doc"><replaceable xmlns="http://docbook.org/ns/docbook">stylesheet</replaceable> transform</command> method.</para>
      <example>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Example</d:title>
        </d:info>
        <programlisting>
set source_doc [::dom::libxml2::parse $XML]
set ssheet_doc [::dom::libxml2::parse $XSLstylesheet]
set ssheet [::xslt::compile $ssheet_doc]
set result_doc [$ssheet transform $source_doc]
set result_xml [::dom::libxml2::serialize $result_doc \
    -method [$ssheet cget -method]]
</programlisting>
      </example>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension</command> command is used to manage extensions of the <application>libxslt</application> library.  The <methodname>add</methodname> is used to register an extension.  The <methodname>remove</methodname> is used to unregister an extension.  See <link>EXTENSIONS</link> for more detail.</para>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>
          <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command>
        </d:title>
      </d:info>
      <para>The <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command is a "call-in" used to manage the security of a stylesheet performing a transformation.  The TclXSLT package does not create this command.  A stylesheet may need to perform an operation on an external resource, such as reading or writing a file, or opening a network connection.  Before performing such an operation, TclXSLT will invoke the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command.  It interprets the result of the command as a boolean value, and only if the "true" value is returned will it instruct the <application>libxslt</application> library to continue.</para>
      <para>TclXSLT will invoke the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command in a different fashion depending on whether the current interpreter is safe or unsafe.</para>
      <itemizedlist>
        <listitem>
          <para>If the current interpeter is unsafe (ie. it is a trusted interpreter) then the command is invoked in the usual manner (see below for arguments).  If the command does not exist then the value "true" is the default, ie. the operation will be permitted.</para>
        </listitem>
        <listitem>
          <para>If the current interpreter is safe then the command is invoked as a hidden command.  This is to ensure that the untrusted script cannot intercept the invocation of the command.  If the hidden command does not exist then the value "false" is the default, ie. the operation will not be permitted.</para>
        </listitem>
      </itemizedlist>
      <para>When the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::security</command> command is invoked two arguments are appended:</para>
      <cmdsynopsis xmlns="http://tclxml.sourceforge.net/doc">
        <command xmlns="http://docbook.org/ns/docbook">::xslt::security</command>
        <methodname xmlns="http://docbook.org/ns/docbook">
          <replaceable>request</replaceable>
        </methodname>
        <arg xmlns="http://docbook.org/ns/docbook">
          <replaceable>detail</replaceable>
        </arg>
      </cmdsynopsis>
      <variablelist>
        <varlistentry>
          <term>
            <methodname>
              <replaceable>request</replaceable>
            </methodname>
          </term>
          <listitem>
            <para>This indicates the operation being requested and may have one of the following values:</para>
            <itemizedlist>
              <listitem>
                <para>
                  <literal>readfile</literal>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
              <listitem>
                <para>
                  <literal/>
                </para>
              </listitem>
            </itemizedlist>
          </listitem>
        </varlistentry>
      </variablelist>
    </refsect2>
  </refsect1>
  <refsect1>
    <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
      <d:title>Extensions</d:title>
    </d:info>
    <para>The TclXSLT package allows an application to bind Tcl scripts to the extension mechanism of <application>libxslt</application>.  This means that Tcl scripts may provide the implementation of an XSLT extension element or function.  The binding is achieved to associating a Tcl namespace with an XML namespace.</para>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Implementing An Extension</d:title>
      </d:info>
      <para>The Tcl application uses the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::extension add</command> command to register an extension.  An XML Namespace for the extension is specified as an argument, along with a Tcl namespace that will provide implementations of extension elements and functions.  For example,</para>
      <informalexample>
        <programlisting>
::xslt::extension add http://tclxml.sourceforge.net/Example ::example
</programlisting>
      </informalexample>
      <para>Everytime the <command xmlns="http://tclxml.sourceforge.net/doc">::xslt::transform</command> command is executed, a newly-created XSLT engine is initialized.  For each registered extension, every procedure in the associated Tcl namespace is defined in the XSLT engine as either an extension element or an extension function.  The procedure is defined as an extension function if it has a variable argument list, otherwise it is defined as an extension element.  The procedure name is used as the local part of the extension name.  For example,</para>
      <informalexample>
        <programlisting>
namespace eval example {
    namespace export myfunc myelement
}

proc example::myfunc {name args} {
    global app
    return $app($name)
}
proc example::myelement {content node inst avts} {
    global app

    puts $app([dom::libxml2::node cget $node -nodeName])

    return {}
}
</programlisting>
      </informalexample>
      <para>"myfunc" is defined as an extension function and "myelement" is defined as an extension element.</para>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Extension Functions</d:title>
        </d:info>
        <para>The arguments to an extension function are passed as parameters to the Tcl procedure. Each argument may be passed as a string or as a nodeset. Nodesets are presented as TclDOM nodes.</para>
        <para>The return result of the Tcl procedure becomes the return value of the extension function.  The type of the result is preserved where possible, otherwise it is converted to a string value.</para>
      </refsect3>
      <refsect3>
        <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
          <d:title>Extension Elements</d:title>
        </d:info>
        <para>When an extension element associated with a registered namespace is instantiated all attributes of the extension element are evaluated as Attribute Value Templates and the content of the extension element is evaluated as a sequence constructor. The Tcl procedure associated with the extension element is then invoked. The Tcl procedure is passed four parameters:</para>
	<itemizedlist>
	  <listitem>
	    <para>The first parameter is a DOM document, an RVT, that is the result of the sequence constructor.</para>
	  </listitem>
	  <listitem>
	    <para>The second parameter is the current node in the source document.</para>
	  </listitem>
	  <listitem>
	    <para>The third parameter is the extension element in the stylesheet document.</para>
	  </listitem>
	  <listitem>
	    <para>The fourth parameter is a list. Each element in the list represents an attribute of the extension element. The list elements are each a sublist that has three values:</para>
	    <itemizedlist>
	      <listitem>
		<para>Attribute name</para>
	      </listitem>
	      <listitem>
		<para>Attribute XML namespace</para>
	      </listitem>
	      <listitem>
		<para>Attribute value after evaluation as an AVT</para>
	      </listitem>
	    </itemizedlist>
	  </listitem>
	</itemizedlist>
	<para>Any result returned by the Tcl procedure is discarded (in the current implementation).</para>
	<para>If the Tcl procedure raises an error then this is passed through to the XSL stylesheet as an XSLT exception condition.</para>
      </refsect3>
    </refsect2>
    <refsect2>
      <d:info xmlns:d="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcl="http://tclxml.sourceforge.net/doc">
        <d:title>Using An Extension</d:title>
      </d:info>
      <para>To invoke an extension in an XSL stylesheet, use the normal XSLT extension mechanism.  The XML Namespace matches the extension to the registered Tcl namespace (NB. the stylesheet author is free to choose any prefix for the extension namespace).  For example,</para>
      <informalexample>
        <programlisting>
&lt;xsl:stylesheet version='1.0'
	xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
	xmlns:eg='http://tclxml.sourceforge.net/Example'&gt;

  &lt;xsl:template match='/'&gt;
    &lt;xsl:text&gt;Result of calling extension is "&lt;/xsl:text&gt;
    &lt;xsl:value-of select='eg:myfunc("foo")'/&gt;
    &lt;xsl:text&gt;".
&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</programlisting>
      </informalexample>
      <para>This stylesheet would result in the following Tcl script being evaluated:</para>
      <informalexample>
        <programlisting>
::example::myfunc foo
</programlisting>
      </informalexample>
    </refsect2>
  </refsect1>
</refentry>
--- a/doc/nroff.xsl
+++ b/doc/nroff.xsl
@@ -88,8 +88,7 @@
   </xsl:template>
 
   <xsl:template match="d:refnamediv">
-    <xsl:text>.BS
-'\" Note:  do not modify the .SH NAME line immediately below!
+    <xsl:text>'\" Note:  do not modify the .SH NAME line immediately below!
 .SH NAME
 </xsl:text>
     <xsl:for-each select="d:refname">
@@ -99,7 +98,6 @@
     <xsl:text>\- </xsl:text>
     <xsl:value-of select="d:refpurpose"/>
     <xsl:text>
-.BE
 
 </xsl:text>
   </xsl:template>