# get_marc_attrs( { marc_xml => doc } )
BLOCK get_marc_attrs;
xml = args.marc_xml;
+
+ # Map item types to schema.org types; impedance mismatch :(
+ args.schema.itemtype = {};
+ schema_typemap = {};
+ schema_typemap.a = 'http://schema.org/Book';
+ schema_typemap.j = 'http://schema.org/MusicRecording';
+
args.isbns = [];
FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]');
args.isbns.push(isbn.textContent);
END;
+
args.upcs = [];
FOR upc IN xml.findnodes('//*[@tag="024"]/*[@code="a"]');
args.upcs.push(upc.textContent);
END;
args.upc = args.upcs.0; # use first UPC as the default
- args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
- args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
- args.title_extended = xml.findnodes('//*[@tag="245"]').textContent;
- args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
- args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
- args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
- args.summary = xml.findnodes('//*[@tag="520"]/*[@code="a"]').textContent;
- args.edition = xml.findnodes('//*[@tag="250"]/*[@code="a"]').textContent ||
- xml.findnodes('//*[@tag="534"]/*[@code="b"]').textContent ||
- xml.findnodes('//*[@tag="775"]/*[@code="b"]').textContent;
- phys = xml.findnodes(
+
+ args.issns = [];
+ FOR sub IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
+ args.issns.push(sub.textContent);
+ END;
+ args.issn = (args.issns.size) ? args.issn.0 : '';
+
+ args.authors = [];
+ FOR sub IN xml.findnodes('//*[@tag="100"]/*[@code="a"]');
+ args.authors.push(sub.textContent);
+ END;
+ args.author = (args.authors.size) ? args.authors.0 : '';
+
+ # Include subfields 'abnp' to generate a more comprehensive title display in search results
+ titresults = xml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b" or @code="n" or @code="p"]');
+ titresults_content = [];
+ FOR sub IN titresults; titresults_content.push(sub.textContent); END;
+ args.title = titresults_content.join(" ");
+ # Avoid ugly trailing syntax on brief titles
+ args.title = args.title | replace('[:;/]$', '');
+
+ # Provide correct spacing between the subfields
+ titsubs = xml.findnodes('//*[@tag="245"]/*[@code]');
+ titsubs_content = [];
+ FOR sub IN titsubs; titsubs_content.push(sub.textContent); END;
+ args.title_extended = titsubs_content.join(" ");
+
+ args.pubplaces = [];
+ FOR sub IN xml.findnodes('//*[@tag="260"]/*[@code="a"]');
+ args.pubplaces.push(sub.textContent);
+ END;
+ args.pubplace = (args.pubplaces.size) ? args.pubplaces.0 : '';
+
+ args.publishers = [];
+ FOR sub IN xml.findnodes('//*[@tag="260"]/*[@code="b"]');
+ args.publishers.push(sub.textContent);
+ END;
+ args.publisher = (args.publishers.size) ? args.publishers.0 : '';
+
+ args.pubdates = [];
+ FOR sub IN xml.findnodes('//*[@tag="260"]/*[@code="c"]');
+ args.pubdates.push(sub.textContent);
+ END;
+ args.pubdate = (args.pubdates.size) ? args.pubdates.0 : '';
+
+ # Full publisher info
+ args.pubinfo = "$args.pubplace $args.publisher $args.pubdate";
+
+ args.summaries = [];
+ FOR sub IN xml.findnodes('//*[@tag="520"]/*[@code="a"]');
+ args.summaries.push(sub.textContent);
+ END;
+ args.summary = (args.summaries.size) ? args.summaries.0 : '';
+
+ args.editions = [];
+ ed_hunt = xml.findnodes('//*[@tag="250"]/*[@code="a"]') ||
+ xml.findnodes('//*[@tag="534"]/*[@code="b"]') ||
+ xml.findnodes('//*[@tag="775"]/*[@code="b"]');
+ FOR sub IN ed_hunt;
+ args.editions.push(sub.textContent);
+ END;
+ args.edition = (args.editions.size) ? args.editions.0 : '';
+
+ phys_content = [];
+ FOR sub IN xml.findnodes(
'//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
);
- phys_content = [];
- FOR p IN phys; phys_content.push(p.textContent); END;
- args.phys_desc = phys_content.join("");
+ phys_content.push(sub.textContent);
+ END;
+ args.phys_desc = phys_content.join(" ");
- args.contents = xml.findnodes('//*[@tag="505"]').textContent;
+ args.contents_list = [];
+ FOR sub IN xml.findnodes('//*[@tag="505"]');
+ args.contents_list.push(sub.textContent);
+ END;
+ args.contents = args.contents_list.join(" ");
+ args.content = (args.contents.size) ? args.contents.0 : '';
# MARC Callnumber
- args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
+ args.marc_cns = [];
+ FOR sub IN xml.findnodes('//*[@tag="092" or @tag="099"]/*');
+ args.marc_cns.push(sub.textContent);
+ END;
+ args.marc_cn = (args.marc_cns.size ) ? args.marc_cns.0 : '';
+
# clean up the ISBN
args.isbn_clean = args.isbns.0.replace('\ .*', '');
args.holdings = [];
args.uris = [];
args.issns = [];
+ args.resolver_isbns = [];
+ args.resolver_issns = [];
# we use $9 of ISBN and ISSN as a flag for e-version
- sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]');
- IF sfx_isbn;
- IF sfx_isbn.textContent == "SFX";
- my_parent = sfx_isbn.parentNode();
- sfx_isbn = my_parent.findnodes('./*[@code="a"]').textContent;
- sfx_isbn = sfx_isbn.replace('-', '');
- args.resolver_isbn = sfx_isbn.replace('\ .*', '');
+ FOR resolver_isbn IN xml.findnodes('//*[@tag="020"]/*[@code="9"]');
+ IF resolver_isbn.textContent == "SFX" || resolver_isbn.textContent == "CUFTS";
+ my_parent = resolver_isbn.parentNode();
+ FOR resolver_isbn_val IN my_parent.findnodes('./*[@code="a"]');
+ args.resolver_isbns.push(
+ resolver_isbn_val.textContent.replace('-', '').replace('\ .*', '')
+ );
+ END;
END;
END;
- sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]');
- IF sfx_issn;
- IF sfx_issn.textContent == "SFX";
- my_parent = sfx_issn.parentNode();
- sfx_issn = my_parent.findnodes('./*[@code="a"]');
- args.issns.push(
- sfx_issn.textContent.replace('[^\d\-X]', '')
- );
+ FOR resolver_issn IN xml.findnodes('//*[@tag="022"]/*[@code="9"]');
+ IF resolver_issn.textContent == "SFX" || resolver_issn.textContent == "CUFTS";
+ my_parent = resolver_issn.parentNode();
+ FOR resolver_issn_val IN my_parent.findnodes('./*[@code="a"]');
+ args.resolver_issns.push(
+ resolver_issn_val.textContent.replace('[^\d\-X]', '')
+ );
+ END;
END;
END;
- # we snag all issns if no SFX available
- IF args.issns.size == 0;
- FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
- args.issns.push(
- rawissn.textContent.replace('[^\d\-X]', '')
- );
- END;
+ # now snag all issns
+ FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
+ args.issns.push(
+ rawissn.textContent.replace('[^\d\-X]', '')
+ );
END;
FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
IF vol.label == '##URI##';
FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]');
+ res = {};
res.href = uri.getAttribute('href');
res.link = uri.getAttribute('label');
res.note = uri.getAttribute('use_restriction');
ELSE;
copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
FOR copy IN copies;
+ parts = copy.findnodes('./*[local-name()="monograph_parts"]/*[local-name()="monograph_part"]');
+ FOREACH part IN parts;
+ part_label = part.getAttribute('label');
+ LAST IF part_label != '';
+ END;
# Check copy visibility
cp.deleted = copy.getAttribute('deleted');
cp.visible = copy.getAttribute('opac_visible');
holding = {
label => vol.label,
+ part_label => part_label,
location => loc.textContent,
library => circlib.textContent,
status => status.textContent
barcode => copy.getAttribute('barcode')
};
args.holdings.push(holding);
+ part_label = '';
END;
END;
END;
FOR node IN xml.findnodes(xpath);
FOR attr IN ['count', 'available', 'unshadow', 'transcendant', 'org_unit'];
depth = node.getAttribute('depth');
+ org_unit = node.getAttribute('org_unit');
args.copy_counts.$depth.$attr = node.getAttribute(attr);
+ args.org_copy_counts.$org_unit.$attr = node.getAttribute(attr);
+ END;
+ END;
+
+ # Get preferred library copy count
+ args.plib_copy_counts = {};
+ count_type = 'pref_lib';
+ xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
+ FOR node IN xml.findnodes(xpath);
+ FOR attr IN ['count', 'available', 'unshadow', 'transcendant', 'org_unit'];
+ depth = node.getAttribute('depth');
+ args.plib_copy_counts.$depth.$attr = node.getAttribute(attr);
END;
END;
node = xml.findnodes(
'//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
IF node AND node.textContent;
+ type = node.textContent;
args.format_label = node.getAttribute('coded-value')
- args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';
+ args.schema.itemtype = schema_typemap.$type;
+ args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ type _ '.png';
LAST;
END;
END;
+
+ END;
+
+ # Get the library or location group
+ # get_library()
+ BLOCK get_library;
+ IF !loc_name;
+ loc_name = 'loc';
+ IF show_loc_groups; loc_name = 'locg'; END;
+ END;
+ IF !loc_value;
+ loc_value = CGI.param('loc') || ctx.search_ou;
+ IF show_loc_groups;
+ loc_value = CGI.param('locg') || ctx.search_ou;
+ END;
+ END;
END;
%]