2 # Extract MARC fields from XML
3 # get_marc_attrs( { marc_xml => doc } )
6 args.isbn = xml.findnodes('//*[@tag="020"]/*[@code="a"]').shift.textContent;
7 args.upc = xml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
8 args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
9 args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
10 args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
11 args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
12 args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
13 args.edition = xml.findnodes('//*[@tag="250"]/*[@code="a"]').textContent ||
14 xml.findnodes('//*[@tag="534"]/*[@code="b"]').textContent ||
15 xml.findnodes('//*[@tag="775"]/*[@code="b"]').textContent;
17 '//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
20 FOR p IN phys; phys_content.push(p.textContent); END;
21 args.phys_desc = phys_content.join("");
24 args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
27 args.isbn_clean = args.isbn.replace('\ .*', '');
33 # we use $9 of ISBN and ISSN as a flag for e-version
34 sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]');
36 IF sfx_isbn.textContent == "SFX";
37 my_parent = sfx_isbn.parentNode();
38 sfx_isbn = my_parent.findnodes('./*[@code="a"]');
39 sfx_isbn.replace('-', '');
40 args.resolver_isbn = sfx_isbn.replace('\ .*', '');
44 sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]');
46 IF sfx_issn.textContent == "SFX";
47 my_parent = sfx_issn.parentNode();
48 sfx_issn = my_parent.findnodes('./*[@code="a"]');
50 sfx_issn.textContent.replace('[^\d\-X]', '')
55 # we snag all issns if no SFX available
56 IF args.issns.size == 0;
57 FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
59 rawissn.textContent.replace('[^\d\-X]', '')
64 FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
66 # Check volume visibility - could push this into XPath
67 vol.label = volume.getAttribute('label');
68 vol.id = volume.getAttribute('id');
69 NEXT IF volume.getAttribute('opac_visible') == 'false';
70 NEXT IF volume.getAttribute('deleted') == 'true';
72 IF vol.label == '##URI##';
73 FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]');
74 res.href = uri.getAttribute('href');
75 res.link = uri.getAttribute('label');
76 res.note = uri.getAttribute('use_restriction');
81 copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
83 # Check copy visibility
84 cp.deleted = copy.getAttribute('deleted');
85 cp.visible = copy.getAttribute('opac_visible');
86 NEXT IF (cp.deleted == 'true' OR cp.visible == 'false');
88 # Iterate through all of the children to determine visibility
89 FOR node IN cp.childNodes;
90 NEXT IF cp.visible == 'false';
91 vis = node.getAttribute('opac_visible');
92 del = node.getAttribute('deleted');
93 IF vis == 'false' or del == 'true';
98 NEXT IF cp.visible == 'false';
100 loc = copy.findnodes('./*[local-name()="location"]');
101 circlib = copy.findnodes('./*[local-name()="circlib"]');
102 status = copy.findnodes('./*[local-name()="status"]');
106 location => loc.textContent,
107 library => circlib.textContent,
108 status => status.textContent
109 barcode => copy.getAttribute('barcode')
111 args.holdings.push(holding);
116 # Extract the copy count summary
117 count_type = (ctx.is_staff) ? 'staff' : 'public';
118 xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
119 FOR node IN xml.findnodes(xpath);
120 args.copy_counts = {};
121 FOR attr IN ['count', 'available', 'unshadow', 'transcendant'];
122 args.copy_counts.$attr = node.getAttribute(attr);
126 # "mattype" == "custom marc format specifier"
127 FOR icon_style IN ['mattype', 'item_type'];
128 node = xml.findnodes(
129 '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
131 args.format_label = node.getAttribute('coded-value')
132 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';
138 BLOCK get_hold_status;
139 IF hold.hold.status == 4;
141 IF ahr.shelf_expire_time;
142 l('<br/>Expires [_1]',
143 date.format(ctx.parse_datetime(ahr.shelf_expire_time), DATE_FORMAT));
145 ELSIF hold.hold.estimated_wait AND hold.hold.estimated_wait > 0;
146 # estimated wait is delivered as seconds.
147 SET hwait = POSIX.ceil(hold.hold.estimated_wait / 86400);
148 l("Estimated wait: [quant,_1,day,days]", hwait);
149 ELSIF hold.hold.status == 3;
151 ELSIF hold.hold.status < 3;
152 l("Waiting for copy");