# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
-# $Id$
#
use strict;# use warnings; #FIXME: turn off warnings before release
use MARC::Record; # marc2marcxml, marcxml2marc, html2marc, changeEncoding
use MARC::File::XML; # marc2marcxml, marcxml2marc, html2marcxml, changeEncoding
use MARC::Crosswalk::DublinCore; # marc2dcxml
+use Biblio::EndnoteStyle;
use Unicode::Normalize; # _entity_encode
use XML::LibXSLT;
use XML::LibXML;
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g;
- shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = 3.00;
@ISA = qw(Exporter);
# only export API methods
@EXPORT = qw(
+ &marc2endnote
&marc2marc
&marc2marcxml
&marcxml2marc
$crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
}
my $dcxml = $crosswalk->as_dublincore($marc_record_obj);
- my $dcxmlfinal = "<?xml version=\"1.0\"?>\n";
+ my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$dcxmlfinal .= "<metadata
xmlns=\"http://example.org/myapp/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:dcterms=\"http://purl.org/dc/terms/\">";
foreach my $element ( $dcxml->elements() ) {
- $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name()."\n";
+ $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n";
}
$dcxmlfinal .= "\n</metadata>";
return ($error,$dcxmlfinal);
my ($marc) = @_;
# grab the XML, run it through our stylesheet, push it out to the browser
my $xmlrecord = marc2marcxml($marc);
- my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl";
+ my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/MARC21slim2MODS3-1.xsl";
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $source = $parser->parse_string($xmlrecord);
my $newxmlrecord = $stylesheet->output_string($results);
return ($newxmlrecord);
}
+
+sub marc2endnote {
+ my ($marc) = @_;
+ my $marc_rec_obj = MARC::Record->new_from_usmarc($marc);
+ my $f260 = $marc_rec_obj->field('260');
+ my $f260a = $f260->subfield('a') if $f260;
+ my $f710 = $marc_rec_obj->field('710');
+ my $f710a = $f710->subfield('a') if $f710;
+ my $f500 = $marc_rec_obj->field('500');
+ my $abstract = $f500->subfield('a') if $f500;
+ my $fields = {
+ DB => C4::Context->preference("LibraryName"),
+ Title => $marc_rec_obj->title(),
+ Author => $marc_rec_obj->author(),
+ Publisher => $f710a,
+ City => $f260a,
+ Year => $marc_rec_obj->publication_date,
+ Abstract => $abstract,
+ };
+ my $endnote;
+ my $style = new Biblio::EndnoteStyle();
+ my $template;
+ $template.= "DB - DB\n" if C4::Context->preference("LibraryName");
+ $template.="T1 - Title\n" if $marc_rec_obj->title();
+ $template.="A1 - Author\n" if $marc_rec_obj->author();
+ $template.="PB - Publisher\n" if $f710a;
+ $template.="CY - City\n" if $f260a;
+ $template.="Y1 - Year\n" if $marc_rec_obj->publication_date;
+ $template.="AB - Abstract\n" if $abstract;
+ my ($text, $errmsg) = $style->format($template, $fields);
+ return ($text);
+
+}
+
+
=head2 html2marcxml
=over 4
$marcxml.="<leader>@$values[$i]</leader>\n";
$first=1;
# rest of the fixed fields
- } elsif (@$tags[$i] < 010) { #FIXME: <10 was the way it was, there might even be a better way
+ } elsif (@$tags[$i] lt '010') { # don't compare numerically 010 == 8
$marcxml.="<controlfield tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
$first=1;
} else {
=head1 MODIFICATIONS
-# $Id$
=cut