use warnings;
use strict;
+use utf8;
use XML::Simple;
use Data::Dump qw(dump);
-use utf8;
my $odt_file = 'contributions.odt';
#foreach my $file ( glob 'contributions/*.xml' ) {
my $xml;
-open(my $fh, '<', 'contributions/all.xml');
+open(my $fh, '<:encoding(utf-8)', 'contributions/all.xml');
{
local $/ = undef;
$xml = <$fh>;
close($fh);
}
+#warn "---xml---", dump($xml), "---/xml---\n";
+
foreach my $xml ( split(/\Q<?xml\E/, $xml) ) {
next unless $xml;
my $abstract;
-#print $xml;
-
$abstract = $xs->XMLin( $xml, ForceArray => qw(PrimaryAuthor) );
warn "# abstract = ", dump($abstract);
#warn "# stat = ",dump($stat);
+use Encode;
+sub enc {
+ my $b = shift;
+ warn "# enc in ",Encode::is_utf8($b), dump($b);
+
+# $b = Encode::decode('iso-8859-1',$b); # XXX doesn't work!
+
+# Encode::from_to($b, 'iso-8859-1','utf-8');
+# Encode::_utf8_on($b);
+
+ Encode::_utf8_off($b);
+
+ warn "# enc out ",Encode::is_utf8($b), dump($b);
+ return $b;
+}
+sub l1 {
+ my $l = shift;
+ #return 'FIXME ref ' . dump($l) if ref $l;
+ return undef if ref $l;
+ return enc($l) if $l =~ m/([\x{80}-\x{ff}])/;
+ return $l;
+}
+
+my @authors;
+
sub abstract2doc {
my $id = shift;
$doc->setPageBreak( $t, position => 'before', style => 'Heading 1');
foreach my $a ( @{ $abstract->{PrimaryAuthor} } ) {
- $doc->appendParagraph(text => join(' ',
- map { $a->{$_}->[0] } qw( FirstName FamilyName )
- ), style => 'Heading 2');
- $doc->appendParagraph(text => join(' ',
- map { $a->{$_}->[0] } qw( Affiliation )
- ), style => 'Heading 3');
- push @{ $stat->{_Affiliation}->{ $a->{Affiliation}->[0] } }, $id;
+ my $v;
+ $v->{$_} = l1($a->{$_}->[0]) foreach qw( FirstName FamilyName Affiliation Email );
+ $doc->appendParagraph(text => $v->{FirstName} . ' ' . $v->{FamilyName}, style => 'Heading 2');
+ $doc->appendParagraph(text => $v->{Affiliation}, style => 'Heading 3');
+ push @{ $stat->{_Affiliation}->{ $v->{Affiliation} } }, $id;
+
+ push @authors, $v;
+
}
# $doc->appendParagraph(text => $abstract->{Content}->[0], style => 'Abstract');
$doc->appendParagraph(text => $p, style => 'Abstract');
}
- $doc->appendParagraph(text => "\nTheme: " . $abstract->{Theme}->[0], style => 'Theme');
+# $doc->appendParagraph(text => "\nTheme: " . $abstract->{Theme}->[0], style => 'Theme');
- $doc->appendParagraph(text => "\nContributionType: " . $abstract->{ContributionType}->[0], style => 'Quotations');
+# $doc->appendParagraph(text => "\nContributionType: " . $abstract->{ContributionType}->[0], style => 'Quotations');
$doc->appendParagraph(text => "\nID: " . $abstract->{Id}->[0], style => 'Abstract');
print $fh '"',$a,'","',dump( $stat->{_Affiliation}->{$a} ), '"', "\n";
}
+
+my $last_html = '';
+open(my $authors_fh, '>', 'authors.html');
+foreach my $a ( sort { $a->{FamilyName} cmp $b->{FamilyName} } @authors ) {
+ my $html = qq{
+<li>
+ <b>$a->{FamilyName}, $a->{FirstName}</b><br>
+ $a->{Affiliation}<br>
+ <em>$a->{Email}</em>
+</li>};
+ print $authors_fh $html eq $last_html ? '<!-- dup -->' : $html;
+ $last_html = $html;
+}
+
+close $authors_fh;
+
__DATA__
"Symposium proposal" => 12,
"Symposium abstract" => 52,