5 use Data::Dump qw(dump);
8 my $indico_xml = 'abstracts.xml';
9 my $odt_file = 'abstracts.odt';
11 my $xs = XML::Simple->new();
14 open(my $fh, '<:raw', $indico_xml);
18 $tree = $xs->XMLin( $xml, ForceArray => qw(PrimaryAuthor) );
21 my $abstracts = delete $tree->{abstract};
23 warn "# tree = ", dump($tree);
25 use OpenOffice::OODoc 2.101;
26 my $doc = odfDocument(file => $odt_file, create => 'text');
33 family => 'paragraph',
34 # parent => 'Default Style',
38 'fo:text-align' => 'justify'
44 foreach my $abstract ( @$abstracts ) {
46 my $id = $abstract->{'Id'}->[0] || die "no Id in ",dump($abstract);
47 warn "# $id abstract = ", dump($abstract);
49 foreach $k (qw( ContributionType )) {
50 $stat->{$k}->{ $abstract->{$k}->[0] } ++;
53 my $f = $abstract->{field};
55 push @{ $stat->{_symposium}->{ $f->{1}->{'content'} } }, $id if exists $f->{1}->{content};
56 push @{ $stat->{_theme}->{ $f->{2}->{'content'} } }, $id if exists $f->{2}->{content};
58 $stat->{field}->{ $_ }++ foreach keys %$f;
60 $id2nr->{ $id } = $nr++;
64 my $t = $doc->appendParagraph(text => $abstract->{Title}->[0], style => 'Heading 1');
65 $doc->setPageBreak( $t, position => 'before', style => 'Heading 1');
67 foreach my $a ( @{ $abstract->{PrimaryAuthor} } ) {
68 $doc->appendParagraph(text => join(' ',
69 map { $a->{$_}->[0] } qw( FirstName FamilyName Email Affiliation )
70 ), style => 'Heading 2');
71 push @{ $stat->{_Affiliation}->{ $a->{Affiliation}->[0] } }, $id;
74 $doc->appendParagraph(text => $abstract->{Content}->[0], style => 'Abstract');
76 $doc->appendParagraph(text => "\nTheme: " . $f->{2}->{'content'}, style => 'Theme');
79 $doc->appendParagraph(text => "\nID: " . $abstract->{Id}->[0], style => 'Abstract');
82 warn "# stat = ",dump($stat);
87 open(my $fh, '>', 'affiliation.csv');
88 foreach my $a ( sort keys %{ $stat->{_Affiliation} } ) {
89 print $fh '"',$a,'","',dump( $stat->{_Affiliation}->{$a} ), '"', "\n";