File: XSLT.xml

package info (click to toggle)
libxml-xslt-perl 0.48-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,356 kB
  • ctags: 113
  • sloc: xml: 10,773; perl: 3,134; makefile: 2
file content (629 lines) | stat: -rw-r--r-- 14,485 bytes parent folder | download | duplicates (4)
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
<?xml version='1.0' encoding='iso-8859-1'?>
<pod xmlns="http://axkit.org/ns/2000/pod2xml">
<head>
	<title>	XML::XSLT - A perl module for processing XSLT
	</title>
</head>
<sect1>
<title>SYNOPSIS</title>
<verbatim><![CDATA[
use XML::XSLT;
]]></verbatim>
<verbatim><![CDATA[
my $xslt = XML::XSLT->new ($xsl, warnings => 1);
]]></verbatim>
<verbatim><![CDATA[
$xslt->transform ($xmlfile);
print $xslt->toString;
]]></verbatim>
<verbatim><![CDATA[
$xslt->dispose();
]]></verbatim>
</sect1>
<sect1>
<title>DESCRIPTION</title>
<para>
This module implements the W3C's XSLT specification. The goal is full
implementation of this spec, but we have not yet achieved
that. However, it already works well.  See <link xref='XML::XSLT Commands'>XML::XSLT Commands</link> for
the current status of each command.
</para>
<para>
XML::XSLT makes use of XML::DOM and LWP::Simple, while XML::DOM
uses XML::Parser.  Therefore XML::Parser, XML::DOM and LWP::Simple
have to be installed properly for XML::XSLT to run.
</para>
</sect1>
<sect1>
<title>Specifying Sources</title>
<para>
The stylesheets and the documents may be passed as filenames, file
handles regular strings, string references or DOM-trees.  Functions
that require sources (e.g. new), will accept either a named parameter
or simply the argument.
</para>
<para>
Either of the following are allowed:
</para>
<verbatim><![CDATA[
my $xslt = XML::XSLT->new($xsl);
my $xslt = XML::XSLT->new(Source => $xsl);
]]></verbatim>
<para>
In documentation, the named parameter `Source' is always shown, but it
is never required.
</para>
<sect2>
<title>METHODS</title>
<list>
<item><itemtext>new(Source =&gt; $xml [, %args])</itemtext>
<para>
Returns a new XSLT parser object.  Valid flags are:
</para>
</item>
<list>
<item><itemtext>DOMparser_args</itemtext>
<para>
Hashref of arguments to pass to the XML::DOM::Parser object's parse
method.
</para>
</item>
<item><itemtext>variables</itemtext>
<para>
Hashref of variables and their values for the stylesheet.
</para>
</item>
<item><itemtext>base</itemtext>
<para>
Base of URL for file inclusion.
</para>
</item>
<item><itemtext>debug</itemtext>
<para>
Turn on debugging messages.
</para>
</item>
<item><itemtext>warnings</itemtext>
<para>
Turn on warning messages.
</para>
</item>
<item><itemtext>indent</itemtext>
<para>
Starting amount of indention for debug messages.  Defaults to 0.
</para>
</item>
<item><itemtext>indent_incr</itemtext>
<para>
Amount to indent each level of debug message.  Defaults to 1.
</para>
</item>
</list>
<item><itemtext>open_xml(Source =&gt; $xml [, %args])</itemtext>
<para>
Gives the XSLT object new XML to process.  Returns an XML::DOM object
corresponding to the XML.
</para>
</item>
<list>
<item><itemtext>base</itemtext>
<para>
The base URL to use for opening documents.
</para>
</item>
<item><itemtext>parser_args</itemtext>
<para>
Arguments to pase to the parser.
</para>
</item>
</list>
<item><itemtext>open_xsl(Source =&gt; $xml, [, %args])</itemtext>
<para>
Gives the XSLT object a new stylesheet to use in processing XML.
Returns an XML::DOM object corresponding to the stylesheet.  Any
arguments present are passed to the XML::DOM::Parser.
</para>
</item>
<list>
<item><itemtext>base</itemtext>
<para>
The base URL to use for opening documents.
</para>
</item>
<item><itemtext>parser_args</itemtext>
<para>
Arguments to pase to the parser.
</para>
</item>
</list>
<item><itemtext>process(%variables)</itemtext>
<para>
Processes the previously loaded XML through the stylesheet using the
variables set in the argument.
</para>
</item>
<item><itemtext>transform(Source =&gt; $xml [, %args])</itemtext>
<para>
Processes the given XML through the stylesheet.  Returns an XML::DOM
object corresponding to the transformed XML.  Any arguments present
are passed to the XML::DOM::Parser.
</para>
</item>
<item><itemtext>serve(Source =&gt; $xml [, %args])</itemtext>
<para>
Processes the given XML through the stylesheet.  Returns a string
containg the result.  Example:
</para>
<verbatim><![CDATA[
use XML::XSLT qw(serve);
]]></verbatim>
<verbatim><![CDATA[
$xslt = XML::XSLT->new($xsl);
print $xslt->serve $xml;
]]></verbatim>
</item>
<list>
<item><itemtext>http_headers</itemtext>
<para>
If true, then prepends the appropriate HTTP headers (e.g. Content-Type,
Content-Length);
</para>
<para>
Defaults to true.
</para>
</item>
<item><itemtext>xml_declaration</itemtext>
<para>
If true, then the result contains the appropriate &lt;?xml?&gt; header.
</para>
<para>
Defaults to true.
</para>
</item>
<item><itemtext>xml_version</itemtext>
<para>
The version of the XML.
</para>
<para>
Defaults to 1.0.
</para>
</item>
<item><itemtext>doctype</itemtext>
<para>
The type of DOCTYPE this document is.  Defaults to SYSTEM.
</para>
</item>
</list>
<item><itemtext>toString</itemtext>
<para>
Returns the result of transforming the XML with the stylesheet as a
string.
</para>
</item>
<item><itemtext>to_dom</itemtext>
<para>
Returns the result of transforming the XML with the stylesheet as an
XML::DOM object.
</para>
</item>
<item><itemtext>media_type</itemtext>
<para>
Returns the media type (aka mime type) of the object.
</para>
</item>
<item><itemtext>dispose</itemtext>
<para>
Executes the <code>dispose</code> method on each XML::DOM object.
</para>
</item>
</list>
</sect2>
</sect1>
<sect1>
<title>XML::XSLT Commands</title>
<list>
<item><itemtext>xsl:apply-imports		no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:apply-templates		limited</itemtext>
<para>
Attribute 'select' is supported to the same extent as xsl:value-of
supports path selections.
</para>
<para>
Not supported yet:
- attribute 'mode'
- xsl:sort and xsl:with-param in content
</para>
</item>
<item><itemtext>xsl:attribute			partially</itemtext>
<para>
Adds an attribute named to the value of the attribute 'name' and as value
the stringified content-template.
</para>
<para>
Not supported yet:
- attribute 'namespace'
</para>
</item>
<item><itemtext>xsl:attribute-set		yes</itemtext>
<para>
Partially
</para>
</item>
<item><itemtext>xsl:call-template		yes</itemtext>
<para>
Takes attribute 'name' which selects xsl:template's by name.
</para>
<para>
Weak support:
- xsl:with-param (select attrib not supported)
</para>
<para>
Not supported yet:
- xsl:sort
</para>
</item>
<item><itemtext>xsl:choose			yes</itemtext>
<para>
Tests sequentially all xsl:whens until one succeeds or
until an xsl:otherwise is found. Limited test support, see xsl:when
</para>
</item>
<item><itemtext>xsl:comment			yes</itemtext>
<para>
Supported.
</para>
</item>
<item><itemtext>xsl:copy				partially</itemtext>
</item>
<item><itemtext>xsl:copy-of			limited</itemtext>
<para>
Attribute 'select' functions as well as with
xsl:value-of
</para>
</item>
<item><itemtext>xsl:decimal-format		no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:element			yes</itemtext>
</item>
<item><itemtext>xsl:fallback			no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:for-each			limited</itemtext>
<para>
Attribute 'select' functions as well as with
xsl:value-of
</para>
<para>
Not supported yet:
- xsl:sort in content
</para>
</item>
<item><itemtext>xsl:if				limited</itemtext>
<para>
Identical to xsl:when, but outside xsl:choose context.
</para>
</item>
<item><itemtext>xsl:import			no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:include			yes</itemtext>
<para>
Takes attribute href, which can be relative-local, 
absolute-local as well as an URL (preceded by
identifier http:).
</para>
</item>
<item><itemtext>xsl:key				no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:message			no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:namespace-alias		no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:number			no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:otherwise			yes</itemtext>
<para>
Supported.
</para>
</item>
<item><itemtext>xsl:output			limited</itemtext>
<para>
Only the initial xsl:output element is used.  The &quot;text&quot; output method
is not supported, but shouldn't be difficult to implement.  Only the
&quot;doctype-public&quot;, &quot;doctype-system&quot;, &quot;omit-xml-declaration&quot;, &quot;method&quot;,
and &quot;encoding&quot; attributes have any support.
</para>
</item>
<item><itemtext>xsl:param			experimental</itemtext>
<para>
Synonym for xsl:variable (currently). See xsl:variable for support.
</para>
</item>
<item><itemtext>xsl:preserve-space		no</itemtext>
<para>
Not supported yet. Whitespace is always preserved.
</para>
</item>
<item><itemtext>xsl:processing-instruction	yes</itemtext>
<para>
Supported.
</para>
</item>
<item><itemtext>xsl:sort				no</itemtext>
<para>
Not supported yet.
</para>
</item>
<item><itemtext>xsl:strip-space			no</itemtext>
<para>
Not supported yet. No whitespace is stripped.
</para>
</item>
<item><itemtext>xsl:stylesheet			limited</itemtext>
<para>
Minor namespace support: other namespace than 'xsl:' for xsl-commands
is allowed if xmlns-attribute is present. xmlns URL is verified.
Other attributes are ignored.
</para>
</item>
<item><itemtext>xsl:template			limited</itemtext>
<para>
Attribute 'name' and 'match' are supported to minor extend.
('name' must match exactly and 'match' must match with full
path or no path)
</para>
<para>
Not supported yet:
- attributes 'priority' and 'mode'
</para>
</item>
<item><itemtext>xsl:text				yes</itemtext>
<para>
Supported.
</para>
</item>
<item><itemtext>xsl:transform			limited</itemtext>
<para>
Synonym for xsl:stylesheet
</para>
</item>
<item><itemtext>xsl:value-of			limited</itemtext>
<para>
Inserts attribute or element values. Limited support:
</para>
<para>
&lt;xsl:value-of select=&quot;.&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;/root-elem&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;elem&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;//elem&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;elem[n]&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;//elem[n]&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;@attr&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;text()&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;processing-instruction()&quot;/&gt;
</para>
<para>
&lt;xsl:value-of select=&quot;comment()&quot;/&gt;
</para>
<para>
and combinations of these.
</para>
<para>
Not supported yet:
- attribute 'disable-output-escaping'
</para>
</item>
<item><itemtext>xsl:variable			experimental</itemtext>
<para>
Very limited. It should be possible to define a variable and use it with
&amp;lt;xsl:value select=&quot;$varname&quot; /&amp;gt; within the same template.
</para>
</item>
<item><itemtext>xsl:when				limited</itemtext>
<para>
Only inside xsl:choose. Limited test support:
</para>
<para>
&lt;xsl:when test=&quot;@attr='value'&quot;&gt;
</para>
<para>
&lt;xsl:when test=&quot;elem='value'&quot;&gt;
</para>
<para>
&lt;xsl:when test=&quot;path/[@attr='value']&quot;&gt;
</para>
<para>
&lt;xsl:when test=&quot;path/[elem='value']&quot;&gt;
</para>
<para>
&lt;xsl:when test=&quot;path&quot;&gt;
</para>
<para>
path is supported to the same extend as with xsl:value-of
</para>
</item>
<item><itemtext>xsl:with-param			experimental</itemtext>
<para>
It is currently not functioning. (or is it?)
</para>
</item>
</list>
</sect1>
<sect1>
<title>SUPPORT</title>
<para>
General information, bug reporting tools, the latest version, mailing
lists, etc. can be found at the XML::XSLT homepage:
</para>
<verbatim><![CDATA[
http://xmlxslt.sourceforge.net/
]]></verbatim>
</sect1>
<sect1>
<title>DEPRECATIONS</title>
<para>
Methods and interfaces from previous versions that are not documented in this
version are deprecated.  Each of these deprecations can still be used
but will produce a warning when the deprecation is first used.  You
can use the old interfaces without warnings by passing <code>new()</code> the
flag <code>use_deprecated</code>.  Example:
</para>
<verbatim><![CDATA[
$parser = XML::XSLT->new($xsl, "FILE",
                         use_deprecated => 1);
]]></verbatim>
<para>
The deprecated methods will disappear by the time a 1.0 release is made.
</para>
<para>
The deprecated methods are :
</para>
<list>
<item><itemtext>output_string</itemtext>
<para>
use toString instead
</para>
</item>
<item><itemtext>result_string</itemtext>
<para>
use toString instead
</para>
</item>
<item><itemtext>output</itemtext>
<para>
use toString instead
</para>
</item>
<item><itemtext>result</itemtext>
<para>
use toString instead
</para>
</item>
<item><itemtext>result_mime_type</itemtext>
<para>
use media_type instead
</para>
</item>
<item><itemtext>output_mime_type</itemtext>
<para>
use media_type instead
</para>
</item>
<item><itemtext>result_tree</itemtext>
<para>
use to_dom instead
</para>
</item>
<item><itemtext>output_tree</itemtext>
<para>
use to_dom instead
</para>
</item>
<item><itemtext>transform_document</itemtext>
<para>
use transform instead
</para>
</item>
<item><itemtext>process_project</itemtext>
<para>
use process instead
</para>
</item>
<item><itemtext>open_project</itemtext>
<para>
use <code>Source</code> argument to <strong>new()</strong> and <strong>transform</strong> instead.
</para>
</item>
<item><itemtext>print_output</itemtext>
<para>
use <strong>serve()</strong> instead.
</para>
</item>
</list>
</sect1>
<sect1>
<title>BUGS</title>
<para>
Yes.
</para>
</sect1>
<sect1>
<title>HISTORY</title>
<para>
Geert Josten and Egon Willighagen developed and maintained XML::XSLT
up to version 0.22.  At that point, Mark Hershberger started moving
the project to Sourceforge and began working on it with Bron Gondwana.
</para>
</sect1>
<sect1>
<title>LICENCE</title>
<para>
Copyright (c) 1999 Geert Josten &amp; Egon Willighagen. All Rights
Reserverd.  This module is free software, and may be distributed under
the same terms and conditions as Perl.
</para>
</sect1>
<sect1>
<title>AUTHORS</title>
<para>
Geert Josten &lt;gjosten@sci.kun.nl&gt;
</para>
<para>
Egon Willighagen &lt;egonw@sci.kun.nl&gt;
</para>
<para>
Mark A. Hershberger &lt;mah@everybody.org&gt;
</para>
<para>
Bron Gondwana &lt;perlcode@brong.net&gt;
</para>
<para>
Jonathan Stowe &lt;jns@gellyfish.com&gt;
</para>
</sect1>
<sect1>
<title>SEE ALSO</title>
<para>
<link xref='XML::DOM'>XML::DOM</link>, <link xref='LWP::Simple'>LWP::Simple</link>, <link xref='XML::Parser'>XML::Parser</link>
</para>
</sect1>
</pod>