1# $Id: xsl_cond.t,v 1.3 2001/12/17 11:32:09 gellyfish Exp $
2# check test attributes && the interface
3
4use Test::More tests => 25;
5use strict;
6use vars qw($DEBUGGING);
7
8$DEBUGGING = 0;
9
10use_ok('XML::XSLT');
11
12# element tests
13eval
14{
15   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
16<?xml version="1.0"?>
17<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
18<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
19<xsl:template match="p"><xsl:choose>
20 <xsl:when test="title='foo'">o</xsl:when>
21 <xsl:otherwise>not ok</xsl:otherwise>
22</xsl:choose><xsl:if test="title='foo'">k</xsl:if></xsl:template>
23</xsl:stylesheet>
24EOS
25
26   $parser->transform(\<<EOX);
27<?xml version="1.0"?><doc><p><title>foo</title>some random text</p></doc>
28EOX
29
30   my $outstr =  $parser->toString();
31
32   warn $outstr if $DEBUGGING;
33
34
35   my $correct = '<doc>ok</doc>';
36
37   $parser->dispose();
38
39   die "$outstr ne $correct\n" unless $outstr eq $correct;
40};
41
42warn $@ if $DEBUGGING;
43ok(!$@,"text node string eq");
44
45eval
46{
47   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
48<?xml version="1.0"?>
49<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
50<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
51<xsl:template match="p"><xsl:choose>
52 <xsl:when test="title != 'foo'">o</xsl:when>
53 <xsl:otherwise>not ok</xsl:otherwise>
54</xsl:choose><xsl:if test="title != 'foo'">k</xsl:if></xsl:template>
55</xsl:stylesheet>
56EOS
57
58   $parser->transform(\<<EOX);
59<?xml version="1.0"?><doc><p><title>bar</title>some random text</p></doc>
60EOX
61
62   my $outstr =  $parser->toString();
63
64   warn $outstr if $DEBUGGING;
65
66
67   my $correct = '<doc>ok</doc>';
68
69   $parser->dispose();
70
71   die "$outstr ne $correct\n" unless $outstr eq $correct;
72};
73
74ok(!$@,"text node string ne");
75
76eval
77{
78   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
79<?xml version="1.0"?>
80<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
81<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
82<xsl:template match="p"><xsl:choose>
83 <xsl:when test="title &lt; 'b'">o</xsl:when>
84 <xsl:otherwise>not ok</xsl:otherwise>
85</xsl:choose><xsl:if test="title &lt; 'b'">k</xsl:if></xsl:template>
86</xsl:stylesheet>
87EOS
88
89   $parser->transform(\<<EOX);
90<?xml version="1.0"?><doc><p><title>a</title>some random text</p></doc>
91EOX
92
93   my $outstr =  $parser->toString();
94
95   warn $outstr if $DEBUGGING;
96
97
98   my $correct = '<doc>ok</doc>';
99
100   $parser->dispose();
101
102   die "$outstr ne $correct\n" unless $outstr eq $correct;
103};
104
105warn $@ if $DEBUGGING;
106ok(!$@,"text node string lt");
107
108eval
109{
110   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
111<?xml version="1.0"?>
112<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
113<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
114<xsl:template match="p"><xsl:choose>
115 <xsl:when test="title > 'b'">o</xsl:when>
116 <xsl:otherwise>not ok</xsl:otherwise>
117</xsl:choose><xsl:if test="title > 'b'">k</xsl:if></xsl:template>
118</xsl:stylesheet>
119EOS
120
121   $parser->transform(\<<EOX);
122<?xml version="1.0"?><doc><p><title>c</title>some random text</p></doc>
123EOX
124
125   my $outstr =  $parser->toString();
126
127   warn $outstr if $DEBUGGING;
128
129
130   my $correct = '<doc>ok</doc>';
131
132   $parser->dispose();
133
134   die "$outstr ne $correct\n" unless $outstr eq $correct;
135};
136
137warn $@ if $DEBUGGING;
138ok(!$@,"text node string gt");
139
140eval
141{
142   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
143<?xml version="1.0"?>
144<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
145<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
146<xsl:template match="p"><xsl:choose>
147 <xsl:when test="title >= 'b'">o</xsl:when>
148 <xsl:otherwise>not ok</xsl:otherwise>
149</xsl:choose><xsl:if test="title >= 'b'">k</xsl:if></xsl:template>
150</xsl:stylesheet>
151EOS
152
153   $parser->transform(\<<EOX);
154<?xml version="1.0"?><doc><p><title>c</title>some random text</p></doc>
155EOX
156
157   my $outstr =  $parser->toString();
158
159   warn $outstr if $DEBUGGING;
160
161
162   my $correct = '<doc>ok</doc>';
163
164   $parser->dispose();
165
166   die "$outstr ne $correct\n" unless $outstr eq $correct;
167};
168
169warn $@ if $DEBUGGING;
170ok(!$@,"text node string ge");
171
172eval
173{
174   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
175<?xml version="1.0"?>
176<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
177<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
178<xsl:template match="p"><xsl:choose>
179 <xsl:when test="title &lt;= 'b'">o</xsl:when>
180 <xsl:otherwise>not ok</xsl:otherwise>
181</xsl:choose><xsl:if test="title &lt;= 'b'">k</xsl:if></xsl:template>
182</xsl:stylesheet>
183EOS
184
185   $parser->transform(\<<EOX);
186<?xml version="1.0"?><doc><p><title>b</title>some random text</p></doc>
187EOX
188
189   my $outstr =  $parser->toString();
190
191   warn $outstr if $DEBUGGING;
192
193
194   my $correct = '<doc>ok</doc>';
195
196   $parser->dispose();
197
198   die "$outstr ne $correct\n" unless $outstr eq $correct;
199};
200
201warn $@ if $DEBUGGING;
202ok(!$@,"text node string le");
203
204eval
205{
206   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
207<?xml version="1.0"?>
208<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
209<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
210<xsl:template match="p"><xsl:choose>
211 <xsl:when test="title = 42">o</xsl:when>
212 <xsl:otherwise>not ok</xsl:otherwise>
213</xsl:choose><xsl:if test="title = 42">k</xsl:if></xsl:template>
214</xsl:stylesheet>
215EOS
216
217   $parser->transform(\<<EOX);
218<?xml version="1.0"?><doc><p><title>42</title>some random text</p></doc>
219EOX
220
221   my $outstr =  $parser->toString();
222
223   warn $outstr if $DEBUGGING;
224
225
226   my $correct = '<doc>ok</doc>';
227
228   $parser->dispose();
229
230   die "$outstr ne $correct\n" unless $outstr eq $correct;
231};
232
233ok(!$@,"text node numeric eq");
234
235
236eval
237{
238   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
239<?xml version="1.0"?>
240<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
241<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
242<xsl:template match="p"><xsl:choose>
243 <xsl:when test="title != 42">o</xsl:when>
244 <xsl:otherwise>not ok</xsl:otherwise>
245</xsl:choose><xsl:if test="title != 42">k</xsl:if></xsl:template>
246</xsl:stylesheet>
247EOS
248
249   $parser->transform(\<<EOX);
250<?xml version="1.0"?><doc><p><title>43</title>some random text</p></doc>
251EOX
252
253   my $outstr =  $parser->toString();
254
255   warn $outstr if $DEBUGGING;
256
257
258   my $correct = '<doc>ok</doc>';
259
260   $parser->dispose();
261
262   die "$outstr ne $correct\n" unless $outstr eq $correct;
263};
264
265warn $@ if $DEBUGGING;
266ok(!$@,"text node numeric ne");
267
268eval
269{
270   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
271<?xml version="1.0"?>
272<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
273<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
274<xsl:template match="p"><xsl:choose>
275 <xsl:when test="title &lt; 42">o</xsl:when>
276 <xsl:otherwise>not ok</xsl:otherwise>
277</xsl:choose><xsl:if test="title &lt; 42">k</xsl:if></xsl:template>
278</xsl:stylesheet>
279EOS
280
281   $parser->transform(\<<EOX);
282<?xml version="1.0"?><doc><p><title>41</title>some random text</p></doc>
283EOX
284
285   my $outstr =  $parser->toString();
286
287   warn $outstr if $DEBUGGING;
288
289
290   my $correct = '<doc>ok</doc>';
291
292   $parser->dispose();
293
294   die "$outstr ne $correct\n" unless $outstr eq $correct;
295};
296
297warn $@ if $DEBUGGING;
298ok(!$@,"text node numeric lt");
299
300eval
301{
302   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
303<?xml version="1.0"?>
304<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
305<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
306<xsl:template match="p"><xsl:choose>
307 <xsl:when test="title > 42">o</xsl:when>
308 <xsl:otherwise>not ok</xsl:otherwise>
309</xsl:choose><xsl:if test="title > 42">k</xsl:if></xsl:template>
310</xsl:stylesheet>
311EOS
312
313   $parser->transform(\<<EOX);
314<?xml version="1.0"?><doc><p><title>43</title>some random text</p></doc>
315EOX
316
317   my $outstr =  $parser->toString();
318
319   warn $outstr if $DEBUGGING;
320
321
322   my $correct = '<doc>ok</doc>';
323
324   $parser->dispose();
325
326   die "$outstr ne $correct\n" unless $outstr eq $correct;
327};
328
329warn $@ if $DEBUGGING;
330ok(!$@,"text node numeric gt");
331
332
333eval
334{
335   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
336<?xml version="1.0"?>
337<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
338<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
339<xsl:template match="p"><xsl:choose>
340 <xsl:when test="title >= 42">o</xsl:when>
341 <xsl:otherwise>not ok</xsl:otherwise>
342</xsl:choose><xsl:if test="title >= 42">k</xsl:if></xsl:template>
343</xsl:stylesheet>
344EOS
345
346   $parser->transform(\<<EOX);
347<?xml version="1.0"?><doc><p><title>43</title>some random text</p></doc>
348EOX
349
350   my $outstr =  $parser->toString();
351
352   warn $outstr if $DEBUGGING;
353
354
355   my $correct = '<doc>ok</doc>';
356
357   $parser->dispose();
358
359   die "$outstr ne $correct\n" unless $outstr eq $correct;
360};
361
362warn $@ if $DEBUGGING;
363ok(!$@,"text node numeric ge");
364
365eval
366{
367   my $parser =  XML::XSLT->new (<<EOS, debug => $DEBUGGING);
368<?xml version="1.0"?>
369<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
370<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
371<xsl:template match="p"><xsl:choose>
372 <xsl:when test="title &lt;= 42">o</xsl:when>
373 <xsl:otherwise>not ok</xsl:otherwise>
374</xsl:choose><xsl:if test="title &lt;= 42">k</xsl:if></xsl:template>
375</xsl:stylesheet>
376EOS
377
378   $parser->transform(\<<EOX);
379<?xml version="1.0"?><doc><p><title>41</title>some random text</p></doc>
380EOX
381
382   my $outstr =  $parser->toString();
383
384   warn $outstr if $DEBUGGING;
385
386
387   my $correct = '<doc>ok</doc>';
388
389   $parser->dispose();
390
391   die "$outstr ne $correct\n" unless $outstr eq $correct;
392};
393
394warn $@ if $DEBUGGING;
395ok(!$@,"text node numeric le");
396
397# attribute tests
398
399eval
400{
401   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
402<?xml version="1.0"?>
403<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
404<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
405<xsl:template match="p"><xsl:choose>
406 <xsl:when test="@title='foo'">o</xsl:when>
407 <xsl:otherwise>not ok</xsl:otherwise>
408</xsl:choose><xsl:if test="@title='foo'">k</xsl:if></xsl:template>
409</xsl:stylesheet>
410EOS
411
412   $parser->transform(\<<EOX);
413<?xml version="1.0"?><doc><p title="foo">some random text</p></doc>
414EOX
415
416   my $outstr =  $parser->toString();
417
418   warn $outstr if $DEBUGGING;
419
420
421   my $correct = '<doc>ok</doc>';
422
423   $parser->dispose();
424
425   die "$outstr ne $correct\n" unless $outstr eq $correct;
426};
427
428warn $@ if $DEBUGGING;
429ok(!$@,"attribute string eq");
430
431eval
432{
433   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
434<?xml version="1.0"?>
435<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
436<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
437<xsl:template match="p"><xsl:choose>
438 <xsl:when test="@title != 'foo'">o</xsl:when>
439 <xsl:otherwise>not ok</xsl:otherwise>
440</xsl:choose><xsl:if test="@title != 'foo'">k</xsl:if></xsl:template>
441</xsl:stylesheet>
442EOS
443
444   $parser->transform(\<<EOX);
445<?xml version="1.0"?><doc><p title="bar">some random text</p></doc>
446EOX
447
448   my $outstr =  $parser->toString();
449
450   warn $outstr if $DEBUGGING;
451
452
453   my $correct = '<doc>ok</doc>';
454
455   $parser->dispose();
456
457   die "$outstr ne $correct\n" unless $outstr eq $correct;
458};
459
460ok(!$@,"attribute string ne");
461
462eval
463{
464   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
465<?xml version="1.0"?>
466<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
467<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
468<xsl:template match="p"><xsl:choose>
469 <xsl:when test="@title &lt; 'b'">o</xsl:when>
470 <xsl:otherwise>not ok</xsl:otherwise>
471</xsl:choose><xsl:if test="@title &lt; 'b'">k</xsl:if></xsl:template>
472</xsl:stylesheet>
473EOS
474
475   $parser->transform(\<<EOX);
476<?xml version="1.0"?><doc><p title="a">some random text</p></doc>
477EOX
478
479   my $outstr =  $parser->toString();
480
481   warn $outstr if $DEBUGGING;
482
483
484   my $correct = '<doc>ok</doc>';
485
486   $parser->dispose();
487
488   die "$outstr ne $correct\n" unless $outstr eq $correct;
489};
490
491warn $@ if $DEBUGGING;
492ok(!$@,"attribute string lt");
493
494eval
495{
496   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
497<?xml version="1.0"?>
498<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
499<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
500<xsl:template match="p"><xsl:choose>
501 <xsl:when test="@title > 'b'">o</xsl:when>
502 <xsl:otherwise>not ok</xsl:otherwise>
503</xsl:choose><xsl:if test="@title > 'b'">k</xsl:if></xsl:template>
504</xsl:stylesheet>
505EOS
506
507   $parser->transform(\<<EOX);
508<?xml version="1.0"?><doc><p title="c">some random text</p></doc>
509EOX
510
511   my $outstr =  $parser->toString();
512
513   warn $outstr if $DEBUGGING;
514
515
516   my $correct = '<doc>ok</doc>';
517
518   $parser->dispose();
519
520   die "$outstr ne $correct\n" unless $outstr eq $correct;
521};
522
523warn $@ if $DEBUGGING;
524ok(!$@,"attribute string gt");
525
526eval
527{
528   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
529<?xml version="1.0"?>
530<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
531<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
532<xsl:template match="p"><xsl:choose>
533 <xsl:when test="@title >= 'b'">o</xsl:when>
534 <xsl:otherwise>not ok</xsl:otherwise>
535</xsl:choose><xsl:if test="@title >= 'b'">k</xsl:if></xsl:template>
536</xsl:stylesheet>
537EOS
538
539   $parser->transform(\<<EOX);
540<?xml version="1.0"?><doc><p title="c">some random text</p></doc>
541EOX
542
543   my $outstr =  $parser->toString();
544
545   warn $outstr if $DEBUGGING;
546
547
548   my $correct = '<doc>ok</doc>';
549
550   $parser->dispose();
551
552   die "$outstr ne $correct\n" unless $outstr eq $correct;
553};
554
555warn $@ if $DEBUGGING;
556ok(!$@,"attribute string ge");
557
558eval
559{
560   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
561<?xml version="1.0"?>
562<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
563<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
564<xsl:template match="p"><xsl:choose>
565 <xsl:when test="@title &lt;= 'b'">o</xsl:when>
566 <xsl:otherwise>not ok</xsl:otherwise>
567</xsl:choose><xsl:if test="@title &lt;= 'b'">k</xsl:if></xsl:template>
568</xsl:stylesheet>
569EOS
570
571   $parser->transform(\<<EOX);
572<?xml version="1.0"?><doc><p title="b">some random text</p></doc>
573EOX
574
575   my $outstr =  $parser->toString();
576
577   warn $outstr if $DEBUGGING;
578
579
580   my $correct = '<doc>ok</doc>';
581
582   $parser->dispose();
583
584   die "$outstr ne $correct\n" unless $outstr eq $correct;
585};
586
587warn $@ if $DEBUGGING;
588ok(!$@,"attribute string le");
589
590eval
591{
592   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
593<?xml version="1.0"?>
594<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
595<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
596<xsl:template match="p"><xsl:choose>
597 <xsl:when test="@title = 42">o</xsl:when>
598 <xsl:otherwise>not ok</xsl:otherwise>
599</xsl:choose><xsl:if test="@title = 42">k</xsl:if></xsl:template>
600</xsl:stylesheet>
601EOS
602
603   $parser->transform(\<<EOX);
604<?xml version="1.0"?><doc><p title="42">some random text</p></doc>
605EOX
606
607   my $outstr =  $parser->toString();
608
609   warn $outstr if $DEBUGGING;
610
611
612   my $correct = '<doc>ok</doc>';
613
614   $parser->dispose();
615
616   die "$outstr ne $correct\n" unless $outstr eq $correct;
617};
618
619ok(!$@,"attribute numeric eq");
620
621
622eval
623{
624   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
625<?xml version="1.0"?>
626<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
627<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
628<xsl:template match="p"><xsl:choose>
629 <xsl:when test="@title != 42">o</xsl:when>
630 <xsl:otherwise>not ok</xsl:otherwise>
631</xsl:choose><xsl:if test="@title != 42">k</xsl:if></xsl:template>
632</xsl:stylesheet>
633EOS
634
635   $parser->transform(\<<EOX);
636<?xml version="1.0"?><doc><p title="43">some random text</p></doc>
637EOX
638
639   my $outstr =  $parser->toString();
640
641   warn $outstr if $DEBUGGING;
642
643
644   my $correct = '<doc>ok</doc>';
645
646   $parser->dispose();
647
648   die "$outstr ne $correct\n" unless $outstr eq $correct;
649};
650
651warn $@ if $DEBUGGING;
652ok(!$@,"attribute numeric ne");
653
654eval
655{
656   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
657<?xml version="1.0"?>
658<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
659<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
660<xsl:template match="p"><xsl:choose>
661 <xsl:when test="@title &lt; 42">o</xsl:when>
662 <xsl:otherwise>not ok</xsl:otherwise>
663</xsl:choose><xsl:if test="@title &lt; 42">k</xsl:if></xsl:template>
664</xsl:stylesheet>
665EOS
666
667   $parser->transform(\<<EOX);
668<?xml version="1.0"?><doc><p title="41">some random text</p></doc>
669EOX
670
671   my $outstr =  $parser->toString();
672
673   warn $outstr if $DEBUGGING;
674
675
676   my $correct = '<doc>ok</doc>';
677
678   $parser->dispose();
679
680   die "$outstr ne $correct\n" unless $outstr eq $correct;
681};
682
683warn $@ if $DEBUGGING;
684ok(!$@,"attribute numeric lt");
685
686eval
687{
688   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
689<?xml version="1.0"?>
690<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
691<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
692<xsl:template match="p"><xsl:choose>
693 <xsl:when test="@title > 42">o</xsl:when>
694 <xsl:otherwise>not ok</xsl:otherwise>
695</xsl:choose><xsl:if test="@title > 42">k</xsl:if></xsl:template>
696</xsl:stylesheet>
697EOS
698
699   $parser->transform(\<<EOX);
700<?xml version="1.0"?><doc><p title="43">some random text</p></doc>
701EOX
702
703   my $outstr =  $parser->toString();
704
705   warn $outstr if $DEBUGGING;
706
707
708   my $correct = '<doc>ok</doc>';
709
710   $parser->dispose();
711
712   die "$outstr ne $correct\n" unless $outstr eq $correct;
713};
714
715warn $@ if $DEBUGGING;
716ok(!$@,"attribute numeric gt");
717
718
719eval
720{
721   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
722<?xml version="1.0"?>
723<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
724<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
725<xsl:template match="p"><xsl:choose>
726 <xsl:when test="@title >= 42">o</xsl:when>
727 <xsl:otherwise>not ok</xsl:otherwise>
728</xsl:choose><xsl:if test="@title >= 42">k</xsl:if></xsl:template>
729</xsl:stylesheet>
730EOS
731
732   $parser->transform(\<<EOX);
733<?xml version="1.0"?><doc><p title="42">some random text</p></doc>
734EOX
735
736   my $outstr =  $parser->toString();
737
738   warn $outstr if $DEBUGGING;
739
740
741   my $correct = '<doc>ok</doc>';
742
743   $parser->dispose();
744
745   die "$outstr ne $correct\n" unless $outstr eq $correct;
746};
747
748warn $@ if $DEBUGGING;
749ok(!$@,"attribute numeric ge");
750
751eval
752{
753   my $parser =  XML::XSLT->new (<<'EOS', debug => $DEBUGGING);
754<?xml version="1.0"?>
755<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
756<xsl:template match="doc"><doc><xsl:apply-templates/></doc></xsl:template>
757<xsl:template match="p"><xsl:choose>
758 <xsl:when test="@title &lt;= 42">o</xsl:when>
759 <xsl:otherwise>not ok</xsl:otherwise>
760</xsl:choose><xsl:if test="@title &lt;= 42">k</xsl:if></xsl:template>
761</xsl:stylesheet>
762EOS
763
764   $parser->transform(\<<EOX);
765<?xml version="1.0"?><doc><p title="41">some random text</p></doc>
766EOX
767
768   my $outstr =  $parser->toString();
769
770   warn $outstr if $DEBUGGING;
771
772
773   my $correct = '<doc>ok</doc>';
774
775   $parser->dispose();
776
777   die "$outstr ne $correct\n" unless $outstr eq $correct;
778};
779
780warn $@ if $DEBUGGING;
781ok(!$@,"attribute numeric le");
782
783