Lines 669-722
sub marc2bibtex {
Link Here
|
669 |
$author = join ' and ', @texauthors; |
669 |
$author = join ' and ', @texauthors; |
670 |
|
670 |
|
671 |
# Defining the conversion hash according to the marcflavour |
671 |
# Defining the conversion hash according to the marcflavour |
672 |
my %bh; |
672 |
my @bh; |
673 |
if ( $marcflavour eq "UNIMARC" ) { |
673 |
if ( $marcflavour eq "UNIMARC" ) { |
674 |
|
674 |
|
675 |
# FIXME, TODO : handle repeatable fields |
675 |
# FIXME, TODO : handle repeatable fields |
676 |
# TODO : handle more types of documents |
676 |
# TODO : handle more types of documents |
677 |
|
677 |
|
678 |
# Unimarc to bibtex hash |
678 |
# Unimarc to bibtex hash |
679 |
%bh = ( |
679 |
@bh = ( |
680 |
|
680 |
|
681 |
# Mandatory |
681 |
# Mandatory |
682 |
author => $author, |
682 |
author => $author, |
683 |
title => $record->subfield("200", "a") || "", |
683 |
title => $record->subfield("200", "a") || "", |
684 |
editor => $record->subfield("210", "g") || "", |
684 |
editor => $record->subfield("210", "g") || "", |
685 |
publisher => $record->subfield("210", "c") || "", |
685 |
publisher => $record->subfield("210", "c") || "", |
686 |
year => $record->subfield("210", "d") || $record->subfield("210", "h") || "", |
686 |
year => $record->subfield("210", "d") || $record->subfield("210", "h") || "", |
687 |
|
687 |
|
688 |
# Optional |
688 |
# Optional |
689 |
volume => $record->subfield("200", "v") || "", |
689 |
volume => $record->subfield("200", "v") || "", |
690 |
series => $record->subfield("225", "a") || "", |
690 |
series => $record->subfield("225", "a") || "", |
691 |
address => $record->subfield("210", "a") || "", |
691 |
address => $record->subfield("210", "a") || "", |
692 |
edition => $record->subfield("205", "a") || "", |
692 |
edition => $record->subfield("205", "a") || "", |
693 |
note => $record->subfield("300", "a") || "", |
693 |
note => $record->subfield("300", "a") || "", |
694 |
url => $record->subfield("856", "u") || "" |
694 |
url => $record->subfield("856", "u") || "" |
695 |
); |
695 |
); |
696 |
} else { |
696 |
} else { |
697 |
|
697 |
|
698 |
# Marc21 to bibtex hash |
698 |
# Marc21 to bibtex hash |
699 |
%bh = ( |
699 |
@bh = ( |
700 |
|
700 |
|
701 |
# Mandatory |
701 |
# Mandatory |
702 |
author => $author, |
702 |
author => $author, |
703 |
title => $record->subfield("245", "a") || "", |
703 |
title => $record->subfield("245", "a") || "", |
704 |
editor => $record->subfield("260", "f") || "", |
704 |
editor => $record->subfield("260", "f") || "", |
705 |
publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "", |
705 |
publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "", |
706 |
year => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "", |
706 |
year => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "", |
707 |
|
707 |
|
708 |
# Optional |
708 |
# Optional |
709 |
# unimarc to marc21 specification says not to convert 200$v to marc21 |
709 |
# unimarc to marc21 specification says not to convert 200$v to marc21 |
710 |
series => $record->subfield("490", "a") || "", |
710 |
series => $record->subfield("490", "a") || "", |
711 |
address => $record->subfield("264", "a") || $record->subfield("260", "a") || "", |
711 |
address => $record->subfield("264", "a") || $record->subfield("260", "a") || "", |
712 |
edition => $record->subfield("250", "a") || "", |
712 |
edition => $record->subfield("250", "a") || "", |
713 |
note => $record->subfield("500", "a") || "", |
713 |
note => $record->subfield("500", "a") || "", |
714 |
url => $record->subfield("856", "u") || "" |
714 |
url => $record->subfield("856", "u") || "" |
715 |
); |
715 |
); |
716 |
} |
716 |
} |
717 |
|
717 |
|
718 |
$tex .= "\@book{"; |
718 |
$tex .= "\@book{"; |
719 |
$tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh); |
719 |
my @elt; |
|
|
720 |
for ( my $i = 0 ; $i < scalar( @bh ) ; $i = $i + 2 ) { |
721 |
next unless $bh[$i+1]; |
722 |
push @elt, qq|\t$bh[$i] = {$bh[$i+1]}|; |
723 |
} |
724 |
$tex .= join(",\n", $id, @elt); |
720 |
$tex .= "\n}\n"; |
725 |
$tex .= "\n}\n"; |
721 |
|
726 |
|
722 |
return $tex; |
727 |
return $tex; |
723 |
- |
|
|