fix Tabular parser to account for a.c. wits; more doc and tests
[scpubgit/stemmatology.git] / t / text_tradition_parser_tei.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More 'no_plan';
5 $| = 1;
6
7
8
9 # =begin testing
10 {
11 use Text::Tradition;
12 binmode STDOUT, ":utf8";
13 binmode STDERR, ":utf8";
14 eval { no warnings; binmode $DB::OUT, ":utf8"; };
15
16 my $par_seg = 't/data/florilegium_tei_ps.xml';
17 my $t = Text::Tradition->new( 
18     'name'  => 'inline', 
19     'input' => 'TEI',
20     'file'  => $par_seg,
21     );
22
23 is( ref( $t ), 'Text::Tradition', "Parsed parallel-segmentation TEI" );
24 if( $t ) {
25     is( scalar $t->collation->readings, 319, "Collation has all readings" );
26     is( scalar $t->collation->paths, 2854, "Collation has all paths" );
27 }
28 }
29
30
31
32 # =begin testing
33 {
34 ## TODO test specific sorts of nodes of the parallel-seg XML.
35 }
36
37
38
39 # =begin testing
40 {
41 use XML::LibXML;
42 use XML::LibXML::XPathContext;
43 use Text::Tradition::Parser::TEI;
44
45 my $xml_str = '<tei><rdg wit="#A #B #C #D">some text</rdg></tei>';
46 my $el = XML::LibXML->new()->parse_string( $xml_str )->documentElement;
47 my $xpc = XML::LibXML::XPathContext->new( $el );
48 my $obj = $xpc->find( '//rdg' );
49
50 my @wits = Text::Tradition::Parser::TEI::_get_sigla( $obj );
51 is( join( ' ', @wits) , "A B C D", "correctly parsed reading wit string" );
52 }
53
54
55
56
57 1;