# The examples from the 1.1 Working Draft # $Id: spec_examples.t,v 1.3 2002/01/09 09:17:40 gellyfish Exp $ use Test::More tests => 8; use strict; use vars qw($DEBUGGING); $DEBUGGING = 0; use_ok('XML::XSLT'); # First example my $stylesheet =< <xsl:value-of select="title"/>

NOTE:

EOS my $xml =< Document Title Chapter Title
Section Title This is a test. This is a note.
Another Section Title This is another test. This is another note.
EOX # this is not the same as that in the spec because of white space issues my $expected =< Document Title

Document Title

Chapter Title

Section Title

This is a test.

NOTE: This is a note.

Another Section Title

This is another test.

NOTE: This is another note.

EOE chomp($expected); my $parser; eval { $parser = XML::XSLT->new($stylesheet,debug => $DEBUGGING); die unless $parser; }; warn $@ if $DEBUGGING; ok(!$@,'Can parse example stylesheet'); my $outstr; eval { $outstr = $parser->serve(\$xml,http_headers => 0); die "no output" unless $outstr; }; warn $@ if $DEBUGGING; ok(!$@,'serve produced output'); warn $outstr if $DEBUGGING; ok($outstr eq $expected,'Matches output'); $parser->dispose(); # The data example - test 'Literal result as stylesheet' $xml =< 10 9 7 4 3 4 6 -1.5 2 EOX $stylesheet =<<'EOS'; Sales Results By Division
Division Revenue Growth Bonus
color:red
EOS $expected =< Sales Results By Division
DivisionRevenueGrowthBonus
North1097
West6-1.52
South434
EOE eval { $parser = XML::XSLT->new(\$stylesheet,debug => $DEBUGGING); die unless $parser; }; ok(!$@,'Wahay it can parse literal result'); eval { $outstr = $parser->serve(\$xml,http_headers => 0); die unless $outstr; }; ok(!$@,'serve at least did something'); ok($outstr !~ 'xsl:sort', 'xsl:sort has not reappeared'); SKIP: { skip("Doesn't handle xsl:sort properly",1); ok( $outstr eq $expected,'Great it does Literal stylesheets'); } print $outstr if $DEBUGGING;