2 # Extract MARC fields from XML
3 # get_marc_attrs( { marc_xml => doc } )
7 FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]');
8 args.isbns.push(isbn.textContent);
11 FOR upc IN xml.findnodes('//*[@tag="024"]/*[@code="a"]');
12 args.upcs.push(upc.textContent);
14 args.upc = args.upcs.0; # use first UPC as the default
15 args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
16 args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
17 args.title_extended = xml.findnodes('//*[@tag="245"]').textContent;
18 args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
19 args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
20 args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
21 args.summary = xml.findnodes('//*[@tag="520"]/*[@code="a"]').textContent;
22 args.edition = xml.findnodes('//*[@tag="250"]/*[@code="a"]').textContent ||
23 xml.findnodes('//*[@tag="534"]/*[@code="b"]').textContent ||
24 xml.findnodes('//*[@tag="775"]/*[@code="b"]').textContent;
26 '//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
29 FOR p IN phys; phys_content.push(p.textContent); END;
30 args.phys_desc = phys_content.join("");
32 args.contents = xml.findnodes('//*[@tag="505"]').textContent;
35 args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
38 args.isbn_clean = args.isbns.0.replace('\ .*', '');
44 # we use $9 of ISBN and ISSN as a flag for e-version
45 sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]');
47 IF sfx_isbn.textContent == "SFX";
48 my_parent = sfx_isbn.parentNode();
49 sfx_isbn = my_parent.findnodes('./*[@code="a"]').textContent;
50 sfx_isbn = sfx_isbn.replace('-', '');
51 args.resolver_isbn = sfx_isbn.replace('\ .*', '');
55 sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]');
57 IF sfx_issn.textContent == "SFX";
58 my_parent = sfx_issn.parentNode();
59 sfx_issn = my_parent.findnodes('./*[@code="a"]');
61 sfx_issn.textContent.replace('[^\d\-X]', '')
66 # we snag all issns if no SFX available
67 IF args.issns.size == 0;
68 FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
70 rawissn.textContent.replace('[^\d\-X]', '')
75 FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
77 # Check volume visibility - could push this into XPath
78 vol.label = volume.getAttribute('label');
79 vol.id = volume.getAttribute('id');
80 NEXT IF volume.getAttribute('opac_visible') == 'false';
81 NEXT IF volume.getAttribute('deleted') == 'true';
83 IF vol.label == '##URI##';
84 FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]');
85 res.href = uri.getAttribute('href');
86 res.link = uri.getAttribute('label');
87 res.note = uri.getAttribute('use_restriction');
92 copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
94 # Check copy visibility
95 cp.deleted = copy.getAttribute('deleted');
96 cp.visible = copy.getAttribute('opac_visible');
97 NEXT IF (cp.deleted == 'true' OR cp.visible == 'false');
99 # Iterate through all of the children to determine visibility
100 FOR node IN cp.childNodes;
101 NEXT IF cp.visible == 'false';
102 vis = node.getAttribute('opac_visible');
103 del = node.getAttribute('deleted');
104 IF vis == 'false' or del == 'true';
105 cp.visible = 'false';
109 NEXT IF cp.visible == 'false';
111 loc = copy.findnodes('./*[local-name()="location"]');
112 circlib = copy.findnodes('./*[local-name()="circlib"]');
113 status = copy.findnodes('./*[local-name()="status"]');
117 location => loc.textContent,
118 library => circlib.textContent,
119 status => status.textContent
120 barcode => copy.getAttribute('barcode')
122 args.holdings.push(holding);
127 # Extract the copy count summary
128 count_type = (ctx.is_staff) ? 'staff' : 'public';
129 xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
130 FOR node IN xml.findnodes(xpath);
131 args.copy_counts = {};
132 FOR attr IN ['count', 'available', 'unshadow', 'transcendant'];
133 args.copy_counts.$attr = node.getAttribute(attr);
137 # "mattype" == "custom marc format specifier"
138 FOR icon_style IN ['mattype', 'item_type'];
139 node = xml.findnodes(
140 '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
141 IF node AND node.textContent;
142 args.format_label = node.getAttribute('coded-value')
143 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';