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 # URI info is in volumes/volume/uris/volume, instead of uri element
65 FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
67 # Check volume visibility - could push this into XPath
68 vol.label = volume.getAttribute('label');
69 vol.id = volume.getAttribute('id');
70 NEXT IF volume.getAttribute('opac_visible') == 'false';
71 NEXT IF volume.getAttribute('deleted') == 'true';
73 IF vol.label == '##URI##';
74 FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="volume"]');
75 res.href = uri.getAttribute('href');
76 res.link = uri.getAttribute('label');
77 res.note = uri.getAttribute('use_restriction');
82 copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
84 # Check copy visibility
85 cp.deleted = copy.getAttribute('deleted');
86 cp.visible = copy.getAttribute('opac_visible');
87 NEXT IF (cp.deleted == 'true' OR cp.visible == 'false');
89 # Iterate through all of the children to determine visibility
90 FOR node IN cp.childNodes;
91 NEXT IF cp.visible == 'false';
92 vis = node.getAttribute('opac_visible');
93 del = node.getAttribute('deleted');
94 IF vis == 'false' or del == 'true';
99 NEXT IF cp.visible == 'false';
101 loc = copy.findnodes('./*[local-name()="location"]');
102 circlib = copy.findnodes('./*[local-name()="circlib"]');
103 status = copy.findnodes('./*[local-name()="status"]');
107 location => loc.textContent,
108 library => circlib.textContent,
109 status => status.textContent
110 barcode => copy.getAttribute('barcode')
112 args.holdings.push(holding);
117 # Extract the copy count summary
118 count_type = (ctx.is_staff) ? 'staff' : 'public';
119 xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
120 FOR node IN xml.findnodes(xpath);
121 args.copy_counts = {};
122 FOR attr IN ['count', 'available', 'unshadow', 'transcendant'];
123 args.copy_counts.$attr = node.getAttribute(attr);
127 # "mattype" == "custom marc format specifier"
128 FOR icon_style IN ['mattype', 'item_type'];
129 node = xml.findnodes(
130 '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
132 args.format_label = node.getAttribute('coded-value')
133 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';
139 BLOCK get_hold_status;
140 IF hold.hold.status == 4;
142 IF ahr.shelf_expire_time;
143 l('<br/>Expires [_1]',
144 date.format(ctx.parse_datetime(ahr.shelf_expire_time), DATE_FORMAT));
146 ELSIF hold.hold.estimated_wait AND hold.hold.estimated_wait > 0;
147 # estimated wait is delivered as seconds.
148 SET hwait = POSIX.ceil(hold.hold.estimated_wait / 86400);
149 l("Estimated wait: [quant,_1,day,days]", hwait);
150 ELSIF hold.hold.status == 3;
152 ELSIF hold.hold.status < 3;
153 l("Waiting for copy");