#!/usr/bin/perl
use autodie;
-use XML::TreePP;
+use XML::Simple;
use Data::Dump qw(dump);
+use utf8;
-my $tpp = XML::TreePP->new();
-my $tree = $tpp->parsefile( "abstracts.xml" );
+my $indico_xml = 'abstracts.xml';
+my $odt_file = 'abstracts.odt';
-my $abstracts = delete $tree->{AbstractBook}->{abstract};
+my $xs = XML::Simple->new();
+my $tree;
+{
+ open(my $fh, '<:raw', $indico_xml);
+ local $/ = undef;
+ my $xml = <$fh>;
+# warn dump($xml);
+ $tree = $xs->XMLin( $xml, ForceArray => qw(PrimaryAuthor) );
+}
+
+my $abstracts = delete $tree->{abstract};
warn "# tree = ", dump($tree);
+use OpenOffice::OODoc 2.101;
+my $doc = odfDocument(file => $odt_file, create => 'text');
my $stat;
my $id2nr;
+$doc->createStyle(
+ "Abstract",
+ family => 'paragraph',
+# parent => 'Default Style',
+# category => 'auto',
+ properties => {
+ -area => 'paragraph',
+ 'fo:text-align' => 'justify'
+ }
+);
+
+
my $nr = 0;
foreach my $abstract ( @$abstracts ) {
- my $id = $abstract->{'Id'} || die "no Id in ",dump($abstract);
+ my $id = $abstract->{'Id'}->[0] || die "no Id in ",dump($abstract);
warn "# $id abstract = ", dump($abstract);
foreach $k (qw( ContributionType )) {
- $stat->{$k}->{ $abstract->{$k} } ++;
+ $stat->{$k}->{ $abstract->{$k}->[0] } ++;
}
- foreach $f (@{ $abstract->{field} } ) {
- $f->{'-id'} == 1 ? push @{ $stat->{_symposium}->{ $f->{'#text'} } }, $id :
- $f->{'-id'} == 2 ? push @{ $stat->{_theme}->{ $f->{'#text'} } }, $id :
- "";
+ my $f = $abstract->{field};
+
+ push @{ $stat->{_symposium}->{ $f->{1}->{'content'} } }, $id if exists $f->{1}->{content};
+ push @{ $stat->{_theme}->{ $f->{2}->{'content'} } }, $id if exists $f->{2}->{content};
+
+ $stat->{field}->{ $_ }++ foreach keys %$f;
- $stat->{field}->{ $f->{'-id'} }++;
- }
$id2nr->{ $id } = $nr++;
+
+ $doc->appendParagraph(text => $abstract->{Title}->[0], style => 'Heading 1');
+
+ foreach my $a ( @{ $abstract->{PrimaryAuthor} } ) {
+ $doc->appendParagraph(text => join(' ',
+ map { $a->{$_}->[0] } qw( FirstName FamilyName Email Affiliation )
+ ), style => 'Heading 2');
+ }
+
+ $doc->appendParagraph(text => $abstract->{Content}->[0], style => 'Abstract');
+
+ my $pg = $doc->appendParagraph();
+ $doc->setPageBreak( $pg );
+
}
warn "# stat = ",dump($stat);
+
+$doc->save;
+