mehmetc / jQuery.PRIMO

A client side convenience library for PRIMO.
MIT License
27 stars 8 forks source link

problem on source records without xmlns #7

Closed uleodolter closed 8 years ago

uleodolter commented 8 years ago

source records without xmlns are not rendered into html, the proposed patch below adds xmlns MARC21 before convertXML2HTML is called. this works especially for records which are loaded from SFX. the patch also passes the sourceformat to the template.

--- librariansWB.html.git   2016-05-23 20:15:12.806200665 +0200
+++ librariansWB.html   2016-05-24 10:18:48.689681731 +0200
@@ -122,7 +122,7 @@
     <script type="text/template" id="libWB-tpl">
         <div>
             <h1>Record : {{ recordId }}</h1>
-            <h2>PNX | Source XML | MARC</h2>
+            <h2>PNX | Source XML | {{ sourceformat }}</h2>

             <div>
                 <iframe class="pnxdata" src='/primo_library/libweb/jqp/record/{{ recordId }}.pnx'></iframe>
@@ -295,6 +295,7 @@
                     //Render template
                     $('body').append(jQuery.PRIMO.template.renderById("libWB-tpl", {
                         recordId: recordId,
+                        sourceformat: record.control.sourceformat,
                         ilsurl: ''
                     }));

@@ -305,6 +306,9 @@
                         switch (record.control.sourceformat.toLowerCase()) {
                             case 'marc21':
                             case 'aleph':
+                                $("#xml").html(function(index,html){
+                                    return html.replace('<record>','<record xmlns="http://www.loc.gov/MARC21/slim">');
+                                });
                                 $('#data').append(convertXML2HTML("#xml", '#pretty_marc'));
                                 break;
                             case 'mab':
mehmetc commented 8 years ago

Ulrich I've incorporated your changes into the August release. Next step is to add ILS record support.