[open-ils-commits] r8029 -
trunk/Open-ILS/xul/staff_client/server/cat
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 7 09:59:21 EST 2007
Author: phasefx
Date: 2007-11-07 09:43:39 -0500 (Wed, 07 Nov 2007)
New Revision: 8029
Modified:
trunk/Open-ILS/xul/staff_client/server/cat/marc_view.html
Log:
some error handling
Modified: trunk/Open-ILS/xul/staff_client/server/cat/marc_view.html
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/marc_view.html 2007-11-07 14:09:23 UTC (rev 8028)
+++ trunk/Open-ILS/xul/staff_client/server/cat/marc_view.html 2007-11-07 14:43:39 UTC (rev 8029)
@@ -10,27 +10,41 @@
var xsltProcessor;
function xsl_marc2html_init() {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- xsltProcessor = new XSLTProcessor();
- var req = new XMLHttpRequest();
- req.open("GET", urls.xsl_marc2html, false);
- req.send(null);
- var xsl = req.responseXML;
- xsltProcessor.importStylesheet(xsl);
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ xsltProcessor = new XSLTProcessor();
+ var req = new XMLHttpRequest();
+ req.open("GET", urls.xsl_marc2html, false);
+ req.send(null);
+ if (req.status != 200) {
+ alert('We were unable to load ' + urls.xsl_marc2html + ' and thus cannot display the MARC here.\nReason: ' + req.statusText);
+ return false;
+ }
+ var xsl = req.responseXML;
+ xsltProcessor.importStylesheet(xsl);
+ return true;
+ } catch(E) {
+ alert('An error occured and we are unable to display the MARC here.\nError in xsl_marc2html_init: ' + E);
+ return false;
+ }
}
function apply_xsl_marc2html(marc) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var obj = this;
- var parser = new DOMParser();
- var doc = parser.parseFromString( marc, 'text/xml' );
- var node = doc.documentElement;
- var fragment = xsltProcessor.transformToFragment(node, document);
- document.body.appendChild(fragment);
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var obj = this;
+ var parser = new DOMParser();
+ var doc = parser.parseFromString( marc, 'text/xml' );
+ var node = doc.documentElement;
+ var fragment = xsltProcessor.transformToFragment(node, document);
+ document.body.appendChild(fragment);
+ } catch(E) {
+ alert('An error occured and we are unable to display the MARC here.\nError in apply_xsl_marc2html: ' + E);
+ }
}
function my_init() {
- xsl_marc2html_init();
+ if (!xsl_marc2html_init()) return;
document.body.innerHTML = "<button onclick='window.print()'>Print Page</button>";
if (typeof xulG != 'undefined' && xulG.marcxml) apply_xsl_marc2html(xulG.marcxml);
document.body.firstChild.focus();
More information about the open-ils-commits
mailing list