LP#1402905 Use stricter matching for UPC values
authorDan Scott <dscott@laurentian.ca>
Tue, 16 Dec 2014 04:23:49 +0000 (23:23 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 16 Dec 2014 20:37:00 +0000 (15:37 -0500)
Per http://www.loc.gov/marc/bibliographic/bd024.html we
should be checking to see if either the ind1 is "1" or
if there's a subfield 2 with a value of "upc" before
assuming that any "Other standard identifier" 024 field
is a UPC value.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/opac/parts/misc_util.tt2

index 32717b8..da7c958 100644 (file)
             args.isbns.push(isbn.textContent);
         END;
 
+        # UPCs can be identified either by ind1="1" or subfield 2 of "upc"
         args.upcs = [];
-        FOR upc IN xml.findnodes('//*[@tag="024"]/*[@code="a"]');
+        FOR upc IN xml.findnodes('//*[@tag="024" and @ind="1"]/*[@code="a"]');
             args.upcs.push(upc.textContent);
         END;
+        FOR upcfield IN xml.findnodes('//*[@tag="024"]/*[@code="2" and text()="upc"]');
+            my_parent = upcfield.parentNode();
+            FOR upc IN my_parent.findnodes('./*[@code="a"]');
+                args.upcs.push(upc.textContent);
+            END;
+        END;
         args.upc = args.upcs.0; # use first UPC as the default
 
         args.issns = [];