Debian Codegraph @

examples/XSLT.html

raw
1 Content-Type: text/xml
2 Content-Length: 17259
3
4 <?xml version="1.0" encoding="UTF-8"?>
5 <html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="xslt.css" /><title>XML::XSLT - A perl module for processing XSLT
6 </title></head><body>
7
8
9
10 <h1>NAME</h1>XML::XSLT - A perl module for processing XSLT
11
12
13
14
15
16
17 <h1>SYNOPSIS
18 </h1>
19
20 <pre>
21 use XML::XSLT;
22
23 my $xslt = XML::XSLT-&gt;new ($xsl, warnings =&gt; 1);
24
25 $xslt-&gt;transform ($xmlfile);
26
27 print $xslt-&gt;toString;
28
29 $xslt-&gt;dispose();
30
31 </pre>
32
33
34
35
36
37 <h1>DESCRIPTION
38 </h1>
39
40 <p>
41 This module implements the W3C's XSLT specification. The goal is full
42 implementation of this spec, but we have not yet achieved
43 that. However, it already works well. See
44 XML::XSLT Commands
45 for
46 the current status of each command.
47
48 </p>
49
50 <p>
51 XML::XSLT makes use of XML::DOM and LWP::Simple, while XML::DOM
52 uses XML::Parser. Therefore XML::Parser, XML::DOM and LWP::Simple
53 have to be installed properly for XML::XSLT to run.
54
55 </p>
56
57
58
59
60
61 <h1>Specifying Sources
62 </h1>
63
64 <p>
65 The stylesheets and the documents may be passed as filenames, file
66 handles regular strings, string references or DOM-trees. Functions
67 that require sources (e.g. new), will accept either a named parameter
68 or simply the argument.
69
70 </p>
71
72 <p>
73 Either of the following are allowed:
74
75 </p>
76
77 <pre>
78 my $xslt = XML::XSLT-&gt;new($xsl);
79 my $xslt = XML::XSLT-&gt;new(Source =&gt; $xsl);
80
81 </pre>
82
83 <p>
84 In documentation, the named parameter `Source' is always shown, but it
85 is never required.
86
87 </p>
88
89
90
91 <h2>METHODS
92 </h2>
93
94 <ul>
95
96 <li>
97 <b>new(Source =&gt; $xml [, %args])
98 </b>
99
100 <p>
101 Returns a new XSLT parser object. Valid flags are:
102
103 </p>
104
105 </li>
106
107 <ul>
108
109 <li>
110 <b>DOMparser_args
111 </b>
112
113 <p>
114 Hashref of arguments to pass to the XML::DOM::Parser object's parse
115 method.
116
117 </p>
118
119 </li>
120
121 <li>
122 <b>variables
123 </b>
124
125 <p>
126 Hashref of variables and their values for the stylesheet.
127
128 </p>
129
130 </li>
131
132 <li>
133 <b>base
134 </b>
135
136 <p>
137 Base of URL for file inclusion.
138
139 </p>
140
141 </li>
142
143 <li>
144 <b>debug
145 </b>
146
147 <p>
148 Turn on debugging messages.
149
150 </p>
151
152 </li>
153
154 <li>
155 <b>warnings
156 </b>
157
158 <p>
159 Turn on warning messages.
160
161 </p>
162
163 </li>
164
165 <li>
166 <b>indent
167 </b>
168
169 <p>
170 Starting amount of indention for debug messages. Defaults to 0.
171
172 </p>
173
174 </li>
175
176 <li>
177 <b>indent_incr
178 </b>
179
180 <p>
181 Amount to indent each level of debug message. Defaults to 1.
182
183 </p>
184
185 </li>
186
187 </ul>
188
189 <li>
190 <b>open_xml(Source =&gt; $xml [, %args])
191 </b>
192
193 <p>
194 Gives the XSLT object new XML to process. Returns an XML::DOM object
195 corresponding to the XML.
196
197 </p>
198
199 </li>
200
201 <ul>
202
203 <li>
204 <b>base
205 </b>
206
207 <p>
208 The base URL to use for opening documents.
209
210 </p>
211
212 </li>
213
214 <li>
215 <b>parser_args
216 </b>
217
218 <p>
219 Arguments to pase to the parser.
220
221 </p>
222
223 </li>
224
225 </ul>
226
227 <li>
228 <b>open_xsl(Source =&gt; $xml, [, %args])
229 </b>
230
231 <p>
232 Gives the XSLT object a new stylesheet to use in processing XML.
233 Returns an XML::DOM object corresponding to the stylesheet. Any
234 arguments present are passed to the XML::DOM::Parser.
235
236 </p>
237
238 </li>
239
240 <ul>
241
242 <li>
243 <b>base
244 </b>
245
246 <p>
247 The base URL to use for opening documents.
248
249 </p>
250
251 </li>
252
253 <li>
254 <b>parser_args
255 </b>
256
257 <p>
258 Arguments to pase to the parser.
259
260 </p>
261
262 </li>
263
264 </ul>
265
266 <li>
267 <b>process(%variables)
268 </b>
269
270 <p>
271 Processes the previously loaded XML through the stylesheet using the
272 variables set in the argument.
273
274 </p>
275
276 </li>
277
278 <li>
279 <b>transform(Source =&gt; $xml [, %args])
280 </b>
281
282 <p>
283 Processes the given XML through the stylesheet. Returns an XML::DOM
284 object corresponding to the transformed XML. Any arguments present
285 are passed to the XML::DOM::Parser.
286
287 </p>
288
289 </li>
290
291 <li>
292 <b>serve(Source =&gt; $xml [, %args])
293 </b>
294
295 <p>
296 Processes the given XML through the stylesheet. Returns a string
297 containg the result. Example:
298
299 </p>
300
301 <pre>
302 use XML::XSLT qw(serve);
303
304 </pre>
305
306 <pre>
307 $xslt = XML::XSLT-&gt;new($xsl);
308 print $xslt-&gt;serve $xml;
309
310 </pre>
311
312 </li>
313
314 <ul>
315
316 <li>
317 <b>http_headers
318 </b>
319
320 <p>
321 If true, then prepends the appropriate HTTP headers (e.g. Content-Type,
322 Content-Length);
323
324 </p>
325
326 <p>
327 Defaults to true.
328
329 </p>
330
331 </li>
332
333 <li>
334 <b>xml_declaration
335 </b>
336
337 <p>
338 If true, then the result contains the appropriate &lt;?xml?&gt; header.
339
340 </p>
341
342 <p>
343 Defaults to true.
344
345 </p>
346
347 </li>
348
349 <li>
350 <b>xml_version
351 </b>
352
353 <p>
354 The version of the XML.
355
356 </p>
357
358 <p>
359 Defaults to 1.0.
360
361 </p>
362
363 </li>
364
365 <li>
366 <b>doctype
367 </b>
368
369 <p>
370 The type of DOCTYPE this document is. Defaults to SYSTEM.
371
372 </p>
373
374 </li>
375
376 </ul>
377
378 <li>
379 <b>toString
380 </b>
381
382 <p>
383 Returns the result of transforming the XML with the stylesheet as a
384 string.
385
386 </p>
387
388 </li>
389
390 <li>
391 <b>to_dom
392 </b>
393
394 <p>
395 Returns the result of transforming the XML with the stylesheet as an
396 XML::DOM object.
397
398 </p>
399
400 </li>
401
402 <li>
403 <b>media_type
404 </b>
405
406 <p>
407 Returns the media type (aka mime type) of the object.
408
409 </p>
410
411 </li>
412
413 <li>
414 <b>dispose
415 </b>
416
417 <p>
418 Executes the
419 dispose
420 method on each XML::DOM object.
421
422 </p>
423
424 </li>
425
426 </ul>
427
428
429
430
431
432
433
434 <h1>XML::XSLT Commands
435 </h1>
436
437 <ul>
438
439 <li>
440 <b>xsl:apply-imports no
441 </b>
442
443 <p>
444 Not supported yet.
445
446 </p>
447
448 </li>
449
450 <li>
451 <b>xsl:apply-templates limited
452 </b>
453
454 <p>
455 Attribute 'select' is supported to the same extent as xsl:value-of
456 supports path selections.
457
458 </p>
459
460 <p>
461 Not supported yet:
462 - attribute 'mode'
463 - xsl:sort and xsl:with-param in content
464
465 </p>
466
467 </li>
468
469 <li>
470 <b>xsl:attribute partially
471 </b>
472
473 <p>
474 Adds an attribute named to the value of the attribute 'name' and as value
475 the stringified content-template.
476
477 </p>
478
479 <p>
480 Not supported yet:
481 - attribute 'namespace'
482
483 </p>
484
485 </li>
486
487 <li>
488 <b>xsl:attribute-set yes
489 </b>
490
491 <p>
492 Partially
493
494 </p>
495
496 </li>
497
498 <li>
499 <b>xsl:call-template yes
500 </b>
501
502 <p>
503 Takes attribute 'name' which selects xsl:template's by name.
504
505 </p>
506
507 <p>
508 Weak support:
509 - xsl:with-param (select attrib not supported)
510
511 </p>
512
513 <p>
514 Not supported yet:
515 - xsl:sort
516
517 </p>
518
519 </li>
520
521 <li>
522 <b>xsl:choose yes
523 </b>
524
525 <p>
526 Tests sequentially all xsl:whens until one succeeds or
527 until an xsl:otherwise is found. Limited test support, see xsl:when
528
529 </p>
530
531 </li>
532
533 <li>
534 <b>xsl:comment yes
535 </b>
536
537 <p>
538 Supported.
539
540 </p>
541
542 </li>
543
544 <li>
545 <b>xsl:copy partially
546 </b>
547
548 </li>
549
550 <li>
551 <b>xsl:copy-of limited
552 </b>
553
554 <p>
555 Attribute 'select' functions as well as with
556 xsl:value-of
557
558 </p>
559
560 </li>
561
562 <li>
563 <b>xsl:decimal-format no
564 </b>
565
566 <p>
567 Not supported yet.
568
569 </p>
570
571 </li>
572
573 <li>
574 <b>xsl:element yes
575 </b>
576
577 </li>
578
579 <li>
580 <b>xsl:fallback no
581 </b>
582
583 <p>
584 Not supported yet.
585
586 </p>
587
588 </li>
589
590 <li>
591 <b>xsl:for-each limited
592 </b>
593
594 <p>
595 Attribute 'select' functions as well as with
596 xsl:value-of
597
598 </p>
599
600 <p>
601 Not supported yet:
602 - xsl:sort in content
603
604 </p>
605
606 </li>
607
608 <li>
609 <b>xsl:if limited
610 </b>
611
612 <p>
613 Identical to xsl:when, but outside xsl:choose context.
614
615 </p>
616
617 </li>
618
619 <li>
620 <b>xsl:import no
621 </b>
622
623 <p>
624 Not supported yet.
625
626 </p>
627
628 </li>
629
630 <li>
631 <b>xsl:include yes
632 </b>
633
634 <p>
635 Takes attribute href, which can be relative-local,
636 absolute-local as well as an URL (preceded by
637 identifier http:).
638
639 </p>
640
641 </li>
642
643 <li>
644 <b>xsl:key no
645 </b>
646
647 <p>
648 Not supported yet.
649
650 </p>
651
652 </li>
653
654 <li>
655 <b>xsl:message no
656 </b>
657
658 <p>
659 Not supported yet.
660
661 </p>
662
663 </li>
664
665 <li>
666 <b>xsl:namespace-alias no
667 </b>
668
669 <p>
670 Not supported yet.
671
672 </p>
673
674 </li>
675
676 <li>
677 <b>xsl:number no
678 </b>
679
680 <p>
681 Not supported yet.
682
683 </p>
684
685 </li>
686
687 <li>
688 <b>xsl:otherwise yes
689 </b>
690
691 <p>
692 Supported.
693
694 </p>
695
696 </li>
697
698 <li>
699 <b>xsl:output limited
700 </b>
701
702 <p>
703 Only the initial xsl:output element is used. The &quot;text&quot; output method
704 is not supported, but shouldn't be difficult to implement. Only the
705 &quot;doctype-public&quot;, &quot;doctype-system&quot;, &quot;omit-xml-declaration&quot;, &quot;method&quot;,
706 and &quot;encoding&quot; attributes have any support.
707
708 </p>
709
710 </li>
711
712 <li>
713 <b>xsl:param experimental
714 </b>
715
716 <p>
717 Synonym for xsl:variable (currently). See xsl:variable for support.
718
719 </p>
720
721 </li>
722
723 <li>
724 <b>xsl:preserve-space no
725 </b>
726
727 <p>
728 Not supported yet. Whitespace is always preserved.
729
730 </p>
731
732 </li>
733
734 <li>
735 <b>xsl:processing-instruction yes
736 </b>
737
738 <p>
739 Supported.
740
741 </p>
742
743 </li>
744
745 <li>
746 <b>xsl:sort no
747 </b>
748
749 <p>
750 Not supported yet.
751
752 </p>
753
754 </li>
755
756 <li>
757 <b>xsl:strip-space no
758 </b>
759
760 <p>
761 Not supported yet. No whitespace is stripped.
762
763 </p>
764
765 </li>
766
767 <li>
768 <b>xsl:stylesheet limited
769 </b>
770
771 <p>
772 Minor namespace support: other namespace than 'xsl:' for xsl-commands
773 is allowed if xmlns-attribute is present. xmlns URL is verified.
774 Other attributes are ignored.
775
776 </p>
777
778 </li>
779
780 <li>
781 <b>xsl:template limited
782 </b>
783
784 <p>
785 Attribute 'name' and 'match' are supported to minor extend.
786 ('name' must match exactly and 'match' must match with full
787 path or no path)
788
789 </p>
790
791 <p>
792 Not supported yet:
793 - attributes 'priority' and 'mode'
794
795 </p>
796
797 </li>
798
799 <li>
800 <b>xsl:text yes
801 </b>
802
803 <p>
804 Supported.
805
806 </p>
807
808 </li>
809
810 <li>
811 <b>xsl:transform limited
812 </b>
813
814 <p>
815 Synonym for xsl:stylesheet
816
817 </p>
818
819 </li>
820
821 <li>
822 <b>xsl:value-of limited
823 </b>
824
825 <p>
826 Inserts attribute or element values. Limited support:
827
828 </p>
829
830 <p>
831 &lt;xsl:value-of select=&quot;.&quot;/&gt;
832
833 </p>
834
835 <p>
836 &lt;xsl:value-of select=&quot;/root-elem&quot;/&gt;
837
838 </p>
839
840 <p>
841 &lt;xsl:value-of select=&quot;elem&quot;/&gt;
842
843 </p>
844
845 <p>
846 &lt;xsl:value-of select=&quot;//elem&quot;/&gt;
847
848 </p>
849
850 <p>
851 &lt;xsl:value-of select=&quot;elem[n]&quot;/&gt;
852
853 </p>
854
855 <p>
856 &lt;xsl:value-of select=&quot;//elem[n]&quot;/&gt;
857
858 </p>
859
860 <p>
861 &lt;xsl:value-of select=&quot;@attr&quot;/&gt;
862
863 </p>
864
865 <p>
866 &lt;xsl:value-of select=&quot;text()&quot;/&gt;
867
868 </p>
869
870 <p>
871 &lt;xsl:value-of select=&quot;processing-instruction()&quot;/&gt;
872
873 </p>
874
875 <p>
876 &lt;xsl:value-of select=&quot;comment()&quot;/&gt;
877
878 </p>
879
880 <p>
881 and combinations of these.
882
883 </p>
884
885 <p>
886 Not supported yet:
887 - attribute 'disable-output-escaping'
888
889 </p>
890
891 </li>
892
893 <li>
894 <b>xsl:variable experimental
895 </b>
896
897 <p>
898 Very limited. It should be possible to define a variable and use it with
899 &amp;lt;xsl:value select=&quot;$varname&quot; /&amp;gt; within the same template.
900
901 </p>
902
903 </li>
904
905 <li>
906 <b>xsl:when limited
907 </b>
908
909 <p>
910 Only inside xsl:choose. Limited test support:
911
912 </p>
913
914 <p>
915 &lt;xsl:when test=&quot;@attr='value'&quot;&gt;
916
917 </p>
918
919 <p>
920 &lt;xsl:when test=&quot;elem='value'&quot;&gt;
921
922 </p>
923
924 <p>
925 &lt;xsl:when test=&quot;path/[@attr='value']&quot;&gt;
926
927 </p>
928
929 <p>
930 &lt;xsl:when test=&quot;path/[elem='value']&quot;&gt;
931
932 </p>
933
934 <p>
935 &lt;xsl:when test=&quot;path&quot;&gt;
936
937 </p>
938
939 <p>
940 path is supported to the same extend as with xsl:value-of
941
942 </p>
943
944 </li>
945
946 <li>
947 <b>xsl:with-param experimental
948 </b>
949
950 <p>
951 It is currently not functioning. (or is it?)
952
953 </p>
954
955 </li>
956
957 </ul>
958
959
960
961
962
963 <h1>SUPPORT
964 </h1>
965
966 <p>
967 General information, bug reporting tools, the latest version, mailing
968 lists, etc. can be found at the XML::XSLT homepage:
969
970 </p>
971
972 <pre>
973 http://xmlxslt.sourceforge.net/
974
975 </pre>
976
977
978
979
980
981 <h1>DEPRECATIONS
982 </h1>
983
984 <p>
985 Methods and interfaces from previous versions that are not documented in this
986 version are deprecated. Each of these deprecations can still be used
987 but will produce a warning when the deprecation is first used. You
988 can use the old interfaces without warnings by passing
989 new()
990 the
991 flag
992 use_deprecated
993 . Example:
994
995 </p>
996
997 <pre>
998 $parser = XML::XSLT-&gt;new($xsl, &quot;FILE&quot;,
999 use_deprecated =&gt; 1);
1000
1001 </pre>
1002
1003 <p>
1004 The deprecated methods will disappear by the time a 1.0 release is made.
1005
1006 </p>
1007
1008 <p>
1009 The deprecated methods are :
1010
1011 </p>
1012
1013 <ul>
1014
1015 <li>
1016 <b>output_string
1017 </b>
1018
1019 <p>
1020 use toString instead
1021
1022 </p>
1023
1024 </li>
1025
1026 <li>
1027 <b>result_string
1028 </b>
1029
1030 <p>
1031 use toString instead
1032
1033 </p>
1034
1035 </li>
1036
1037 <li>
1038 <b>output
1039 </b>
1040
1041 <p>
1042 use toString instead
1043
1044 </p>
1045
1046 </li>
1047
1048 <li>
1049 <b>result
1050 </b>
1051
1052 <p>
1053 use toString instead
1054
1055 </p>
1056
1057 </li>
1058
1059 <li>
1060 <b>result_mime_type
1061 </b>
1062
1063 <p>
1064 use media_type instead
1065
1066 </p>
1067
1068 </li>
1069
1070 <li>
1071 <b>output_mime_type
1072 </b>
1073
1074 <p>
1075 use media_type instead
1076
1077 </p>
1078
1079 </li>
1080
1081 <li>
1082 <b>result_tree
1083 </b>
1084
1085 <p>
1086 use to_dom instead
1087
1088 </p>
1089
1090 </li>
1091
1092 <li>
1093 <b>output_tree
1094 </b>
1095
1096 <p>
1097 use to_dom instead
1098
1099 </p>
1100
1101 </li>
1102
1103 <li>
1104 <b>transform_document
1105 </b>
1106
1107 <p>
1108 use transform instead
1109
1110 </p>
1111
1112 </li>
1113
1114 <li>
1115 <b>process_project
1116 </b>
1117
1118 <p>
1119 use process instead
1120
1121 </p>
1122
1123 </li>
1124
1125 <li>
1126 <b>open_project
1127 </b>
1128
1129 <p>
1130 use
1131 Source
1132 argument to
1133 new()
1134 and
1135 transform
1136 instead.
1137
1138 </p>
1139
1140 </li>
1141
1142 <li>
1143 <b>print_output
1144 </b>
1145
1146 <p>
1147 use
1148 serve()
1149 instead.
1150
1151 </p>
1152
1153 </li>
1154
1155 </ul>
1156
1157
1158
1159
1160
1161 <h1>BUGS
1162 </h1>
1163
1164 <p>
1165 Yes.
1166
1167 </p>
1168
1169
1170
1171
1172
1173 <h1>HISTORY
1174 </h1>
1175
1176 <p>
1177 Geert Josten and Egon Willighagen developed and maintained XML::XSLT
1178 up to version 0.22. At that point, Mark Hershberger started moving
1179 the project to Sourceforge and began working on it with Bron Gondwana.
1180
1181 </p>
1182
1183
1184
1185
1186
1187 <h1>LICENCE
1188 </h1>
1189
1190 <p>
1191 Copyright (c) 1999 Geert Josten &amp; Egon Willighagen. All Rights
1192 Reserverd. This module is free software, and may be distributed under
1193 the same terms and conditions as Perl.
1194
1195 </p>
1196
1197
1198
1199
1200
1201 <h1>AUTHORS
1202 </h1>
1203
1204 <p>
1205 Geert Josten &lt;[email protected]&gt;
1206
1207 </p>
1208
1209 <p>
1210 Egon Willighagen &lt;[email protected]&gt;
1211
1212 </p>
1213
1214 <p>
1215 Mark A. Hershberger &lt;[email protected]&gt;
1216
1217 </p>
1218
1219 <p>
1220 Bron Gondwana &lt;[email protected]&gt;
1221
1222 </p>
1223
1224 <p>
1225 Jonathan Stowe &lt;[email protected]&gt;
1226
1227 </p>
1228
1229
1230
1231
1232
1233 <h1>SEE ALSO
1234 </h1>
1235
1236 <p>
1237
1238 XML::DOM
1239 ,
1240 LWP::Simple
1241 ,
1242 XML::Parser
1243
1244
1245 </p>
1246
1247
1248
1249 </body></html>