[% # Extract MARC fields from XML # get_marc_attrs( { marc_xml => doc } ) BLOCK get_marc_attrs; xml = args.marc_xml; args.isbn = xml.findnodes('//*[@tag="020"]/*[@code="a"]').shift.textContent; args.upc = xml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').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.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( '//*[@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(""); # MARC Callnumber args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent; # clean up the ISBN args.isbn_clean = args.isbn.replace('\ .*', ''); args.holdings = []; FOR holding IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); args.holdings.push( holding.getAttribute('label') ); END; # Extract the copy count summary count_type = (ctx.is_staff) ? 'staff' : 'public'; xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]'; FOR node IN xml.findnodes(xpath); args.copy_counts = {}; FOR attr IN ['count', 'available', 'unshadow', 'transcendant']; args.copy_counts.$attr = node.getAttribute(attr); END; END; # "mattype" == "custom marc format specifier" FOR icon_style IN ['mattype', 'item_type']; node = xml.findnodes( '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]'); IF node; args.format_label = node.getAttribute('coded-value') args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png'; LAST; END; END; END; BLOCK get_hold_status; IF hold.hold.status == 4; l("Available"); IF ahr.shelf_expire_time; l('
Expires [_1]', date.format(ctx.parse_datetime(ahr.shelf_expire_time), DATE_FORMAT)); END; ELSIF hold.hold.estimated_wait AND hold.hold.estimated_wait > 0; # estimated wait is delivered as seconds. SET hwait = POSIX.ceil(hold.hold.estimated_wait / 86400); l("Estimated wait: [quant,_1,day,days]", hwait); ELSIF hold.hold.status == 3; l("In Transit"); ELSIF hold.hold.status < 3; l("Waiting for copy"); END; END; %]