From e6017966d43f4c4f95b4a73093c2a32e0f5c8d87 Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 22 Jul 2009 18:08:59 +0000 Subject: [PATCH] Patch from Warren Layton for support of RIS format in SuperCat - thanks Warren! === I've put together another SuperCat feed, this type for the RIS format. This can be used with most bibliographic citation software, such as Reference Manager and Endnote. Combined with the previous "MARC text" feed for RefWorks, most software should be covered. I have only included the changes to add the feed and the XSLT file. The patch (against trunk) doesn't include any changes to the OPAC, but I'm willing to put something together if needed. The MARC21slim2RIS.xsl transform makes a few assumptions: * Any authors listed in 100, 110, or 111 fields are considered "primary authors" (A1) * Any individuals listed in 700 fields are considered primary authors (A1) if their last name is found in the statement of responsibility (245c). Otherwise, they are considered secondary authors (A2). It's not 100% accurate, but it's certainly a step up from just turning all 700-level authors into A2s. * Corporate authors listed in 710 fields are always considered secondary authors (A2). * Meetings in 711 fields are always converted into "Title Series" (T3) (i.e., a talk at a conference would have the conference name listed as the "Title Series", with the title of the talk listed as "T1", primary title). * Apart from field 520 (used for Abstracts, "N2"), no 5xx fields are used * Subfields in the 650 and 651 fields are used as keywords ("KW") Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Warren Layton git-svn-id: svn://svn.open-ils.org/ILS/trunk@13700 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 16 +- .../src/perlmods/OpenILS/WWW/SuperCat/Feed.pm | 52 ++++ Open-ILS/xsl/MARC21slim2RIS.xsl | 284 ++++++++++++++++++ 3 files changed, 349 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/xsl/MARC21slim2RIS.xsl diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index d2f5888eee..62a3a824f9 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -145,7 +145,7 @@ sub child_init { ->gather(1); $list = [ map { (keys %$_)[0] } @$list ]; - push @$list, 'htmlholdings','html', 'marctxt'; + push @$list, 'htmlholdings','html', 'marctxt', 'ris'; for my $browse_axis ( qw/title author subject topic series item-age/ ) { for my $record_browse_format ( @$list ) { @@ -260,6 +260,7 @@ sub unapi { + FORMATS } elsif ($type eq 'metarecord') { $body .= <<" FORMATS"; @@ -315,6 +316,7 @@ sub unapi { + FORMATS @@ -407,7 +409,7 @@ sub unapi { @{ $supercat->request("open-ils.supercat.$type.formats")->gather(1) } and !grep { $_ eq $base_format } - qw/opac html htmlholdings marctxt/ + qw/opac html htmlholdings marctxt ris/ ) { print "Content-type: text/html; charset=utf-8\n\n"; $apache->custom_response( 406, <<" HTML"); @@ -553,6 +555,10 @@ sub supercat { marctxt text/plain + + + ris + text/plain "; } @@ -622,6 +628,10 @@ sub supercat { marctxt text/plain + + + ris + text/plain "; for my $h (@$list) { @@ -1232,7 +1242,7 @@ sub create_record_feed { $feed->unapi($unapi) if ($flesh); $type = 'atom' if ($type eq 'html'); - $type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt')); + $type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt') || ($type eq 'ris')); #$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1); diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm index 5c1687243d..9b95d4a98b 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm @@ -797,4 +797,56 @@ package OpenILS::WWW::SuperCat::Feed::marctxt::item; use base 'OpenILS::WWW::SuperCat::Feed::marcxml::item'; +package OpenILS::WWW::SuperCat::Feed::ris; +use base 'OpenILS::WWW::SuperCat::Feed::marcxml'; + +sub new { + my $class = shift; + my $self = $class->SUPER::new; + $self->{type} = 'text/plain'; + $self->{xsl} = "/MARC21slim2RIS.xsl"; + return $self; +} + + +our ($_parser, $_xslt, $xslt_file); + +sub toString { + my $self = shift; + my $base = $self->base || ''; + my $root = $self->root || ''; + my $search = $self->search || ''; + my $class = $self->class || ''; + my $lib = $self->lib || '-'; + + $self->composeDoc; + + $_parser ||= new XML::LibXML; + $_xslt ||= new XML::LibXSLT; + + $xslt_file ||= + OpenSRF::Utils::SettingsClient + ->new + ->config_value( dirs => 'xsl' ). + $self->{xsl}; + + # parse the MARC text xslt ... + my $ris_xslt = $_xslt->parse_stylesheet( $_parser->parse_file($xslt_file) ); + + my $new_doc = $ris_xslt->transform( + $self->{doc}, + base_dir => "'$root'", + lib => "'$lib'", + searchTerms => "'$search'", + searchClass => "'$class'", + ); + + return $ris_xslt->output_string($new_doc); +} + + +package OpenILS::WWW::SuperCat::Feed::ris::item; +use base 'OpenILS::WWW::SuperCat::Feed::marcxml::item'; + + 1; diff --git a/Open-ILS/xsl/MARC21slim2RIS.xsl b/Open-ILS/xsl/MARC21slim2RIS.xsl new file mode 100644 index 0000000000..b00bd67274 --- /dev/null +++ b/Open-ILS/xsl/MARC21slim2RIS.xsl @@ -0,0 +1,284 @@ + + + + + + + + + + + TY - + + + + + + + + + + + JOUR + NEWS + SER + + + JOUR + + + + + + + + + BOOK + CHAP + CONF + THES + ABST + PAT + CASE + STAT + RPRT + CTLG + + + BOOK + + + + + + MAP + SOUND + MUSIC + + + + + MPCT + VIDEO + SLIDE + + + MPCT + + + + + + ART + + + GEN + + + + + + + COMP + ELEC + DATA + + + COMP + + + + GEN + + + + + + A1 - + + + + ,; + + + + + + + + + + + + + + + + + + + + + + + T1 - + + + + :/ + + + + + + + + : + + + / + + + + + + + + + + + + + + + + A1 - + + + ,; + + + + + + + + A2 - + + + ,; + + + + + + + + + + + + A2 - + + + + + + + + T3 - + + + + + + + + + + + + + + JO - + + + + + + + JF - + + + + + + + + CY - + + + : + + + + + + + + PB - + + + , + + + + + + + + PY - + + + . + + + + + + /// + + + + + + N2 - + + + + + + + KW - + + + + + + + UR - + + + + + + SN - + + + + + + ER - + + + -- 2.43.2