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);
10 args.upc = xml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
11 args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
12 args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
13 args.title_extended = xml.findnodes('//*[@tag="245"]').textContent;
14 args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
15 args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
16 args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
17 args.summary = xml.findnodes('//*[@tag="520"]/*[@code="a"]').textContent;
18 args.edition = xml.findnodes('//*[@tag="250"]/*[@code="a"]').textContent ||
19 xml.findnodes('//*[@tag="534"]/*[@code="b"]').textContent ||
20 xml.findnodes('//*[@tag="775"]/*[@code="b"]').textContent;
22 '//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
25 FOR p IN phys; phys_content.push(p.textContent); END;
26 args.phys_desc = phys_content.join("");
28 args.contents = xml.findnodes('//*[@tag="505"]').textContent;
31 args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
34 args.isbn_clean = args.isbns.0.replace('\ .*', '');
40 # we use $9 of ISBN and ISSN as a flag for e-version
41 sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]');
43 IF sfx_isbn.textContent == "SFX";
44 my_parent = sfx_isbn.parentNode();
45 sfx_isbn = my_parent.findnodes('./*[@code="a"]').textContent;
46 sfx_isbn = sfx_isbn.replace('-', '');
47 args.resolver_isbn = sfx_isbn.replace('\ .*', '');
51 sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]');
53 IF sfx_issn.textContent == "SFX";
54 my_parent = sfx_issn.parentNode();
55 sfx_issn = my_parent.findnodes('./*[@code="a"]');
57 sfx_issn.textContent.replace('[^\d\-X]', '')
62 # we snag all issns if no SFX available
63 IF args.issns.size == 0;
64 FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
66 rawissn.textContent.replace('[^\d\-X]', '')
71 FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
73 # Check volume visibility - could push this into XPath
74 vol.label = volume.getAttribute('label');
75 vol.id = volume.getAttribute('id');
76 NEXT IF volume.getAttribute('opac_visible') == 'false';
77 NEXT IF volume.getAttribute('deleted') == 'true';
79 IF vol.label == '##URI##';
80 FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]');
81 res.href = uri.getAttribute('href');
82 res.link = uri.getAttribute('label');
83 res.note = uri.getAttribute('use_restriction');
88 copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
90 # Check copy visibility
91 cp.deleted = copy.getAttribute('deleted');
92 cp.visible = copy.getAttribute('opac_visible');
93 NEXT IF (cp.deleted == 'true' OR cp.visible == 'false');
95 # Iterate through all of the children to determine visibility
96 FOR node IN cp.childNodes;
97 NEXT IF cp.visible == 'false';
98 vis = node.getAttribute('opac_visible');
99 del = node.getAttribute('deleted');
100 IF vis == 'false' or del == 'true';
101 cp.visible = 'false';
105 NEXT IF cp.visible == 'false';
107 loc = copy.findnodes('./*[local-name()="location"]');
108 circlib = copy.findnodes('./*[local-name()="circlib"]');
109 status = copy.findnodes('./*[local-name()="status"]');
113 location => loc.textContent,
114 library => circlib.textContent,
115 status => status.textContent
116 barcode => copy.getAttribute('barcode')
118 args.holdings.push(holding);
123 # Extract the copy count summary
124 count_type = (ctx.is_staff) ? 'staff' : 'public';
125 xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
126 FOR node IN xml.findnodes(xpath);
127 args.copy_counts = {};
128 FOR attr IN ['count', 'available', 'unshadow', 'transcendant'];
129 args.copy_counts.$attr = node.getAttribute(attr);
133 # "mattype" == "custom marc format specifier"
134 FOR icon_style IN ['mattype', 'item_type'];
135 node = xml.findnodes(
136 '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
137 IF node AND node.textContent;
138 args.format_label = node.getAttribute('coded-value')
139 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';