MKDoc-XML-0.75/ 0002755 0000764 0000764 00000000000 10214062151 013336 5 ustar bruno bruno 0000000 0000000 MKDoc-XML-0.75/t/ 0002755 0000764 0000764 00000000000 10214062151 013601 5 ustar bruno bruno 0000000 0000000 MKDoc-XML-0.75/t/500_MKDoc_XML_Decode.t 0000644 0000764 0000764 00000000707 07765641335 017324 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Decode;
my $decode = new MKDoc::XML::Decode (qw /xml xhtml numeric/);
is ($decode->process ('Hello, <'), 'Hello, <');
is ($decode->process ('Hello, >'), 'Hello, >');
is ($decode->process ('Hello, &'), 'Hello, &');
is ($decode->process ('Hello, "'), 'Hello, "');
is ($decode->process ('Hello, ''), 'Hello, \'');
1;
__END__
MKDoc-XML-0.75/t/101_MKDoc_XML_Tokenizer_Comment.t 0000644 0000764 0000764 00000000362 07765640455 021571 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tokenizer;
my $data = '';
eval { MKDoc::XML::Tokenizer->process_data ($data) };
ok ($@);
1;
__END__
MKDoc-XML-0.75/t/001_MKDoc_XML_Token_tag_open.t 0000644 0000764 0000764 00000001513 07765640455 021067 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Token;
my $data = qq ||;
my $token = new MKDoc::XML::Token ($data);
my $node = $token->tag_open();
ok (exists $node->{'petal:omit-tag'});
is ($node->{'petal:omit-tag'}, '');
$data = qq | |;
$token = new MKDoc::XML::Token ($data);
$node = $token->tag_open();
ok (exists $node->{'foo_bulb:zoo'});
is ($node->{'foo_bulb:zoo'}, 'baz');
$data = <
EOF
$token = new MKDoc::XML::Token ($data);
$node = $token->tag_open();
is ($node->{'petal_temp:attributes'}, 'petal:attributes dididi dadada');
$token = new MKDoc::XML::Token (qq ||);
$node = $token->tag_open();
is ($node->{foo}, 'bar');
1;
__END__
MKDoc-XML-0.75/t/604_MKDoc_XML_Dumper_Entities.t 0000644 0000764 0000764 00000000733 10006703757 021232 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Dumper;
my $xml = <
- First Impressions
=================
Okay, I am not allowed to disclosed information about "all Google software,
EOF
my $pl = MKDoc::XML::Dumper->xml2perl ($xml);
ok (ref $pl);
like ($pl->{data}, qr/\"/);
1;
__END__
MKDoc-XML-0.75/t/data/ 0002755 0000764 0000764 00000000000 10214062151 014512 5 ustar bruno bruno 0000000 0000000 MKDoc-XML-0.75/t/data/prova.xhtml 0000644 0000764 0000764 00000001030 10077525313 016722 0 ustar bruno bruno 0000000 0000000
Petal test
Walking in København.
MKDoc-XML-0.75/t/data/root.html 0000644 0000764 0000764 00000001275 07765640455 016420 0 ustar bruno bruno 0000000 0000000
Big Title
2002-01-01 00:00:00
0
fr
One, Two, Three
This is some description
default_child_listing_bottom
Blargh
This is a test
Foo Bar
MKDoc-XML-0.75/t/data/sample.xml 0000644 0000764 0000764 00000001646 07765640455 016554 0 ustar bruno bruno 0000000 0000000
en-gb
English (United Kingdom)
MKDoc
MKDoc-XML-0.75/t/100_MKDoc_XML_Tokenizer.t 0000644 0000764 0000764 00000002043 10130753640 020061 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tokenizer;
{
my $data = <
EOF
my $tokens = MKDoc::XML::Tokenizer->process_data ($data);
like ($tokens->[0]->as_string(), qr/value\=\"test\"/);
}
my $file = (-e 't/data/sample.xml') ? 't/data/sample.xml' : 'data/sample.xml';
my $tokens = MKDoc::XML::Tokenizer->process_file ($file);
like ($tokens->[0]->as_string(), qr/|);
like ($tokens->[9]->as_string(), qr/^\s+$/s);
1;
__END__
MKDoc-XML-0.75/t/601_MKDoc_XML_Dumper_Thaw.t 0000644 0000764 0000764 00000020070 07765640455 020357 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Dumper;
local $MKDoc::XML::Dumper::IndentLevel = 0;
# xml_to_perl_litteral
{
my $tree = { _tag => 'litteral', _content => [ 'Foo' ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_litteral ($tree);
is ($res, 'Foo');
}
{
my $tree = { _tag => 'litteral', _content => [ '' ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_litteral ($tree);
is ($res, '');
}
{
my $tree = { _tag => 'litteral', _content => [ '0' ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_litteral ($tree);
is ($res, '0');
}
{
my $tree = { _tag => 'litteral', undef => 'true' };
my $res = MKDoc::XML::Dumper->xml_to_perl_litteral ($tree);
ok (not defined $res);
}
# xml_to_perl_backref
{
my $ref = [];
my $ref_id = $ref + 0;
local $MKDoc::XML::Dumper::BackRef = { 12 => 'Foo' };
my $res = MKDoc::XML::Dumper->xml_to_perl_backref ( { _tag => 'backref', id => '12' } );
is ($res, 'Foo');
}
{
my $ref = [];
my $ref_id = $ref + 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $res = MKDoc::XML::Dumper->xml_to_perl_backref ( { _tag => 'backref', id => '12' } );
ok (not defined $res);
}
# xml_to_perl_scalar
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'scalar', id => '1', bless => 'Foo', _content => [
{ _tag => 'litteral', _content => [ 'ABCDEF' ] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_scalar ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
is ($$res, 'ABCDEF');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'scalar', id => '1', _content => [
{ _tag => 'litteral', _content => [ 'ABCDEF' ] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_scalar ($tree);
ok (ref $res);
is (ref $res, 'SCALAR');
is ($$res, 'ABCDEF');
}
# perl_to_xml_hash
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1', bless => 'Foo' };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /HASH/);
ok (scalar keys %{$res} == 0);
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1', bless => 'Foo', _content => [
{ _tag => 'item', key => 'foo', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] } ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /HASH/);
ok (scalar keys %{$res} == 1);
is ($res->{foo}, 'bar');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1', bless => 'Foo', _content => [
{ _tag => 'item', key => 'foo', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] },
{ _tag => 'item', key => 'baz', _content => [
{ _tag => 'litteral', _content => [ 'buz' ] }
] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /HASH/);
ok (scalar keys %{$res} == 2);
is ($res->{foo}, 'bar');
is ($res->{baz}, 'buz');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1' };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
is (ref $res, 'HASH');
ok (scalar keys %{$res} == 0);
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1', _content => [
{ _tag => 'item', key => 'foo', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] } ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
is (ref $res, 'HASH');
ok (scalar keys %{$res} == 1);
is ($res->{foo}, 'bar');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'hash', id => '1', _content => [
{ _tag => 'item', key => 'foo', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] },
{ _tag => 'item', key => 'baz', _content => [
{ _tag => 'litteral', _content => [ 'buz' ] }
] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_hash ($tree);
ok (ref $res);
is (ref $res, 'HASH');
ok (scalar keys %{$res} == 2);
is ($res->{foo}, 'bar');
is ($res->{baz}, 'buz');
}
# perl_to_xml_hash
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1', bless => 'Foo' };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /ARRAY/);
ok (@{$res} == 0);
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1', bless => 'Foo', _content => [
{ _tag => 'item', key => '0', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] } ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /ARRAY/);
ok (@{$res} == 1);
is ($res->[0], 'bar');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1', bless => 'Foo', _content => [
{ _tag => 'item', key => '0', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] },
{ _tag => 'item', key => '1', _content => [
{ _tag => 'litteral', _content => [ 'buz' ] }
] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
ok ($res->isa ('Foo'));
ok ($res =~ /ARRAY/);
ok (@{$res} == 2);
is ($res->[0], 'bar');
is ($res->[1], 'buz');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1' };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
is (ref $res, 'ARRAY');
ok (@{$res} == 0);
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1', _content => [
{ _tag => 'item', key => '0', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] } ] };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
is (ref $res, 'ARRAY');
ok (@{$res} == 1);
is ($res->[0], 'bar');
}
{
local $MKDoc::XML::Dumper::IndentLevel = 0;
local $MKDoc::XML::Dumper::BackRef = {};
my $tree = { _tag => 'array', id => '1', _content => [
{ _tag => 'item', key => '0', _content => [
{ _tag => 'litteral', _content => [ 'bar' ] }
] },
{ _tag => 'item', key => '1', _content => [
{ _tag => 'litteral', _content => [ 'buz' ] }
] }
] };
my $res = MKDoc::XML::Dumper->xml_to_perl_array ($tree);
ok (ref $res);
is (ref $res, 'ARRAY');
ok (@{$res} == 2);
is ($res->[0], 'bar');
is ($res->[1], 'buz');
}
{
# let's try some wicked stuff
local $MKDoc::XML::Dumper::BackRef = {};
my $tree =
{ _tag => 'ref', id => '1', _content => [
{ _tag => 'backref', id => '1' } ] };
my $res = MKDoc::XML::Dumper->xml_to_perl ( $tree );
ok (ref $res);
is (ref $res, 'REF');
is ($$res, $res);
}
1;
__END__
MKDoc-XML-0.75/t/304_MKDoc_XML_Tagger_Numbers.t 0000644 0000764 0000764 00000001554 10214061170 021020 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib ('../lib', 'lib');
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tagger::Preserve;
use MKDoc::XML::Tagger;
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff 1
",
{ _expr => '&(1)', _tag => 'a', href => '/' }
);
like ($text, qr|stuff 1
|);
}
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff 1
",
{ _expr => '1', _tag => 'a', href => '/' }
);
# very wrong
# like ($text, qr|&\(1 \)stuff 1
|);
# correct output
like ($text, qr|stuff 1
|);
}
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff &(1)
",
{ _expr => '&(1)', _tag => 'a', href => '/' }
);
like ($text, qr|stuff &\(1\)
|);
}
1;
__END__
MKDoc-XML-0.75/t/201_MKDoc_XML_TreeBuilder_Root.t 0000644 0000764 0000764 00000000447 07765640455 021353 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::TreeBuilder;
use MKDoc::XML::Tokenizer;
{
my @res = MKDoc::XML::TreeBuilder->process_file ('./t/data/root.html');
ok (1); # if it didn't die then we're good :)
}
1;
__END__
MKDoc-XML-0.75/t/300_MKDoc_XML_Tagger.t 0000644 0000764 0000764 00000005443 10130753640 017331 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tagger;
use MKDoc::XML::Tokenizer;
# _tag_close and _tag_open functions
{
my $tag = MKDoc::XML::Tagger::_tag_close ('strong');
is ($tag, '');
$tag = MKDoc::XML::Tagger::_tag_open ('strong');
is ($tag, '');
$tag = MKDoc::XML::Tagger::_tag_open ('strong', { class => 'superFort' });
is ($tag, '');
}
# this regex should match any amount of consecutive whitespace,
# or \&(214) like tags, or carriage returns
{
my $sample_text = <SGML
that is completely described in this document.
EOF
my $tokens = MKDoc::XML::Tokenizer->process_data ($example);
my ($text, $tags) = MKDoc::XML::Tagger::_segregate_markup_from_text ($tokens);
like ($text, qr/\&\(1\)SGML\&\(2\)/);
like ($text, qr/\&\(3\)completely described\&\(4\)/);
}
# more nasty test
{
my $r = MKDoc::XML::Tagger->process_data (
'Hello Cool World!',
{ _expr => 'Cool World', _tag => 'a', href => 'cw', alt => 'foo' },
{ _expr => 'Hello Cool World', _tag => 'a', href => 'hcw' }
);
is ($r, 'Hello Cool World !');
$r = MKDoc::XML::Tagger->process_data (
'<hello>',
{ _expr => 'hello', _tag => 'a', href => 'http://www.hello.com/' },
);
like ($r, qr/process_data (
'News foo barStatements , declarations
',
{
'_expr' => 'news',
'href' => 'http://news.com/',
'_tag' => 'a',
},
{
'_expr' => 'News',
'lang' => 'en',
'href' => 'http://users.groucho/news/',
'_tag' => 'a',
}
);
}
{
my $data = qq |<p>this is a test, hello world, this is a test</p>
|;
my $r = MKDoc::XML::Tagger->process_data (
$data,
{ _expr => 'Hello World', _tag => 'a', href => 'cw', alt => 'foo' }
);
}
{
my $r = MKDoc::XML::Tagger->process_data (
'q & a',
{
'_expr' => 'Q & A',
'href' => 'http://news.com/',
'_tag' => 'a',
}
);
is ($r, ' q & a ');
}
1;
__END__
MKDoc-XML-0.75/t/302_MKDoc_XML_Tagger_Spaces.t 0000644 0000764 0000764 00000001164 10065553624 020634 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tagger::Preserve;
# _tag_close and _tag_open functions
{
my $text = <process_data (
[ 'a' ],
$text,
{ _expr => 'News', _tag => 'a', href => 'http://news.com/' },
);
like ($text, qr/anewsletter/);
}
1;
__END__
MKDoc-XML-0.75/t/305_MKDoc_XML_tagger_ampersand.t 0000644 0000764 0000764 00000001655 10214042270 021422 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib ('../lib', 'lib');
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tagger::Preserve;
use MKDoc::XML::Tagger;
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff
",
{ _expr => 'stuff', _tag => 'a', href => 'http://example.com/foo.cgi?a=b&c=d' }
);
like ($text, qr|stuff
|, '& double escaped');
};
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff
",
{ _expr => 'stuff', _tag => 'foo', bar => '' }
);
like ($text, qr|stuff
|, '<> double escaped');
};
{
my $text = MKDoc::XML::Tagger->process_data (
"stuff
",
{ _expr => 'stuff', _tag => 'foo', bar => '"hello world"' }
);
like ($text, qr|stuff
|, '" double escaped');
};
1;
__END__
MKDoc-XML-0.75/t/400_MKDoc_XML_Stripper.t 0000644 0000764 0000764 00000006275 07765640455 017760 0 ustar bruno bruno 0000000 0000000 #!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Token;
use MKDoc::XML::Stripper;
# let's test this _node_to_tag business
{
my $r;
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1 } );
is ($r, '');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _close => 1 } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, _close => 1 } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, extra => "foo" } );
is ($r, '');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _close => 1, extra => "foo" } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, _close => 1, extra => "foo" } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, extra => "'foo'" } );
is ($r, '');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _close => 1, extra => "'foo'" } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, _close => 1, extra => "'foo'" } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, extra => "\"foo\"" } );
is ($r, '');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _close => 1, extra => "\"foo\"" } );
is ($r, ' ');
$r = MKDoc::XML::Stripper::_node_to_tag ( { _tag => 'b', _open => 1, _close => 1, extra => "\"foo\"" } );
is ($r, ' ');
}
# now let's perform some tests on MKDoc::XML::Stripper objects
{
my $s = new MKDoc::XML::Stripper;
ok ($s->isa ('MKDoc::XML::Stripper'));
# allow p along with 'class' and 'id' attributes
$s->allow (qw /p class id/);
ok ($s->{p});
is (ref $s->{p}, 'HASH');
ok ($s->{p}->{class});
ok ($s->{p}->{id});
ok (!$s->{p}->{p});
# let's see if the 'strip' method works...
my $token = undef;
$token = new MKDoc::XML::Token ('hello');
ok ($s->strip ($token));
is ($s->strip ($token)->as_string, 'hello');
$token = new MKDoc::XML::Token ('');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token (' ');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token (' ');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token (' ');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token (' ');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token ('');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token ('');
ok (!$s->strip ($token));
$token = new MKDoc::XML::Token ('');
ok ($s->strip ($token));
$token = new MKDoc::XML::Token ('
');
my $r = $s->strip ($token)->as_string();
like ($r, qr /