JBAS-769 data sanity check; add 245p
authorBill Erickson <berickxx@gmail.com>
Thu, 20 Aug 2015 04:56:54 +0000 (21:56 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Don't assume the nodes below a MARC tag are element nodes.
Apparently, in some cases, they were text nodes or possibly
some other node type.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/opac/extras/circ/alt_holds_print.js

index 21e8971..20d109e 100644 (file)
@@ -11,6 +11,7 @@ function get_marc_bits(marcxml) {
     var m100c = '';
     var m245a = '';
     var m245b = '';
+    var m245p = '';
 
     var xmlDoc = new DOMParser().parseFromString(marcxml, 'text/xml');
 
@@ -20,15 +21,20 @@ function get_marc_bits(marcxml) {
             var tag = node.getAttribute('tag');
             if (tag == '100') {
                 dojo.forEach(node.childNodes, function(sub_node) {
-                    var code = sub_node.getAttribute('code');
-                    if (code == 'a') m100a = sub_node.textContent;
-                    if (code == 'c') m100c = sub_node.textContent;
+                    if (sub_node.nodeType == Node.ELEMENT_NODE) {
+                        var code = sub_node.getAttribute('code');
+                        if (code == 'a') m100a = sub_node.textContent;
+                        if (code == 'c') m100c = sub_node.textContent;
+                    }
                 });
             } else if (tag == '245') {
                 dojo.forEach(node.childNodes, function(sub_node) {
-                    var code = sub_node.getAttribute('code');
-                    if (code == 'a') m245a = sub_node.textContent;
-                    if (code == 'b') m245b = sub_node.textContent;
+                    if (sub_node.nodeType == Node.ELEMENT_NODE) {
+                        var code = sub_node.getAttribute('code');
+                        if (code == 'a') m245a = sub_node.textContent;
+                        if (code == 'b') m245b = sub_node.textContent;
+                        if (code == 'p') m245p = sub_node.textContent;
+                    }
                 });
             }
         }
@@ -36,7 +42,7 @@ function get_marc_bits(marcxml) {
 
     return {
         author : m100a + ' ' + m100c,
-        title : m245a + ' ' + m245b
+        title : m245a + ' ' + m245b + ' ' + m245p
     };
 }