X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmatology.git;a=blobdiff_plain;f=lib%2FText%2FTradition%2FCollation.pm;h=fcdd1ff78959c66662fc5ac00a9481fba6afdf90;hp=17e439413e279be2299fffcceb685171ae258656;hb=2a8127263ef278f3f14b480a12b84f9aa4f92fdc;hpb=772edba80a9590a86b2d4e5a5d6d82392ade5933 diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index 17e4394..fcdd1ff 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -887,6 +887,13 @@ is( scalar $st->collation->readings, $READINGS, "Reparsed collation has all read is( scalar $st->collation->paths, $PATHS, "Reparsed collation has all paths" ); is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" ); +# Now add a stemma, write to GraphML, and parse again. +my $stemma = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' ); +is( ref( $stemma ), 'Text::Tradition::Stemma', "Parsed dotfile into stemma" ); +is( $tradition->stemmata, 1, "Tradition now has the stemma" ); +$graphml = $c->as_graphml; +like( $graphml, qr/digraph/, "Digraph declaration exists in GraphML" ); + =end testing =cut @@ -957,6 +964,8 @@ sub as_graphml { next unless $save_types{$attr->type_constraint->name}; $graph_attributes{$attr->name} = $save_types{$attr->type_constraint->name}; } + # Extra custom key for the tradition stemma(ta) + $graph_attributes{'stemmata'} = 'string'; foreach my $datum ( sort keys %graph_attributes ) { $graph_data_keys{$datum} = 'dg'.$gdi++; @@ -1030,11 +1039,16 @@ sub as_graphml { $sgraph->setAttribute( 'parse.nodes', 0 ); # fill in later $sgraph->setAttribute( 'parse.order', 'nodesfirst' ); - # Collation attribute data + # Tradition/collation attribute data foreach my $datum ( keys %graph_attributes ) { my $value; if( $datum eq 'version' ) { - $value = '3.1'; + $value = '3.2'; + } elsif( $datum eq 'stemmata' ) { + my @stemstrs; + map { push( @stemstrs, $_->editable( {linesep => ''} ) ) } + $self->tradition->stemmata; + $value = join( "\n", @stemstrs ); } elsif( $gattr_from{$datum} eq 'Tradition' ) { $value = $self->tradition->$datum; } else {