LP#1312308 script circ and deps removal
authorBill Erickson <berickxx@gmail.com>
Wed, 13 May 2015 17:14:21 +0000 (13:14 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 1 Jul 2015 14:51:23 +0000 (10:51 -0400)
* Remove libjs and spidermonkey from prereq installer
* Remove references to spidermonkey and script runner
* Remove stock JS circ and catalog scripts

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>

45 files changed:
Makefile.am
Open-ILS/examples/json-request-test.pl [deleted file]
Open-ILS/examples/opensrf.xml.example
Open-ILS/src/Makefile.am
Open-ILS/src/extras/Makefile.install
Open-ILS/src/extras/install/Makefile.common
Open-ILS/src/extras/install/Makefile.debian
Open-ILS/src/extras/install/Makefile.debian-jessie
Open-ILS/src/extras/install/Makefile.debian-squeeze
Open-ILS/src/extras/install/Makefile.debian-wheezy
Open-ILS/src/extras/install/Makefile.fedora
Open-ILS/src/extras/install/Makefile.ubuntu-precise
Open-ILS/src/extras/install/Makefile.ubuntu-trusty
Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js [deleted file]
Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js [deleted file]
Open-ILS/src/javascript/backend/catalog/fixed_fields.js [deleted file]
Open-ILS/src/javascript/backend/catalog/phys_char.js [deleted file]
Open-ILS/src/javascript/backend/catalog/record_type.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_duration.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_groups.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_item_config.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_lib.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_permit_copy.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_permit_hold.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_permit_patron.js [deleted file]
Open-ILS/src/javascript/backend/circ/circ_permit_renew.js [deleted file]
Open-ILS/src/javascript/backend/libs/jsDOM.js [deleted file]
Open-ILS/src/javascript/backend/libs/jsOO.js [deleted file]
Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js [deleted file]
Open-ILS/src/javascript/backend/libs/xmlhttprequest.js [deleted file]
Open-ILS/src/javascript/backend/libs/xpath.js [deleted file]
Open-ILS/src/javascript/backend/penalty/patron_penalty.js [deleted file]
Open-ILS/src/javascript/backend/test/xmlhttprequest-test.js [deleted file]
Open-ILS/src/perlmods/Build.PL
Open-ILS/src/perlmods/MANIFEST
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/ScriptBuilder.pm [deleted file]
Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/PermitHold.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/ScriptRunner.pm [deleted file]
Open-ILS/src/perlmods/lib/OpenILS/Utils/SpiderMonkey.pm [deleted file]
Open-ILS/src/perlmods/t/05-OpenILS-Application-Circ.t
Open-ILS/src/perlmods/t/14-OpenILS-Utils.t
Open-ILS/src/support-scripts/settings-tester.pl
Open-ILS/src/support-scripts/test-scripts/circ_rules.pl [deleted file]

index 9aeb9ed..51b512c 100644 (file)
@@ -18,9 +18,6 @@ export TEMPLATEDIR=@localstatedir@/templates
 export UPDATESDIR=@localstatedir@/updates
 
 export datadir=@localstatedir@/data
-export circrulesdir=@localstatedir@/circ
-export catalogscriptdir=@localstatedir@/catalog
-export penaltyrulesdir=@localstatedir@/penalty
 export XSLDIR=@localstatedir@/xsl
 export REPORTERDIR=@localstatedir@/reporter
 export SOCK=@localstatedir@/lock
diff --git a/Open-ILS/examples/json-request-test.pl b/Open-ILS/examples/json-request-test.pl
deleted file mode 100755 (executable)
index edafb1c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-use lib '../src/perlmods/lib/';
-use lib '../src/perlmods/lib/OpenILS/Utils/';
-
-use OpenSRF::Utils::JSON;
-use OpenSRF::System;
-use OpenILS::Utils::ScriptRunner;
-use OpenSRF::Utils::Logger;
-use OpenSRF::Utils::SettingsClient;
-use OpenSRF::EX qw(:try);
-use Fieldmapper (IDL => 'fm_IDL.xml');
-
-unless (@ARGV > 1) {
-       print <<USAGE;
-Usage: $0 /openils-root-dir script.js
-USAGE
-}
-
-my $root = shift(@ARGV);
-
-OpenSRF::System->bootstrap_client( config_file => $root.'/conf/opensrf_core.xml');
-
-try {
-        OpenILS::Utils::ScriptRunner->add_path($root.'/var/web/opac/common/js/');
-        OpenILS::Utils::ScriptRunner->add_path('../src/javascript/backend/libs/');
-        OpenILS::Utils::ScriptRunner->add_path('./');
-
-       print OpenSRF::Utils::JSON->perl2JSON( OpenILS::Utils::ScriptRunner->new( file => shift(@ARGV) )->run );
-       #print OpenSRF::Utils::JSON->perl2JSON( OpenILS::Utils::ScriptRunner->new->run( shift(@ARGV) ) );
-
-} otherwise {
-        warn 'crap:'.shift();
-};
-
index dd7667a..c7994db 100644 (file)
@@ -849,22 +849,6 @@ vim:et:ts=4:sw=4:
                     <notify_hold>
                         <email>false</email> <!-- set to false to disable hold notice emails -->
                     </notify_hold>
-
-                    <!-- circulation policy scripts -->
-                    <script_path>LIBDIR/javascript</script_path>
-                    <script_path>LOCALSTATEDIR</script_path>
-                    <script_path>LOCALSTATEDIR/catalog</script_path>
-                    <legacy_script_support>false</legacy_script_support>
-                    <scripts> 
-                        <circ_permit_patron>circ/circ_permit_patron.js</circ_permit_patron>
-                        <circ_permit_copy>circ/circ_permit_copy.js</circ_permit_copy>
-                        <circ_duration>circ/circ_duration.js</circ_duration>
-                        <circ_recurring_fines>circ/circ_recurring_fines.js</circ_recurring_fines>
-                        <circ_max_fines>circ/circ_max_fines.js</circ_max_fines>
-                        <circ_permit_renew>circ/circ_permit_renew.js</circ_permit_renew>
-                        <circ_permit_hold>circ/circ_permit_hold.js</circ_permit_hold>
-                    </scripts>               
-
                 </app_settings>
             </open-ils.circ>
 
index 07d90f9..4e62684 100644 (file)
@@ -24,11 +24,7 @@ export DEF_LDLIBS = -lopensrf
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 datadir=@localstatedir@/data
-circrulesdir=@localstatedir@/circ
-catalogscriptdir=@localstatedir@/catalog
-penaltyrulesdir=@localstatedir@/penalty
 examples = @top_srcdir@/Open-ILS/examples
-jsbackend = @srcdir@/javascript/backend
 supportscr = @srcdir@/support-scripts
 
 # Collect files to be used by multiple targets
@@ -80,22 +76,6 @@ core_scripts =   $(examples)/oils_ctl.sh \
 
 installautojs = $(autojsbinscripts)
 
-#circ-rules-install
-circrules_SCRIPTS = $(jsbackend)/circ/circ_duration.js \
-                   $(jsbackend)/circ/circ_groups.js \
-                   $(jsbackend)/circ/circ_item_config.js \
-                   $(jsbackend)/circ/circ_lib.js \
-                   $(jsbackend)/circ/circ_permit_copy.js \
-                   $(jsbackend)/circ/circ_permit_hold.js \
-                   $(jsbackend)/circ/circ_permit_patron.js \
-                   $(jsbackend)/circ/circ_permit_renew.js 
-penaltyrules_SCRIPTS = $(jsbackend)/penalty/patron_penalty.js
-catalogscript_SCRIPTS = $(jsbackend)/catalog/biblio_descriptor.js \
-                       $(jsbackend)/catalog/biblio_fingerprint.js \
-                       $(jsbackend)/catalog/fixed_fields.js \
-                       $(jsbackend)/catalog/phys_char.js \
-                       $(jsbackend)/catalog/record_type.js
-
 endif
 
 #--------------------
index 54c5460..3356b9f 100644 (file)
@@ -7,7 +7,7 @@
 # Currently supports Debian (jessie, wheezy, squeeze), Ubuntu (12.04), 
 # Ubuntu (14.04) and Fedora (16 and 17).
 #
-# Installs Perl prereqs, libjs with Perl wrapper, libdbi, libdbi-drivers, and libyaz
+# Installs Perl prereqs, libdbi, libdbi-drivers, and libyaz
 #
 # usage:
 #      make -f Makefile.install debian-jessie
 # Make any assumptions about the shell being used explicit
 export SHELL=/bin/bash 
 
-export LIBJS=js-1.7.0
-export LIBJS_PERL=JavaScript-SpiderMonkey-0.21
-export LIBJS_URL=http://ftp.mozilla.org/pub/mozilla.org/js/$(LIBJS).tar.gz
-export LIBJS_PERL_URL=http://mirror.datapipe.net/pub/CPAN/authors/id/T/TB/TBUSCH/$(LIBJS_PERL).tar.gz
-
-# used for installing libjs lib and header files
-export JS_INSTALL_PREFIX=/usr/
-
 export LIBNET_Z3950_SIMPLESERVER=Net-Z3950-SimpleServer-1.15
 export LIBNET_Z3950_SIMPLESERVER_URL=http://ftp.indexdata.dk/pub/simpleserver/$(LIBNET_Z3950_SIMPLESERVER)
 
index d3bdd54..ecfdb8f 100644 (file)
@@ -40,6 +40,5 @@ install_nodejs_from_source:
 clean:
        make -C $(LIBDBI) clean
        make -C $(LIBDBI_DRIVERS) clean
-       make -C $(LIBJS_PERL) clean
 
 # vim:noet:sw=4:ts=4:
index 4c0ee13..495cdb2 100644 (file)
@@ -5,27 +5,6 @@ APT_TOOL=apt-get -yq
 install_debs:
        $(APT_TOOL) install $(DEBS)
 
-# Install the custom spidermonkey libs and JavaScript-SpiderMonkey Perl modules
-install_js_sm: install_libjs install_spidermonkey
-
-install_libjs: 
-       if [ ! -f $(LIBJS).tar.gz ]; then wget $(LIBJS_URL); fi;
-       tar -zxf $(LIBJS).tar.gz
-       cd js/src/ && JS_DIST=/usr make -f Makefile.ref
-       mkdir -p $(JS_INSTALL_PREFIX)/include/js/
-       cp js/src/*.h $(JS_INSTALL_PREFIX)/include/js/
-       cp js/src/*.tbl $(JS_INSTALL_PREFIX)/include/js/
-       cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib/
-       cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib/
-       ldconfig
-
-
-install_spidermonkey:
-       if [ ! -f $(LIBJS_PERL).tar.gz ]; then wget $(LIBJS_PERL_URL); fi
-       tar -zxf $(LIBJS_PERL).tar.gz
-       cd $(LIBJS_PERL) && perl Makefile.PL -E4X \
-               && make && make test && make install
-
 # On Ubuntu and possibly Debian, the libdbi0 package prevents the 
 # compiled-from-source version from being used and breaks the install.
 # This package might get installed depending on the install-time choices
@@ -52,7 +31,6 @@ debian_sys_config:
        ldconfig
 
 clean:
-       make -f Makefile.ref -C js/src/ clean
-
+       echo "cleaning"
 
 # vim:noet:sw=4:ts=4:
index 1938237..4be4c2c 100644 (file)
@@ -131,7 +131,6 @@ all:
        make -f $(DIR)/Makefile.debian install_debs
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
-       make -f $(DIR)/Makefile.debian install_js_sm
        make -f $(DIR)/Makefile.debian debian_sys_config
 
 install_postgres_server:
index f7e596c..8206743 100644 (file)
@@ -101,7 +101,6 @@ all: install_pgsql_client_backport_debs_91 install_yaz
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
        make -f $(DIR)/Makefile.common install_libdbi
-       make -f $(DIR)/Makefile.debian install_js_sm
        make -f $(DIR)/Makefile.debian debian_sys_config
 
 install_yaz:
index 9720e30..ecc3702 100644 (file)
@@ -125,7 +125,6 @@ all:
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
        make -f $(DIR)/Makefile.common install_libdbi
-       make -f $(DIR)/Makefile.debian install_js_sm
        make -f $(DIR)/Makefile.debian debian_sys_config
 
 install_postgres_server:
index f2d83c2..b80b93f 100644 (file)
@@ -92,7 +92,7 @@ PGSQL_FEDORA_RPMS = \
        postgresql-plperl \
        postgresql-server
 
-all: install_fedora_rpms install_js_sm
+all: install_fedora_rpms
        make -f $(DIR)/Makefile.common install_net_z3950_simpleserver
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
@@ -104,36 +104,6 @@ install_fedora_rpms:
        yum -y update
        yum -y install $(FEDORA_RPMS)
 
-install_js_sm: install_libjs install_spidermonkey
-
-install_libjs: 
-       if [ ! -f $(LIBJS).tar.gz ]; then wget $(LIBJS_URL); fi;
-       tar -zxf $(LIBJS).tar.gz
-       cd js/src/ && JS_DIST=/usr make -f Makefile.ref
-       mkdir -p $(JS_INSTALL_PREFIX)/include/js/
-       cp js/src/*.h $(JS_INSTALL_PREFIX)/include/js/
-       cp js/src/*.tbl $(JS_INSTALL_PREFIX)/include/js/
-       if [ ! -z $(FEDORA_64) ]; then \
-               cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib64/ && \
-               cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib64/; \
-       else \
-               cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib/ && \
-               cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib/; \
-       fi;
-       ldconfig
-
-install_spidermonkey:
-       if [ ! -f $(LIBJS_PERL).tar.gz ]; then wget $(LIBJS_PERL_URL); fi;
-       tar -zxf $(LIBJS_PERL).tar.gz
-       if [ ! -z $(FEDORA_64) ]; then \
-               sed -i -e 's/"\/usr\/lib"/"\/usr\/lib64"/' $(LIBJS_PERL)/Makefile.PL ; \
-       fi;
-       if [ ! -z $(FEDORA) ]; then \
-               sed -i -e 's/js32.dll/libjs.so/' $(LIBJS_PERL)/Makefile.PL ; \
-       fi;
-       cd $(LIBJS_PERL) && perl Makefile.PL -E4X && make && make test && make install
-
-
 clean:
        make -f $(DIR)/Makefile.common clean
 
index 86a939a..0ac0a9a 100644 (file)
@@ -128,7 +128,6 @@ all:
        make -f $(DIR)/Makefile.debian test_for_libdbi_pkg
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
-       make -f $(DIR)/Makefile.debian install_js_sm
        make -f $(DIR)/Makefile.debian debian_sys_config
 
 install_postgres_server:
index a8a7d52..49e0e77 100644 (file)
@@ -136,7 +136,6 @@ all:
        make -f $(DIR)/Makefile.debian test_for_libdbi_pkg
        make -f $(DIR)/Makefile.common install_cpan
        make -f $(DIR)/Makefile.common install_cpan_force
-       make -f $(DIR)/Makefile.debian install_js_sm
        make -f $(DIR)/Makefile.debian debian_sys_config
 
 install_postgres_server:
diff --git a/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js b/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js
deleted file mode 100644 (file)
index 1c1d195..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// so we can tell if it's a book or other type
-load_lib('fmall.js');
-load_lib('fmgen.js');
-load_lib('record_type.js');
-load_lib('JSON_v1.js');
-
-var marcdoc = new XML(environment.marc);
-var marc_ns = new Namespace('http://www.loc.gov/MARC21/slim');
-
-default xml namespace = marc_ns;
-
-environment.result = new mrd();
-
-environment.result.item_type( extractFixedField( marcdoc, 'Type' ) );
-environment.result.item_form( extractFixedField( marcdoc, 'Form' ) );
-environment.result.bib_level( extractFixedField( marcdoc, 'BLvl' ) );
-environment.result.control_type( extractFixedField( marcdoc, 'Ctrl' ) );
-environment.result.enc_level( extractFixedField( marcdoc, 'ELvl' ) );
-environment.result.audience( extractFixedField( marcdoc, 'Audn' ) );
-environment.result.lit_form( extractFixedField( marcdoc, 'LitF' ) );
-environment.result.type_mat( extractFixedField( marcdoc, 'TMat' ) );
-environment.result.cat_form( extractFixedField( marcdoc, 'Desc' ) );
-environment.result.pub_status( extractFixedField( marcdoc, 'DtSt' ) );
-environment.result.item_lang( extractFixedField( marcdoc, 'Lang' ) );
-environment.result.date1( extractFixedField( marcdoc, 'Date1' ) );
-environment.result.date2( extractFixedField( marcdoc, 'Date2' ) );
-
-environment.result.vr_format( videorecordingFormatCode( marcdoc ) );
-
diff --git a/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js b/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js
deleted file mode 100644 (file)
index 83992c2..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-// so we can tell if it's a book or other type
-load_lib('record_type.js');
-load_lib('JSON_v1.js');
-
-environment.result = {};
-
-var marcdoc = new XML(environment.marc);
-var marc_ns = new Namespace('http://www.loc.gov/MARC21/slim');
-
-var modsdoc = new XML(environment.mods);
-var mods_ns = new Namespace('http://www.loc.gov/mods/');
-default xml namespace = marc_ns;
-
-//var mods3_ns = new Namespace('http://www.loc.gov/mods/v3');
-
-
-var rtype = recordType(marcdoc); // BKS, SER, VIS, MIX, MAP, SCO, REC, COM
-
-var quality = 0;
-var t = '';
-var a = '';
-
-try {
-       // first, related items entries (700t)
-       var t = marcdoc.datafield.( @tag == '700' ).subfield.( @code == 't');
-       if (!t.length()) throw "No title in related item added entry (700)";
-       
-       a = t.parent().subfield.( @code == 'a' );
-
-       quality += 10;
-
-       log_debug("title: " + t);
-       log_debug("author: " + a);
-} catch(e) {
-       log_debug(e);
-       log_debug("Looking in main entries");
-
-       var _t = '';
-       try {
-               try { 
-                       try { // uniform title
-                               _t = marcdoc.datafield.( @tag == '240' ).subfield.( @code == 'a' );
-                               if (!_t.length()) throw "No title in 240";
-                       } catch(e) { // translation of title
-                               log_debug(e);
-                               _t = marcdoc.datafield.( @tag == '242' ).subfield.( @code == 'a' );
-                               if (!_t.length()) throw "No title in 242";
-                       }
-               } catch(e) { // alternate title (not as note) 
-                       log_debug(e);
-                       _t = marcdoc.datafield.( @tag == '246' && !(@ind1.match(/0|1/)) ).subfield.( @code == 'a' );
-                       if (!_t.length()) throw "No title in 246";
-               }
-
-               t = _t[0];
-               log_debug("Title: " + t);
-               quality += 25;
-
-       } catch(e) {
-               log_debug(e);
-               log_debug("Using title proper (245a)");
-               t = marcdoc.datafield.( @tag == '245' ).subfield.( @code == 'a' );
-               t = t[0];
-               quality += 10;
-       }
-
-       try {
-               var _a = marcdoc.datafield.( @tag == '100' || @tag == '110' || @tag == '111').subfield.( @code == 'a' );
-               if (!_a.length()) throw "No author in 100, 110, 111";
-               
-               a = _a[0];
-               log_debug("Author: " + a);
-
-       } catch(e) {
-               log_debug(e);
-               log_debug("Trying to find a publisher (260b)");
-               a = marcdoc.datafield.( @tag == '260' ).subfield.( @code == 'b' );
-               a = a[0];
-       }
-}
-
-if (rtype != 'BKS') {
-       quality += marcdoc.datafield.length() / 2;
-} else {
-       quality += 40 + marcdoc.datafield.length();
-}
-
-var title = t;
-if (!title) {
-       log_debug("no title found");
-       title = '';
-} else {
-       title = title.toString();
-}
-
-title = title
-       .toLowerCase()
-       .replace(/\[.+?\]/,'')
-       .replace(/\bthe\b|\ban?d?\b|\W+/g,'');
-
-
-var author = a;
-if (!author) {
-       author = '';
-} else {
-       author = author.toString();
-}
-
-author = author.toLowerCase().replace(/^\s*(\w+).*?$/,"$1");
-
-environment.result.fingerprint = title + author;
-
-if (marcdoc.datafield.(@tag == '040').subfield.(@code == 'a').toString().match(/DLC/)) {
-       quality += 5;
-       log_debug( 'got DLC bump' );
-}
-
-if (marcdoc.datafield.(@tag == '039').subfield.(@code == 'b').toString().match(/oclc/i)) {
-       quality += 10;
-       log_debug( 'got OCLC source bump' );
-       
-} else if (marcdoc.datafield.(@tag == '039').subfield.(@code == 'b').toString().match(/isxn/i)) {
-       quality += 5;
-       log_debug( 'got ISxN source bump' );
-       
-} else if (marcdoc.datafield.(@tag == '039').subfield.(@code == 'b').toString().match(/local/i)) {
-       quality += 1;
-       log_debug( 'got Local source bump' );
-}
-
-if (extractFixedField(marcdoc, 'Lang') == 'eng') {
-       quality += 100;
-       log_debug( 'got language bump for ' + extractFixedField(marcdoc, 'Lang') );
-}
-
-
-environment.result.quality = quality;
-
diff --git a/Open-ILS/src/javascript/backend/catalog/fixed_fields.js b/Open-ILS/src/javascript/backend/catalog/fixed_fields.js
deleted file mode 100644 (file)
index 90856bb..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-
-var rec_type = {
-    BKS : { Type : /[at]{1}/,    BLvl : /[acdm]{1}/ },
-    SER : { Type : /[a]{1}/,    BLvl : /[bsi]{1}/ },
-    VIS : { Type : /[gkro]{1}/,    BLvl : /[abcdmsi]{1}/ },
-    MIX : { Type : /[p]{1}/,    BLvl : /[cdi]{1}/ },
-    MAP : { Type : /[ef]{1}/,    BLvl : /[abcdmsi]{1}/ },
-    SCO : { Type : /[cd]{1}/,    BLvl : /[abcdmsi]{1}/ },
-    REC : { Type : /[ij]{1}/,    BLvl : /[abcdmsi]{1}/ },
-    COM : { Type : /[m]{1}/,    BLvl : /[abcdmsi]{1}/ },
-    AUT : { Type : /[z]{1}/,    BLvl : /.{1}/ },
-    MFHD : { Type : /[uvxy]{1}/,  BLvl : /.{1}/ }
-};
-
-var ff_pos = {
-    Ctry : {
-        _8 : {
-            BKS : {start : 15, len : 3, def : ' ' },
-            SER : {start : 15, len : 3, def : ' ' },
-            VIS : {start : 15, len : 3, def : ' ' },
-            MIX : {start : 15, len : 3, def : ' ' },
-            MAP : {start : 15, len : 3, def : ' ' },
-            SCO : {start : 15, len : 3, def : ' ' },
-            REC : {start : 15, len : 3, def : ' ' },
-            COM : {start : 15, len : 3, def : ' ' },
-        }
-    },
-    Lang : {
-        _8 : {
-            BKS : {start : 35, len : 3, def : ' ' },
-            SER : {start : 35, len : 3, def : ' ' },
-            VIS : {start : 35, len : 3, def : ' ' },
-            MIX : {start : 35, len : 3, def : ' ' },
-            MAP : {start : 35, len : 3, def : ' ' },
-            SCO : {start : 35, len : 3, def : ' ' },
-            REC : {start : 35, len : 3, def : ' ' },
-            COM : {start : 35, len : 3, def : ' ' },
-        }
-    },
-    MRec : {
-        _8 : {
-            BKS : {start : 38, len : 1, def : ' ' },
-            SER : {start : 38, len : 1, def : ' ' },
-            VIS : {start : 38, len : 1, def : ' ' },
-            MIX : {start : 38, len : 1, def : ' ' },
-            MAP : {start : 38, len : 1, def : ' ' },
-            SCO : {start : 38, len : 1, def : ' ' },
-            REC : {start : 38, len : 1, def : ' ' },
-            COM : {start : 38, len : 1, def : ' ' },
-        }
-    },
-    DtSt : {
-        _8 : {
-            BKS : {start : 6, len : 1, def : ' ' },
-            SER : {start : 6, len : 1, def : 'c' },
-            VIS : {start : 6, len : 1, def : ' ' },
-            MIX : {start : 6, len : 1, def : ' ' },
-            MAP : {start : 6, len : 1, def : ' ' },
-            SCO : {start : 6, len : 1, def : ' ' },
-            REC : {start : 6, len : 1, def : ' ' },
-            COM : {start : 6, len : 1, def : ' ' },
-        }
-    },
-    Type : {
-        ldr : {
-            BKS : {start : 6, len : 1, def : 'a' },
-            SER : {start : 6, len : 1, def : 'a' },
-            VIS : {start : 6, len : 1, def : 'g' },
-            MIX : {start : 6, len : 1, def : 'p' },
-            MAP : {start : 6, len : 1, def : 'e' },
-            SCO : {start : 6, len : 1, def : 'c' },
-            REC : {start : 6, len : 1, def : 'i' },
-            COM : {start : 6, len : 1, def : 'm' },
-            AUT : {start : 6, len : 1, def : 'z' },
-            MFHD : {start : 6, len : 1, def : 'y' }
-
-        }
-    },
-    Ctrl : {
-        ldr : {
-            BKS : {start : 8, len : 1, def : ' ' },
-            SER : {start : 8, len : 1, def : ' ' },
-            VIS : {start : 8, len : 1, def : ' ' },
-            MIX : {start : 8, len : 1, def : ' ' },
-            MAP : {start : 8, len : 1, def : ' ' },
-            SCO : {start : 8, len : 1, def : ' ' },
-            REC : {start : 8, len : 1, def : ' ' },
-            COM : {start : 8, len : 1, def : ' ' },
-        }
-    },
-    BLvl : {
-        ldr : {
-            BKS : {start : 7, len : 1, def : 'm' },
-            SER : {start : 7, len : 1, def : 's' },
-            VIS : {start : 7, len : 1, def : 'm' },
-            MIX : {start : 7, len : 1, def : 'c' },
-            MAP : {start : 7, len : 1, def : 'm' },
-            SCO : {start : 7, len : 1, def : 'm' },
-            REC : {start : 7, len : 1, def : 'm' },
-            COM : {start : 7, len : 1, def : 'm' },
-        }
-    },
-    Desc : {
-        ldr : {
-            BKS : {start : 18, len : 1, def : ' ' },
-            SER : {start : 18, len : 1, def : ' ' },
-            VIS : {start : 18, len : 1, def : ' ' },
-            MIX : {start : 18, len : 1, def : ' ' },
-            MAP : {start : 18, len : 1, def : ' ' },
-            SCO : {start : 18, len : 1, def : ' ' },
-            REC : {start : 18, len : 1, def : ' ' },
-            COM : {start : 18, len : 1, def : ' ' },
-        }
-    },
-    Item : {
-        ldr : {
-            MFHD : {start : 18, len : 1, def : 'i' }
-        }
-    },
-    ELvl : {
-        ldr : {
-            BKS : {start : 17, len : 1, def : ' ' },
-            SER : {start : 17, len : 1, def : ' ' },
-            VIS : {start : 17, len : 1, def : ' ' },
-            MIX : {start : 17, len : 1, def : ' ' },
-            MAP : {start : 17, len : 1, def : ' ' },
-            SCO : {start : 17, len : 1, def : ' ' },
-            REC : {start : 17, len : 1, def : ' ' },
-            COM : {start : 17, len : 1, def : ' ' },
-            AUT : {start : 17, len : 1, def : 'n' },
-            MFHD : {start : 17, len : 1, def : 'u' }
-        }
-    },
-    TMat : {
-        _8 : {
-            VIS : {start : 33, len : 1, def : ' ' },
-        },
-        _6 : {
-            VIS : {start : 16, len : 1, def : ' ' },
-        }
-    },
-    Indx : {
-        _8 : {
-            BKS : {start : 31, len : 1, def : '0' },
-            MAP : {start : 31, len : 1, def : '0' },
-        },
-        _6 : {
-            BKS : {start : 14, len : 1, def : '0' },
-            MAP : {start : 14, len : 1, def : '0' },
-        }
-    },
-    Date1 : {
-        _8 : {
-            BKS : {start : 7, len : 4, def : ' ' },
-            SER : {start : 7, len : 4, def : ' ' },
-            VIS : {start : 7, len : 4, def : ' ' },
-            MIX : {start : 7, len : 4, def : ' ' },
-            MAP : {start : 7, len : 4, def : ' ' },
-            SCO : {start : 7, len : 4, def : ' ' },
-            REC : {start : 7, len : 4, def : ' ' },
-            COM : {start : 7, len : 4, def : ' ' },
-        },
-    },
-    Date2 : {
-        _8 : {
-            BKS : {start : 11, len : 4, def : ' ' },
-            SER : {start : 11, len : 4, def : '9' },
-            VIS : {start : 11, len : 4, def : ' ' },
-            MIX : {start : 11, len : 4, def : ' ' },
-            MAP : {start : 11, len : 4, def : ' ' },
-            SCO : {start : 11, len : 4, def : ' ' },
-            REC : {start : 11, len : 4, def : ' ' },
-            COM : {start : 11, len : 4, def : ' ' },
-        },
-    },
-    LitF : {
-        _8 : {
-            BKS : {start : 33, len : 1, def : '0' },
-        },
-        _6 : {
-            BKS : {start : 16, len : 1, def : '0' },
-        }
-    },
-    Biog : {
-        _8 : {
-            BKS : {start : 34, len : 1, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 17, len : 1, def : ' ' },
-        }
-    },
-    Ills : {
-        _8 : {
-            BKS : {start : 18, len : 4, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 1, len : 4, def : ' ' },
-        }
-    },
-    Fest : {
-        _8 : {
-            BKS : {start : 30, len : 1, def : '0' },
-        },
-        _6 : {
-            BKS : {start : 13, len : 1, def : '0' },
-        }
-    },
-    Conf : {
-        _8 : {
-            BKS : {start : 24, len : 4, def : ' ' },
-            SER : {start : 25, len : 3, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 7, len : 4, def : ' ' },
-            SER : {start : 8, len : 3, def : ' ' },
-        }
-    },
-    GPub : {
-        _8 : {
-            BKS : {start : 28, len : 1, def : ' ' },
-            SER : {start : 28, len : 1, def : ' ' },
-            VIS : {start : 28, len : 1, def : ' ' },
-            MAP : {start : 28, len : 1, def : ' ' },
-            COM : {start : 28, len : 1, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 11, len : 1, def : ' ' },
-            SER : {start : 11, len : 1, def : ' ' },
-            VIS : {start : 11, len : 1, def : ' ' },
-            MAP : {start : 11, len : 1, def : ' ' },
-            COM : {start : 11, len : 1, def : ' ' },
-        }
-    },
-    Audn : {
-        _8 : {
-            BKS : {start : 22, len : 1, def : ' ' },
-            SER : {start : 22, len : 1, def : ' ' },
-            VIS : {start : 22, len : 1, def : ' ' },
-            SCO : {start : 22, len : 1, def : ' ' },
-            REC : {start : 22, len : 1, def : ' ' },
-            COM : {start : 22, len : 1, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 5, len : 1, def : ' ' },
-            SER : {start : 5, len : 1, def : ' ' },
-            VIS : {start : 5, len : 1, def : ' ' },
-            SCO : {start : 5, len : 1, def : ' ' },
-            REC : {start : 5, len : 1, def : ' ' },
-            COM : {start : 5, len : 1, def : ' ' },
-        }
-    },
-    Form : {
-        _8 : {
-            BKS : {start : 23, len : 1, def : ' ' },
-            SER : {start : 23, len : 1, def : ' ' },
-            VIS : {start : 29, len : 1, def : ' ' },
-            MIX : {start : 23, len : 1, def : ' ' },
-            MAP : {start : 29, len : 1, def : ' ' },
-            SCO : {start : 23, len : 1, def : ' ' },
-            REC : {start : 23, len : 1, def : ' ' },
-        },
-        _6 : {
-            BKS : {start : 6, len : 1, def : ' ' },
-            SER : {start : 6, len : 1, def : ' ' },
-            VIS : {start : 12, len : 1, def : ' ' },
-            MIX : {start : 6, len : 1, def : ' ' },
-            MAP : {start : 12, len : 1, def : ' ' },
-            SCO : {start : 6, len : 1, def : ' ' },
-            REC : {start : 6, len : 1, def : ' ' },
-        }
-    },
-    'S/L' : {
-        _8 : {
-            SER : {start : 34, len : 1, def : '0' },
-        },
-        _6 : {
-            SER : {start : 17, len : 1, def : '0' },
-        }
-    },
-    'Alph' : {
-        _8 : {
-            SER : {start : 33, len : 1, def : ' ' },
-        },
-        _6 : {
-            SER : {start : 16, len : 1, def : ' ' },
-        }
-    },
-    "GeoDiv" : {
-        "_8" : {
-            "AUT" : {"start" : 6, "len" : 1, "def" : ' ' }
-        }
-    },
-    "Roman" : {
-        "_8" : {
-            "AUT" : {"start" : 7, "len" : 1, "def" : ' ' }
-        }
-    },
-    "CatLang" : {
-        "_8" : {
-            "AUT" : {"start" : 8, "len" : 1, "def" : ' ' }
-        }
-    },
-    "Kind" : {
-        "_8" : {
-            "AUT" : {"start" : 9, "len" : 1, "def" : ' ' }
-        }
-    },
-    "Rules" : {
-        "_8" : {
-            "AUT" : {"start" : 10, "len" : 1, "def" : ' ' }
-        }
-    },
-    "Subj" : {
-        "_8" : {
-            "AUT" : {"start" : 11, "len" : 1, "def" : ' ' }
-        }
-    },
-    "SHSys" : {
-        "_8" : {
-            "AUT" : {"start" : 11, "len" : 1, "def" : ' ' }
-        }
-    },
-    "SerType" : {
-        "_8" : {
-            "AUT" : {"start" : 12, "len" : 1, "def" : ' ' }
-        }
-    },
-    "SerNum" : {
-        "_8" : {
-            "AUT" : {"start" : 13, "len" : 1, "def" : ' ' }
-        }
-    },
-    "HeadMain" : {
-        "_8" : {
-            "AUT" : {"start" : 14, "len" : 1, "def" : ' ' }
-        }
-    },
-    "SubjUse" : {
-        "_8" : {
-            "AUT" : {"start" : 15, "len" : 1, "def" : ' ' }
-        }
-    },
-    "HeadSubj" : {
-        "_8" : {
-            "AUT" : {"start" : 15, "len" : 1, "def" : ' ' }
-        }
-    },
-    "HeadSer" : {
-        "_8" : {
-            "AUT" : {"start" : 16, "len" : 1, "def" : ' ' }
-        }
-    },
-    "TypeSubd" : {
-        "_8" : {
-            "AUT" : {"start" : 17, "len" : 1, "def" : ' ' }
-        }
-    },
-    "TypeGov" : {
-        "_8" : {
-            "AUT" : {"start" : 28, "len" : 1, "def" : ' ' }
-        }
-    },
-    "RefEval" : {
-        "_8" : {
-            "AUT" : {"start" : 29, "len" : 1, "def" : ' ' }
-        }
-    },
-    "RecUpd" : {
-        "_8" : {
-            "AUT" : {"start" : 31, "len" : 1, "def" : ' ' }
-        }
-    },
-    "NameDiff" : {
-        "_8" : {
-            "AUT" : {"start" : 32, "len" : 1, "def" : ' ' }
-        }
-    },
-    "Level" : {
-        "_8" : {
-            "AUT" : {"start" : 33, "len" : 1, "def" : ' ' }
-        }
-    },
-    "ModRec" : {
-        "_8" : {
-            "AUT" : {"start" : 38, "len" : 1, "def" : ' ' }
-        }
-    },
-    "CatSrc" : {
-        "_8" : {
-            "AUT" : {"start" : 39, "len" : 1, "def" : ' ' }
-        }
-    }
-};
-
diff --git a/Open-ILS/src/javascript/backend/catalog/phys_char.js b/Open-ILS/src/javascript/backend/catalog/phys_char.js
deleted file mode 100644 (file)
index 4a6ba8d..0000000
+++ /dev/null
@@ -1,1062 +0,0 @@
-var physical_characteristics  = {
-       c : {
-               label     : "Electronic Resource",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       a : "Tape Cartridge",
-                                               b : "Chip cartridge",
-                                               c : "Computer optical disk cartridge",
-                                               f : "Tape cassette",
-                                               h : "Tape reel",
-                                               j : "Magnetic disk",
-                                               m : "Magneto-optical disk",
-                                               o : "Optical disk",
-                                               r : "Remote",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       a : "One color",
-                                               b : "Black-and-white",
-                                               c : "Multicolored",
-                                               g : "Gray scale",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "3 1/2 in.",
-                                               e : "12 in.",
-                                               g : "4 3/4 in. or 12 cm.",
-                                               i : "1 1/8 x 2 3/8 in.",
-                                               j : "3 7/8 x 2 1/2 in.",
-                                               n : "Not applicable",
-                                               o : "5 1/4 in.",
-                                               u : "Unknown",
-                                               v : "8 in.",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Sound",
-                               values: {       ' ' : "No sound (Silent)",
-                                               a   : "Sound",
-                                               u   : "Unknown",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 3,
-                               label : "Image bit depth",
-                               values: {       mmm   : "Multiple",
-                                               nnn   : "Not applicable",
-                                               '---' : "Unknown",
-                               },
-                       },
-                       h : {   start : 9,
-                               len   : 1,
-                               label : "File formats",
-                               values: {       a : "One file format",
-                                               m : "Multiple file formats",
-                                               u : "Unknown",
-                               },
-                       },
-                       i : {   start : 10,
-                               len   : 1,
-                               label : "Quality assurance target(s)",
-                               values: {       a : "Absent",
-                                               n : "Not applicable",
-                                               p : "Present",
-                                               u : "Unknown",
-                               },
-                       },
-                       j : {   start : 11,
-                               len   : 1,
-                               label : "Antecedent/Source",
-                               values: {       a : "File reproduced from original",
-                                               b : "File reproduced from microform",
-                                               c : "File reproduced from electronic resource",
-                                               d : "File reproduced from an intermediate (not microform)",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                               },
-                       },
-                       k : {   start : 12,
-                               len   : 1,
-                               label : "Level of compression",
-                               values: {       a : "Uncompressed",
-                                               b : "Lossless",
-                                               d : "Lossy",
-                                               m : "Mixed",
-                                               u : "Unknown",
-                               },
-                       },
-                       l : {   start : 13,
-                               len   : 1,
-                               label : "Reformatting quality",
-                               values: {       a : "Access",
-                                               n : "Not applicable",
-                                               p : "Preservation",
-                                               r : "Replacement",
-                                               u : "Unknown",
-                               },
-                       },
-               },
-       },
-       d : {
-               label     : "Globe",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       a : "Celestial globe",
-                                               b : "Planetary or lunar globe",
-                                               c : "Terrestrial globe",
-                                               e : "Earth moon globe",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       a : "One color",
-                                               c : "Multicolored",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Physical medium",
-                               values: {       a : "Paper",
-                                               b : "Wood",
-                                               c : "Stone",
-                                               d : "Metal",
-                                               e : "Synthetics",
-                                               f : "Skins",
-                                               g : "Textile",
-                                               p : "Plaster",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Type of reproduction",
-                               values: {       f : "Facsimile",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       a : {
-               label     : "Map",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       d : "Atlas",
-                                               g : "Diagram",
-                                               j : "Map",
-                                               k : "Profile",
-                                               q : "Model",
-                                               r : "Remote-sensing image",
-                                               s : "Section",
-                                               u : "Unspecified",
-                                               y : "View",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       a : "One color",
-                                               c : "Multicolored",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Physical medium",
-                               values: {       a : "Paper",
-                                               b : "Wood",
-                                               c : "Stone",
-                                               d : "Metal",
-                                               e : "Synthetics",
-                                               f : "Skins",
-                                               g : "Textile",
-                                               p : "Plaster",
-                                               q : "Flexible base photographic medium, positive",
-                                               r : "Flexible base photographic medium, negative",
-                                               s : "Non-flexible base photographic medium, positive",
-                                               t : "Non-flexible base photographic medium, negative",
-                                               u : "Unknown",
-                                               y : "Other photographic medium",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Type of reproduction",
-                               values: {       f : "Facsimile",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Production/reproduction details",
-                               values: {       a : "Photocopy, blueline print",
-                                               b : "Photocopy",
-                                               c : "Pre-production",
-                                               d : "Film",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Positive/negative",
-                               values: {       a : "Positive",
-                                               b : "Negative",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                               },
-                       },
-               },
-       },
-       h : {
-               label     : "Microform",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       a : "Aperture card",
-                                               b : "Microfilm cartridge",
-                                               c : "Microfilm cassette",
-                                               d : "Microfilm reel",
-                                               e : "Microfiche",
-                                               f : "Microfiche cassette",
-                                               g : "Microopaque",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Positive/negative",
-                               values: {       a : "Positive",
-                                               b : "Negative",
-                                               m : "Mixed",
-                                               u : "Unknown",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "8 mm.",
-                                               e : "16 mm.",
-                                               f : "35 mm.",
-                                               g : "70mm.",
-                                               h : "105 mm.",
-                                               l : "3 x 5 in. (8 x 13 cm.)",
-                                               m : "4 x 6 in. (11 x 15 cm.)",
-                                               o : "6 x 9 in. (16 x 23 cm.)",
-                                               p : "3 1/4 x 7 3/8 in. (9 x 19 cm.)",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 4,
-                               label : "Reduction ratio range/Reduction ratio",
-                               values: {       a : "Low (1-16x)",
-                                               b : "Normal (16-30x)",
-                                               c : "High (31-60x)",
-                                               d : "Very high (61-90x)",
-                                               e : "Ultra (90x-)",
-                                               u : "Unknown",
-                                               v : "Reduction ratio varies",
-                               },
-                       },
-                       g : {   start : 9,
-                               len   : 1,
-                               label : "Color",
-                               values: {       b : "Black-and-white",
-                                               c : "Multicolored",
-                                               m : "Mixed",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 10,
-                               len   : 1,
-                               label : "Emulsion on film",
-                               values: {       a : "Silver halide",
-                                               b : "Diazo",
-                                               c : "Vesicular",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 11,
-                               len   : 1,
-                               label : "Quality assurance target(s)",
-                               values: {       a : "1st gen. master",
-                                               b : "Printing master",
-                                               c : "Service copy",
-                                               m : "Mixed generation",
-                                               u : "Unknown",
-                               },
-                       },
-                       j : {   start : 12,
-                               len   : 1,
-                               label : "Base of film",
-                               values: {       a : "Safety base, undetermined",
-                                               c : "Safety base, acetate undetermined",
-                                               d : "Safety base, diacetate",
-                                               l : "Nitrate base",
-                                               m : "Mixed base",
-                                               n : "Not applicable",
-                                               p : "Safety base, polyester",
-                                               r : "Safety base, mixed",
-                                               t : "Safety base, triacetate",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       m : {
-               label     : "Motion Picture",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       a : "Film cartridge",
-                                               f : "Film cassette",
-                                               r : "Film reel",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       b : "Black-and-white",
-                                               c : "Multicolored",
-                                               h : "Hand-colored",
-                                               m : "Mixed",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Motion picture presentation format",
-                               values: {       a : "Standard sound aperture, reduced frame",
-                                               b : "Nonanamorphic (wide-screen)",
-                                               c : "3D",
-                                               d : "Anamorphic (wide-screen)",
-                                               e : "Other-wide screen format",
-                                               f : "Standard. silent aperture, full frame",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Sound on medium or separate",
-                               values: {       a : "Sound on medium",
-                                               b : "Sound separate from medium",
-                                               u : "Unknown",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Medium for sound",
-                               values: {       a : "Optical sound track on motion picture film",
-                                               b : "Magnetic sound track on motion picture film",
-                                               c : "Magnetic audio tape in cartridge",
-                                               d : "Sound disc",
-                                               e : "Magnetic audio tape on reel",
-                                               f : "Magnetic audio tape in cassette",
-                                               g : "Optical and magnetic sound track on film",
-                                               h : "Videotape",
-                                               i : "Videodisc",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "Standard 8 mm.",
-                                               b : "Super 8 mm./single 8 mm.",
-                                               c : "9.5 mm.",
-                                               d : "16 mm.",
-                                               e : "28 mm.",
-                                               f : "35 mm.",
-                                               g : "70 mm.",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 8,
-                               len   : 1,
-                               label : "Configuration of playback channels",
-                               values: {       k : "Mixed",
-                                               m : "Monaural",
-                                               n : "Not applicable",
-                                               q : "Multichannel, surround or quadraphonic",
-                                               s : "Stereophonic",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       j : {   start : 9,
-                               len   : 1,
-                               label : "Production elements",
-                               values: {       a : "Work print",
-                                               b : "Trims",
-                                               c : "Outtakes",
-                                               d : "Rushes",
-                                               e : "Mixing tracks",
-                                               f : "Title bands/inter-title rolls",
-                                               g : "Production rolls",
-                                               n : "Not applicable",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       k : {
-               label     : "Non-projected Graphic",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       c : "Collage",
-                                               d : "Drawing",
-                                               e : "Painting",
-                                               f : "Photo-mechanical print",
-                                               g : "Photonegative",
-                                               h : "Photoprint",
-                                               i : "Picture",
-                                               j : "Print",
-                                               l : "Technical drawing",
-                                               n : "Chart",
-                                               o : "Flash/activity card",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       a : "One color",
-                                               b : "Black-and-white",
-                                               c : "Multicolored",
-                                               h : "Hand-colored",
-                                               m : "Mixed",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Primary support material",
-                               values: {       a : "Canvas",
-                                               b : "Bristol board",
-                                               c : "Cardboard/illustration board",
-                                               d : "Glass",
-                                               e : "Synthetics",
-                                               f : "Skins",
-                                               g : "Textile",
-                                               h : "Metal",
-                                               m : "Mixed collection",
-                                               o : "Paper",
-                                               p : "Plaster",
-                                               q : "Hardboard",
-                                               r : "Porcelain",
-                                               s : "Stone",
-                                               t : "Wood",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Secondary support material",
-                               values: {       a : "Canvas",
-                                               b : "Bristol board",
-                                               c : "Cardboard/illustration board",
-                                               d : "Glass",
-                                               e : "Synthetics",
-                                               f : "Skins",
-                                               g : "Textile",
-                                               h : "Metal",
-                                               m : "Mixed collection",
-                                               o : "Paper",
-                                               p : "Plaster",
-                                               q : "Hardboard",
-                                               r : "Porcelain",
-                                               s : "Stone",
-                                               t : "Wood",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       g : {
-               label     : "Projected Graphic",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       c : "Film cartridge",
-                                               d : "Filmstrip",
-                                               f : "Film filmstrip type",
-                                               o : "Filmstrip roll",
-                                               s : "Slide",
-                                               t : "Transparency",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       b : "Black-and-white",
-                                               c : "Multicolored",
-                                               h : "Hand-colored",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Base of emulsion",
-                               values: {       d : "Glass",
-                                               e : "Synthetics",
-                                               j : "Safety film",
-                                               k : "Film base, other than safety film",
-                                               m : "Mixed collection",
-                                               o : "Paper",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Sound on medium or separate",
-                               values: {       a : "Sound on medium",
-                                               b : "Sound separate from medium",
-                                               u : "Unknown",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Medium for sound",
-                               values: {       a : "Optical sound track on motion picture film",
-                                               b : "Magnetic sound track on motion picture film",
-                                               c : "Magnetic audio tape in cartridge",
-                                               d : "Sound disc",
-                                               e : "Magnetic audio tape on reel",
-                                               f : "Magnetic audio tape in cassette",
-                                               g : "Optical and magnetic sound track on film",
-                                               h : "Videotape",
-                                               i : "Videodisc",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "Standard 8 mm.",
-                                               b : "Super 8 mm./single 8 mm.",
-                                               c : "9.5 mm.",
-                                               d : "16 mm.",
-                                               e : "28 mm.",
-                                               f : "35 mm.",
-                                               g : "70 mm.",
-                                               j : "2 x 2 in. (5 x 5 cm.)",
-                                               k : "2 1/4 x 2 1/4 in. (6 x 6 cm.)",
-                                               s : "4 x 5 in. (10 x 13 cm.)",
-                                               t : "5 x 7 in. (13 x 18 cm.)",
-                                               v : "8 x 10 in. (21 x 26 cm.)",
-                                               w : "9 x 9 in. (23 x 23 cm.)",
-                                               x : "10 x 10 in. (26 x 26 cm.)",
-                                               y : "7 x 7 in. (18 x 18 cm.)",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 8,
-                               len   : 1,
-                               label : "Secondary support material",
-                               values: {       c : "Cardboard",
-                                               d : "Glass",
-                                               e : "Synthetics",
-                                               h : "metal",
-                                               j : "Metal and glass",
-                                               k : "Synthetics and glass",
-                                               m : "Mixed collection",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       r : {
-               label     : "Remote-sensing Image",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: { u : "Unspecified" },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Altitude of sensor",
-                               values: {       a : "Surface",
-                                               b : "Airborne",
-                                               c : "Spaceborne",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Attitude of sensor",
-                               values: {       a : "Low oblique",
-                                               b : "High oblique",
-                                               c : "Vertical",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Cloud cover",
-                               values: {       0 : "0-09%",
-                                               1 : "10-19%",
-                                               2 : "20-29%",
-                                               3 : "30-39%",
-                                               4 : "40-49%",
-                                               5 : "50-59%",
-                                               6 : "60-69%",
-                                               7 : "70-79%",
-                                               8 : "80-89%",
-                                               9 : "90-100%",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Platform construction type",
-                               values: {       a : "Balloon",
-                                               b : "Aircraft-low altitude",
-                                               c : "Aircraft-medium altitude",
-                                               d : "Aircraft-high altitude",
-                                               e : "Manned spacecraft",
-                                               f : "Unmanned spacecraft",
-                                               g : "Land-based remote-sensing device",
-                                               h : "Water surface-based remote-sensing device",
-                                               i : "Submersible remote-sensing device",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Platform use category",
-                               values: {       a : "Meteorological",
-                                               b : "Surface observing",
-                                               c : "Space observing",
-                                               m : "Mixed uses",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 8,
-                               len   : 1,
-                               label : "Sensor type",
-                               values: {       a : "Active",
-                                               b : "Passive",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       j : {   start : 9,
-                               len   : 2,
-                               label : "Data type",
-                               values: {       nn : "Not applicable",
-                                               uu : "Unknown",
-                                               zz : "Other",
-                                               aa : "Visible light",
-                                               da : "Near infrared",
-                                               db : "Middle infrared",
-                                               dc : "Far infrared",
-                                               dd : "Thermal infrared",
-                                               de : "Shortwave infrared (SWIR)",
-                                               df : "Reflective infrared",
-                                               dv : "Combinations",
-                                               dz : "Other infrared data",
-                                               ga : "Sidelooking airborne radar (SLAR)",
-                                               gb : "Synthetic aperture radar (SAR-single frequency)",
-                                               gc : "SAR-multi-frequency (multichannel)",
-                                               gd : "SAR-like polarization",
-                                               ge : "SAR-cross polarization",
-                                               gf : "Infometric SAR",
-                                               gg : "Polarmetric SAR",
-                                               gu : "Passive microwave mapping",
-                                               gz : "Other microwave data",
-                                               ja : "Far ultraviolet",
-                                               jb : "Middle ultraviolet",
-                                               jc : "Near ultraviolet",
-                                               jv : "Ultraviolet combinations",
-                                               jz : "Other ultraviolet data",
-                                               ma : "Multi-spectral, multidata",
-                                               mb : "Multi-temporal",
-                                               mm : "Combination of various data types",
-                                               pa : "Sonar-water depth",
-                                               pb : "Sonar-bottom topography images, sidescan",
-                                               pc : "Sonar-bottom topography, near-surface",
-                                               pd : "Sonar-bottom topography, near-bottom",
-                                               pe : "Seismic surveys",
-                                               pz : "Other acoustical data",
-                                               ra : "Gravity anomales (general)",
-                                               rb : "Free-air",
-                                               rc : "Bouger",
-                                               rd : "Isostatic",
-                                               sa : "Magnetic field",
-                                               ta : "Radiometric surveys",
-                               },
-                       },
-               },
-       },
-       s : {
-               label     : "Sound Recording",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       d : "Sound disc",
-                                               e : "Cylinder",
-                                               g : "Sound cartridge",
-                                               i : "Sound-track film",
-                                               q : "Roll",
-                                               s : "Sound cassette",
-                                               t : "Sound-tape reel",
-                                               u : "Unspecified",
-                                               w : "Wire recording",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Speed",
-                               values: {       a : "16 rpm",
-                                               b : "33 1/3 rpm",
-                                               c : "45 rpm",
-                                               d : "78 rpm",
-                                               e : "8 rpm",
-                                               f : "1.4 mps",
-                                               h : "120 rpm",
-                                               i : "160 rpm",
-                                               k : "15/16 ips",
-                                               l : "1 7/8 ips",
-                                               m : "3 3/4 ips",
-                                               o : "7 1/2 ips",
-                                               p : "15 ips",
-                                               r : "30 ips",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Configuration of playback channels",
-                               values: {       m : "Monaural",
-                                               q : "Quadraphonic",
-                                               s : "Stereophonic",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Groove width or pitch",
-                               values: {       m : "Microgroove/fine",
-                                               n : "Not applicable",
-                                               s : "Coarse/standard",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "3 in.",
-                                               b : "5 in.",
-                                               c : "7 in.",
-                                               d : "10 in.",
-                                               e : "12 in.",
-                                               f : "16 in.",
-                                               g : "4 3/4 in. (12 cm.)",
-                                               j : "3 7/8 x 2 1/2 in.",
-                                               o : "5 1/4 x 3 7/8 in.",
-                                               s : "2 3/4 x 4 in.",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Tape width",
-                               values: {       l : "1/8 in.",
-                                               m : "1/4in.",
-                                               n : "Not applicable",
-                                               o : "1/2 in.",
-                                               p : "1 in.",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 8,
-                               len   : 1,
-                               label : "Tape configuration ",
-                               values: {       a : "Full (1) track",
-                                               b : "Half (2) track",
-                                               c : "Quarter (4) track",
-                                               d : "8 track",
-                                               e : "12 track",
-                                               f : "16 track",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       m : {   start : 12,
-                               len   : 1,
-                               label : "Special playback",
-                               values: {       a : "NAB standard",
-                                               b : "CCIR standard",
-                                               c : "Dolby-B encoded, standard Dolby",
-                                               d : "dbx encoded",
-                                               e : "Digital recording",
-                                               f : "Dolby-A encoded",
-                                               g : "Dolby-C encoded",
-                                               h : "CX encoded",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       n : {   start : 13,
-                               len   : 1,
-                               label : "Capture and storage",
-                               values: {       a : "Acoustical capture, direct storage",
-                                               b : "Direct storage, not acoustical",
-                                               d : "Digital storage",
-                                               e : "Analog electrical storage",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       f : {
-               label     : "Tactile Material",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       a : "Moon",
-                                               b : "Braille",
-                                               c : "Combination",
-                                               d : "Tactile, with no writing system",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 2,
-                               label : "Class of braille writing",
-                               values: {       a : "Literary braille",
-                                               b : "Format code braille",
-                                               c : "Mathematics and scientific braille",
-                                               d : "Computer braille",
-                                               e : "Music braille",
-                                               m : "Multiple braille types",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Level of contraction",
-                               values: {       a : "Uncontracted",
-                                               b : "Contracted",
-                                               m : "Combination",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 6,
-                               len   : 3,
-                               label : "Braille music format",
-                               values: {       a : "Bar over bar",
-                                               b : "Bar by bar",
-                                               c : "Line over line",
-                                               d : "Paragraph",
-                                               e : "Single line",
-                                               f : "Section by section",
-                                               g : "Line by line",
-                                               h : "Open score",
-                                               i : "Spanner short form scoring",
-                                               j : "Short form scoring",
-                                               k : "Outline",
-                                               l : "Vertical score",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       g : {   start : 9,
-                               len   : 1,
-                               label : "Special physical characteristics",
-                               values: {       a : "Print/braille",
-                                               b : "Jumbo or enlarged braille",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-       v : {
-               label     : "Videorecording",
-               subfields : {
-                       b : {   start : 1,
-                               len   : 1,
-                               label : "SMD",
-                               values: {       c : "Videocartridge",
-                                               d : "Videodisc",
-                                               f : "Videocassette",
-                                               r : "Videoreel",
-                                               u : "Unspecified",
-                                               z : "Other",
-                               },
-                       },
-                       d : {   start : 3,
-                               len   : 1,
-                               label : "Color",
-                               values: {       b : "Black-and-white",
-                                               c : "Multicolored",
-                                               m : "Mixed",
-                                               n : "Not applicable",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       e : {   start : 4,
-                               len   : 1,
-                               label : "Videorecording format",
-                               values: {       a : "Beta",
-                                               b : "VHS",
-                                               c : "U-matic",
-                                               d : "EIAJ",
-                                               e : "Type C",
-                                               f : "Quadruplex",
-                                               g : "Laserdisc",
-                                               h : "CED",
-                                               i : "Betacam",
-                                               j : "Betacam SP",
-                                               k : "Super-VHS",
-                                               m : "M-II",
-                                               o : "D-2",
-                                               p : "8 mm.",
-                                               q : "Hi-8 mm.",
-                                               u : "Unknown",
-                                               v : "DVD",
-                                               z : "Other",
-                               },
-                       },
-                       f : {   start : 5,
-                               len   : 1,
-                               label : "Sound on medium or separate",
-                               values: {       a : "Sound on medium",
-                                               b : "Sound separate from medium",
-                                               u : "Unknown",
-                               },
-                       },
-                       g : {   start : 6,
-                               len   : 1,
-                               label : "Medium for sound",
-                               values: {       a : "Optical sound track on motion picture film",
-                                               b : "Magnetic sound track on motion picture film",
-                                               c : "Magnetic audio tape in cartridge",
-                                               d : "Sound disc",
-                                               e : "Magnetic audio tape on reel",
-                                               f : "Magnetic audio tape in cassette",
-                                               g : "Optical and magnetic sound track on motion picture film",
-                                               h : "Videotape",
-                                               i : "Videodisc",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       h : {   start : 7,
-                               len   : 1,
-                               label : "Dimensions",
-                               values: {       a : "8 mm.",
-                                               m : "1/4 in.",
-                                               o : "1/2 in.",
-                                               p : "1 in.",
-                                               q : "2 in.",
-                                               r : "3/4 in.",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-                       i : {   start : 8,
-                               len   : 1,
-                               label : "Configuration of playback channel",
-                               values: {       k : "Mixed",
-                                               m : "Monaural",
-                                               n : "Not applicable",
-                                               q : "Multichannel, surround or quadraphonic",
-                                               s : "Stereophonic",
-                                               u : "Unknown",
-                                               z : "Other",
-                               },
-                       },
-               },
-       },
-};
-
diff --git a/Open-ILS/src/javascript/backend/catalog/record_type.js b/Open-ILS/src/javascript/backend/catalog/record_type.js
deleted file mode 100644 (file)
index 0a6988b..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-// Constants ...
-load_lib('phys_char.js');
-load_lib('fixed_fields.js');
-load_lib('JSON_v1.js');
-
-function recordType (rec) {
-
-       var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
-       var _l = rec.marcns::leader.toString();
-
-       var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
-       var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
-
-       for (var t in rec_type) {
-               if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
-                       return t;
-               }
-       }
-}
-
-function videorecordingFormatName (rec) {
-       var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
-       var _7 = rec.marcns::controlfield.(@tag.match(/007/)).text().toString();
-
-       if (_7.match(/^v/)) {
-               var _v_e = _7.substr(
-                       physical_characteristics.v.subfields.e.start,
-                       physical_characteristics.v.subfields.e.len
-               );
-
-               return physical_characteristics.v.subfields.e.values[ _v_e ];
-       }
-
-       return null;
-}
-
-function videorecordingFormatCode (rec) {
-       var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
-       var _7 = rec.marcns::controlfield.(@tag.match(/007/)).text().toString();
-
-       if (_7.match(/^v/)) {
-               return _7.substr(
-                       physical_characteristics.v.subfields.e.start,
-                       physical_characteristics.v.subfields.e.len
-               );
-       }
-
-       return null;
-}
-
-
-function extractFixedField (rec, field) {
-
-       var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
-       var _l = rec.marcns::leader.toString();
-       var _8 = rec.marcns::controlfield.(@tag.match(/008/)).text().toString();
-       var _6 = rec.marcns::controlfield.(@tag.match(/006/)).text().toString();
-
-       var rtype = recordType(rec);
-
-       var val;
-
-       if (ff_pos[field].ldr) {
-               if (ff_pos[field].ldr[rtype]) {
-                       val = _l.substr(
-                               ff_pos[field].ldr[rtype].start,
-                               ff_pos[field].ldr[rtype].len
-                       );
-               }
-       } else if (ff_pos[field]._8) {
-               if (ff_pos[field]._8[rtype]) {
-                       val = _8.substr(
-                               ff_pos[field]._8[rtype].start,
-                               ff_pos[field]._8[rtype].len
-                       );
-               }
-       }
-
-       if (!val && ff_pos[field]._6) {
-               if (ff_pos[field]._6[rtype]) {
-                       val = _6.substr(
-                               ff_pos[field]._6[rtype].start,
-                               ff_pos[field]._6[rtype].len
-                       );
-               }
-       }
-               
-       return val;
-}
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_duration.js b/Open-ILS/src/javascript/backend/circ/circ_duration.js
deleted file mode 100644 (file)
index 6f6a3d4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-function go(){
-
-load_lib('circ/circ_item_config.js');
-load_lib('JSON_v1.js');
-log_vars('circ_duration');
-
-
-/* treat pre-cat copies like vanilla books */
-if( isTrue(isPrecat) ) {
-       log_info("pre-cat copy getting duration defaults...");
-       result.durationRule                     = 'default';
-       result.recurringFinesRule       = 'default';
-       result.maxFine                          = 'default'
-       return;
-}
-
-
-/* grab the config from the config script */
-var config = getItemConfig();
-var itemForm   = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
-
-
-/* ----------------------------------------------------------------------------- 
-       Now set the rule values based on the config.  If there is no configured info
-       on this copy, fall back on defaults.
-       ----------------------------------------------------------------------------- */
-if( config ) {
-
-       log_debug("circ_duration found a config for the copy");
-       result.durationRule                     = config.durationRule;
-       result.recurringFinesRule       = config.recurringFinesRule;
-       result.maxFine                      = config.maxFine;
-
-} else {
-
-       result.durationRule = 'default';
-       result.recurringFinesRule = 'default';
-       result.maxFine = 'default';
-}
-
-
-log_info('final duration results: ' + 
-    result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine );
-
-} go();
-
-
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_groups.js b/Open-ILS/src/javascript/backend/circ/circ_groups.js
deleted file mode 100644 (file)
index 036d56e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ---------------------------------------------------------------------
-       Set up the limits for the various profiles (aka permission groups).
-       Values of -1 mean there is no limit 
-
-       maxItemsOut                     - the maximum number of items the user can have out
-       fineThreshold           - the fine threshold. 
-       overdueThreshold        - the overdue items threshold.
-       maxHolds                                - The maximum number of holds the user can have
-
-       A user exceeds the fineThreshold and/or overdueThreshold if they are 
-       equal to or exceed the threshold
-       --------------------------------------------------------------------- */
-
-var GROUP_CONFIG = {
-       'Patron' : {
-               maxItemsOut         : 50,
-               fineThreshold       : 10,
-               overdueThreshold    : 10,
-               maxHolds            : -1
-       },
-}
diff --git a/Open-ILS/src/javascript/backend/circ/circ_item_config.js b/Open-ILS/src/javascript/backend/circ/circ_item_config.js
deleted file mode 100644 (file)
index c54d0cc..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_debug('loading circ_item_config.js ...');
-
-
-/* SIP media types
-000 Other
-001 Book
-002 Magazine
-003 Bound journal
-004 Audio tape
-005 Video tape
-006 CD/CDROM
-007 Diskette
-008 Book with diskette
-009 Book with CD
-010 Book with audio tape
-*/
-
-/* ----------------------------------------------------------------------------- 
-       Configure the duration rules for the various item types and circ modifiers
-       MARC Fixed Field info:
-       http://www.oclc.org/bibformats/en/fixedfield/
-       ----------------------------------------------------------------------------- */
-
-var MARC_ITEM_TYPE_MAP = {
-       a : { /* Language material [Books] */
-               SIPMediaType                    : '001',
-               magneticMedia                   : 'f',
-               durationRule                    : 'default',
-               recurringFinesRule          : 'default',
-               maxFine                                 : 'default'
-       },
-    /* add more MARC item type configs as needed... */
-}
-
-/* make 't' and 'a' share the same config info */
-MARC_ITEM_TYPE_MAP.t = MARC_ITEM_TYPE_MAP.a;
-
-
-var CIRC_MOD_MAP = {
-       'bestseller'                            : {
-               SIPMediaType                    : '001',
-               magneticMedia                   : 'f',
-               durationRule                    : 'default',
-               recurringFinesRule          : 'default',
-               maxFine                                 : 'default'
-       },
-}
-
-
-/* this will set defaults even if no one asked for them */
-log_debug("Calling getItemConfig() to force defaults..");
-result.item_config = getItemConfig();
-
-
-function getItemConfig() {
-
-       var config = null;
-       var marcType    = getMARCItemType();
-       var circMod             = copy.circ_modifier;
-
-    if( circMod ) {
-        config = CIRC_MOD_MAP[circMod];
-        if(!config) 
-            config = CIRC_MOD_MAP[circMod.toLowerCase()]
-    }
-
-    if(!config)
-               config = MARC_ITEM_TYPE_MAP[marcType];
-
-    if(!config) {
-        config = {};
-               config.SIPMediaType = '001';
-               config.magneticMedia = 'f';
-               config.durationRule     = 'default';
-               config.recurringFinesRule = 'default';
-               config.maxFine = 'default';
-    }
-
-    return config
-}
-
-
-
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_lib.js b/Open-ILS/src/javascript/backend/circ/circ_lib.js
deleted file mode 100644 (file)
index 64923ed..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-load_lib('catalog/record_type.js');
-load_lib('circ/circ_groups.js');
-load_lib('JSON_v1.js');
-
-
-try {
-       if( environment.copy ) {
-               environment.copy.fetchBestHold = function() {
-                       var key = scratchKey();
-                       environment.copy.__OILS_FUNC_fetch_best_hold(scratchPad(key));
-                       var val = getScratch(key);
-                       return (val) ? val : null;
-               }
-       }
-} catch(e) {}
-
-
-/* ----------------------------------------------------------------------------- 
-       Collect all of the global variables
-       ----------------------------------------------------------------------------- */
-
-/* the global result object.  Any data returned to the 
-       caller must be put into this object.  */
-var result                             = environment.result = {};
-result.event                   = 'SUCCESS';
-result.events                  = [];
-result.fatalEvents     = [];
-result.infoEvents              = [];
-
-
-/* Pull in any variables passed in from the calling process */
-var copy                                       = environment.copy;
-var volume                             = environment.volume;
-var title                              = environment.title;
-var recDescriptor              = environment.titleDescriptor;
-var patron                             = environment.patron;
-var patronItemsOut     = environment.patronItemsOut;
-var patronOverdueCount = environment.patronOverdueCount;
-var patronFines                = environment.patronFines;
-var isRenewal                  = environment.isRenewal;
-var isPrecat                   = environment.isPrecat;
-var currentLocation    = environment.location;
-var holdRequestLib     = environment.requestLib;
-var holdPickupLib       = environment.pickupLib; /* hold pickup lib */
-var requestor = environment.requestor || patron;
-var newHold = environment.newHold;
-
-
-
-/* create some new vars based on the data we have wherever possible */
-var patronProfile;
-var copyStatus;
-var marcXMLDoc;
-
-if( patron && patron.profile ) 
-       patronProfile = patron.profile.name;
-if( copy && copy.status ) 
-       copyStatus = copy.status.name;
-if( title && title.marc )
-       marcXMLDoc = new XML(title.marc);
-
-
-
-/* copy the group tree into some other useful data structures */
-var groupTree          = environment.groupTree;
-var groupList          = {};
-var groupIDList        = {};
-flattenGroupTree(groupTree);
-
-
-
-
-
-
-/* ----------------------------------------------------------------------------- 
-       Define all of the utility functions
-       ----------------------------------------------------------------------------- */
-
-
-
-/* useful functions for creating wrappers around system functions */
-var __scratchKey = 0;
-var __SCRATCH = {};
-function scratchKey()          { return '_' + __scratchKey++; };
-function scratchPad(key)       { return '__SCRATCH.'+ key; }
-function getScratch(key)       { return __SCRATCH[ key ]; }
-function scratchClear()                { for( var o in __SCRATCH ) __SCRATCH[o] = null; }
-
-
-/* note: returns false if the value is 'f' or 'F' ... */
-function isTrue(d) {
-       if(     d && 
-                       d != "0" && 
-                       d != "f" &&
-                       d != "F" )
-                       return true;
-       return false;
-}
-
-/* Utility function for iterating over array */
-function iterate( arr, callback ) {
-       for( var i = 0; i < arr.length; i++ ) 
-               callback(arr[i]);
-}
-
-
-/**
-  * returns a list of items that when passed to the callback 
-  * 'func' returned true returns null if none were found
-  */
-function grep( arr, func ) {
-       var results = [];
-       iterate( arr, 
-               function(d) {
-                       if( func(d) ) 
-                               results.push(d);
-               }
-       );
-       if(results.length > 0)  
-               return results;
-       return null;
-}
-
-
-
-function flattenGroupTree(node) {
-       if(!node) return null;
-       groupList[node.name] = node;
-       groupIDList[node.id] = node;
-       iterate( node.children,
-               function(n) {
-                       flattenGroupTree(n);
-               }
-       );
-}
-
-
-
-/**
-  * Returns true if 'child' is equal or descends from 'parent'
-  * @param parent The name of the parent group
-  * @param child The name of the child group
-  */
-function isGroupDescendant( parent, child ) {
-       log_debug("checking descendant p="+parent + " c=" + child);
-       return __isGroupDescendant(
-               groupList[parent],
-               groupList[child]);
-}
-
-function isGroupDescendantId( parentName, childId ) {
-       log_debug("checking descendant ID p="+parentName + " c=" + childId);
-       return __isGroupDescendant(
-               groupList[parentName],
-               groupIDList[childId]);
-}
-
-
-/**
-  * Returns true if 'child' is equal or descends from 'parent'
-  * @param parent The node of the parent group
-  * @param child The node of the child group
-  */
-function __isGroupDescendant( parent, child ) {
-    if(!(parent && child)) return false;
-       if (parent.id == child.id) return true;
-       var node = child;
-       while( (node = groupIDList[node.parent]) ) {
-               if( node.id == parent.id ) 
-                       return true;
-       }
-       return false;
-}
-
-
-function getMARCItemType() {
-       if(     copy &&
-                       copy.circ_as_type &&
-                       copy.circ_as_type != 'undef' )
-               return copy.circ_as_type;
-       
-       return (marcXMLDoc) ? extractFixedField(marcXMLDoc, 'Type') : "";
-}
-
-
-function isOrgDescendent( parentName, childId ) {
-       var key = scratchKey();
-       __OILS_FUNC_isOrgDescendent(scratchPad(key), parentName, childId);
-       var val = getScratch(key);
-       if( val == '1' ) return true;
-       return false;
-}
-
-/* returns the number of unfulfilled holds open on this user */
-function userHoldCount(userid) {
-   var key = scratchKey();
-   __OILS_FUNC_userHoldCount(scratchPad(key), userid);
-   return getScratch(key);
-}
-
-function hasCommonAncestor( org1, org2, depth ) {
-       var key = scratchKey();
-       __OILS_FUNC_hasCommonAncestor(scratchPad(key), org1, org2, depth);
-       var val = getScratch(key);
-       if( val == '1' ) return true;
-       return false;
-}
-
-/* returns a dictionary of circmod : count for checked out items */
-function checkoutsByCircModifier(userid) {
-    var key = scratchKey();
-    __OILS_FUNC_userCircsByCircmod(scratchPad(key), userid);
-    var val = getScratch(key);
-    return (val) ? val : {};
-}
-
-/* useful for testing */
-function die(msg) {
-       log_error("die(): "+msg);
-       log_stderr("die(): "+msg);
-       var foo = null;
-       var baz = foo.bar;
-}
-
-
-
-/* logs a load of info */
-function log_vars( prefix ) {
-       var str = prefix + ' : ';
-
-       if(patron) {
-               str += ' Patron=' + patron.id;
-               str += ', Patron_Username='+ patron.usrname;
-               str += ', Patron_Profile_Group='+ patronProfile;
-               str += ', Patron_Fines='        + patronFines;
-               str += ', Patron_OverdueCount=' + patronOverdueCount;
-               str += ', Patron_Items_Out=' + patronItemsOut;
-
-               try {
-                       str += ', Patron_Barcode='      + patron.card.barcode;
-                       str += ', Patron_Library='      + patron.home_ou.name;
-               } catch(e) {}
-       }
-
-    if(requestor.id != patron.id) 
-        str+= ' Requestor='+requestor.usrname;
-
-       if(copy)        {
-               str += ', Copy=' + copy.id;
-               str += ', Copy_Barcode=' + copy.barcode;
-               str += ', Copy_status=' + copyStatus;
-      str += (copy.circ_modifier) ? ', Circ_Mod=' + copy.circ_modifier : '';
-
-               try {
-                       str += ', Circ_Lib=' + copy.circ_lib.shortname;
-                       str += ', Copy_location=' + copy.location.name;
-               } catch(e) {}
-       }
-
-       if(volume) {
-        str += ', Item_Owning_lib=' + volume.owning_lib;
-        str += ', Volume='     + volume.id;
-    }
-
-       if(title) str += ', Record='    + title.id;
-
-       if(recDescriptor)       {
-               str += ', Record_Descriptor=' + recDescriptor.id;
-               str += ', Item_Type='                   + recDescriptor.item_type;
-               str += ', Item_Form='                   + recDescriptor.item_form;
-               str += ', Item_Lang='                   + recDescriptor.item_lang;
-               str += ', Item_Audience='               + recDescriptor.audience;
-       }
-
-       str += ', Is_Renewal: ' + ( (isTrue(isRenewal)) ? "yes" : "no" );
-       str += ', Is_Precat: '  + ( (isTrue(isPrecat)) ? "yes" : "no" );
-       str += (holdRequestLib) ? ', Hold_request_lib=' + holdRequestLib.shortname : '';
-    str += (holdPickupLib) ? ', Hold_Pickup_Lib=' + holdPickupLib : '';
-
-       log_info(str);
-}
-
-
-
-/**
-  * Returns config information for the requested group.  If 
-  * no config info exists for the requested group, then this
-  * function searches up the tree to find the config info 
-  * for the nearest ancestor
-  * @param The name of the group who's config info to return
-  */
-function findGroupConfig(name) {
-       if(!name) return null;
-       var node = groupList[name];
-       do {
-               if( GROUP_CONFIG[node.name] ) {
-                       debugGroupConfig(name, node.name, GROUP_CONFIG[node.name]);
-                       return GROUP_CONFIG[node.name];
-               }
-       } while( (node = groupIDList[node.parent]) );
-       return null;
-}
-
-
-/** prints out the settings for the given group config **/
-function debugGroupConfig(name, foundName, config) {
-       if(!config) return;
-       var str = "findGroupConfig('"+name+"'): returning config info for '"+ foundName +"': ";
-       for( var i in config ) 
-               str += i + '=' + config[i] + '  ';
-       log_debug(str);
-}
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js b/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js
deleted file mode 100644 (file)
index 053d9b7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-function go() {
-
-/* load the lib script */
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_vars('circ_permit_copy');
-
-
-if( ! isTrue(copy.circulate) || !isTrue(copy.location.circulate) ) 
-       result.events.push('COPY_CIRC_NOT_ALLOWED');
-
-
-if( ! isTrue(isRenewal) ) {
-       if(copyStatus != 'Available' && 
-               copyStatus != 'On holds shelf' && copyStatus != 'Reshelving' ) {
-                       result.events.push('COPY_NOT_AVAILABLE');
-       } 
-}
-
-
-       
-} go();
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js
deleted file mode 100644 (file)
index 942aace..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-function go() {
-
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_vars('circ_permit_hold');
-
-
-
-if( isTrue(patron.barred) ) 
-       result.events.push('PATRON_BARRED');
-
-if( isTrue(copy.ref) ) 
-       result.events.push('ITEM_NOT_HOLDABLE');
-
-if( !isTrue(copy.circulate) ) 
-       result.events.push('ITEM_NOT_HOLDABLE');
-
-
-var config = findGroupConfig(patronProfile);
-
-
-if( config ) {
-
-    /* see if they have too many items out */
-    if(newHold) {
-        log_info("This is a new hold, checking maxHolds...");
-        var limit = config.maxHolds;
-        var count = userHoldCount(patron.id);
-        if( limit >= 0 && count >= limit ) {
-            log_info("patron has " + count + " open holds");
-            result.events.push('MAX_HOLDS');
-        }
-    } else {
-        log_info("Ignoring maxHolds on existing hold...");
-    }
-}
-
-
-} go();
-
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js b/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js
deleted file mode 100644 (file)
index 9549688..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-function go() {
-
-/* load the script library */
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_vars('circ_permit_patron');
-
-
-if( isTrue(patron.barred) ) 
-       result.events.push('PATRON_BARRED');
-
-var config = findGroupConfig(patronProfile);
-
-if( config ) {
-
-    var limit = config.maxItemsOut;
-    if( limit >= 0 ) {
-        log_info('patron items out = ' + patronItemsOut +' limit = ' + limit);
-        if( !isTrue(isRenewal) && patronItemsOut >= limit ) {
-            result.events.push('PATRON_EXCEEDS_CHECKOUT_COUNT');
-        }
-    }
-    
-} else {
-
-    log_warn("** profile has no configured information: " + patronProfile);
-}
-
-
-
-} go();
-
-
diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js b/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js
deleted file mode 100644 (file)
index 2eaac55..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-function go() {
-
-/* load the lib script */
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_vars('circ_permit_renew');
-
-} go();
diff --git a/Open-ILS/src/javascript/backend/libs/jsDOM.js b/Open-ILS/src/javascript/backend/libs/jsDOM.js
deleted file mode 100644 (file)
index 5b143c0..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-try {
-       load_lib('jsOO.js')
-       load_lib('xpath.js')
-} catch (e) {}
-
-function DOMException  (c) { this.code = c }
-DOMException.INDEX_SIZE_ERR = 1;
-DOMException.DOMSTRING_SIZE_ERR = 2;
-DOMException.HIERARCHY_REQUEST_ERR = 3;
-DOMException.WRONG_DOCUMENT_ERR = 4;
-DOMException.INVALID_CHARACTER_ERR = 5;
-DOMException.NO_DATA_ALLOWED_ERR = 6;
-DOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
-DOMException.NOT_FOUND_ERR = 8;
-DOMException.NOT_SUPPORTED_ERR = 9;
-DOMException.INUSE_ATTRIBUTE_ERR = 10;
-DOMException.INVALID_STATE_ERR = 11;
-DOMException.SYNTAX_ERR = 12;
-DOMException.INVALID_MODIFICATION_ERR = 13;
-DOMException.NAMESPACE_ERR = 14;
-DOMException.INVALID_ACCESS_ERR = 15;
-
-function DOMImplementation () {
-       this._features = {};
-       this._features['CORE'] = {};
-       this._features['CORE']['any'] = true;
-       this._features['CORE']['1.0'] = true;
-       this._features['CORE']['2.0'] = true;
-       this._features['XML'] = {};
-       this._features['XML']['any'] = true;
-       this._features['XML']['1.0'] = true;
-       this._features['XML']['2.0'] = true;
-}
-
-DOMImplementation.method('hasFeature', function (f, v) {
-       if (!v) v = 'any';
-       if (this._features[f] && this._features[f][v])
-               return this._features[f][v];
-       return false;
-});
-DOMImplementation.method('createDocumentType', function (n, p, s) {
-       return null;
-});
-DOMImplementation.method('createDocument', function (ns,qn,dt) {
-       var d = new Document(dt);
-       d.documentElement = d.createElement(qn);
-       d.appendChild(d.documentElement);
-       if (ns)
-               d.documentElement.namespaceURI = ns;
-
-       installDOM3XPathSupport(d,new XPathParser());
-       return d;
-});
-
-var __XMLDOC = {};
-var __XMLDOCid = 0;
-DOMImplementation.parseString = function (xml) {
-       __XMLDOC['id' + __XMLDOCid] = {};
-       try {
-               _OILS_FUNC_xml_parse_string(xml, '__XMLDOC.id' + __XMLDOCid);
-       } catch (e) {
-               alert("Sorry, no string parsing support");
-       }
-       var x = __XMLDOC['id' + __XMLDOCid];
-       __XMLDOCid++;
-       return x;
-}
-
-
-// NodeList interface
-function NodeList () {
-       this.length = 0;
-       //log_stdout(' --  NodeList constructor');
-}
-
-NodeList.method('item', function (idx) {
-       return this[idx];
-});
-NodeList.method('push', function (node) {
-       var idx = this.length;
-       this[idx] = node;
-       this.length++;
-       return this[idx];
-});
-
-
-
-
-// NamedNodeMap interface
-function NamedNodeMap () {
-       this.length = 0;
-       this._nodes = {};
-       this._ns_nodes = {};
-       //log_stdout(' --  NamedNodeMap constructor');
-}
-
-NamedNodeMap.method('item', function (idx) {
-       return this.getNamedItem(idx);
-});
-
-NamedNodeMap.method('removeNamedItemNS', function (ns, name) {
-       var x = this._ns_nodes[ns][name];
-       for (var i in this._nodes) {
-               if (this._nodes[i] === x) {
-                       this._nodes[i] = null;
-               }
-       }
-       this._ns_nodes[ns][name] = null;
-       return x;
-});
-
-NamedNodeMap.method('removeNamedItem', function (name) {
-       var x = this._nodes[name];
-       for (var i in this._nodes) {
-               if (this._nodes[i] === x) {
-                       this._nodes[i] = null;
-               }
-       }
-       return x;
-});
-
-NamedNodeMap.method('getNamedItem', function (name) {
-       return this._nodes[name];
-});
-
-NamedNodeMap.method('getNamedItemNS', function (ns,name) {
-       return this._ns_nodes[ns][name];
-});
-
-NamedNodeMap.method('setNamedItem', function (node) {
-       if (node.nodeName == 'length') return null;
-       this[node.nodeName] = node.value;
-       this[this.length] = node.value;
-       this._nodes[node.nodeName] = node;
-       this._nodes[this.length] = node;
-       this.length++;
-});
-
-NamedNodeMap.method('setNamedItemNS', function (node) {
-       if (node.nodeName == 'length') return null;
-       this[this.length] = node.value;
-       if (!this._ns_nodes[node.namespaceURI]) this._ns_nodes[node.namespaceURI] = {};
-       this._ns_nodes[node.namespaceURI][node.nodeName] = node;
-       this._nodes[this.length] = node;
-       this.length++;
-});
-
-// Node interface
-function Node (name) {
-       this.nodeName = name;
-       this.nodeValue = null;
-       this.nodeType = null;
-       this.parentNode = null;
-       this.childNodes = new NodeList();
-       this.firstChild = null;
-       this.lastChild = null;
-       this.previousSibling = null;
-       this.nextSibling = null;
-       this.attributes = new NamedNodeMap();
-       this.ownerDocument = null;
-       this.namespaceURI = null;
-
-       if (name) {
-               var p = name.indexOf(':');
-               if (p != -1) {
-                       this.prefix = name.substring(0,p);
-                       this.localName = name.substring(p + 1);
-               } else {
-                       this.localName = name;
-               }
-       }
-
-       //log_stdout(' --  Node constructor');
-}
-Node.ELEMENT_NODE = 1;
-Node.ATTRIBUTE_NODE = 2;
-Node.TEXT_NODE = 3;
-Node.CDATA_SECTION_NODE = 4;
-Node.ENTITY_REFERENCE_NODE = 5;
-Node.ENTITY_NODE = 6;
-Node.PROCESSING_INSTRUCTION_NODE = 7;
-Node.COMMENT_NODE = 8;
-Node.DOCUMENT_NODE = 9;
-Node.DOCUMENT_TYPE_NODE = 10;
-Node.DOCUMENT_FRAGMENT_NODE = 11;
-Node.NOTATION_NODE = 12;
-Node.NAMESPACE_DECL = 18;
-
-Node.method('_childIndex', function (node) {
-       for (var i = 0; i < this.childNodes.length; i++)
-               if (this.childNodes[i] === node) return i;
-});
-Node.method('insertBefore', function (node, target) {
-
-       if (node.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
-               for (var i = 0; i < node.childNodes.length; i++)
-                       this.insertBefore(node.childNodes.item(i));
-               return node;
-       }
-
-       node.parentNode = this;
-       node.ownerDocument = this.ownerDocument;
-       var i = this._childIndex(target);
-
-       for (var j = this.childNodes.length; j > i; j--)
-               this.childNodes[j] = this.childNodes[j - 1];
-
-       this.childNodes[i] = node;
-
-       if (i == 0) {
-               this.firstChild = node;
-       } else {
-               this.childNodes[i - 1].nextSibling = node;
-               node.previousSibling = this.childNodes[i + 1];
-       }
-
-       this.childNodes[i + 1].previousSibling = node;
-       node.nextSibling = this.childNodes[i + 1];
-       
-       node._index = this.ownerDocument._nodes.length;
-       this.ownerDocument._nodes[this.ownerDocument._nodes.length] = node;
-
-       this.childNodes.length++;
-       return node;
-});
-
-Node.method('removeChild', function (node) {
-       node.parentNode = this;
-       node.ownerDocument = this.ownerDocument;
-       var i = this._childIndex(node);
-
-       if (node === this.firstChild) {
-               this.firstChild = node.nextSibling;
-       } else {
-               node.previousSibling.nextSibling = node.nextSibling;
-               for (var j = i; j < this.childNodes.length; j++)
-                       this.childNodes[j - 1] = this.childNodes[j];
-       }
-
-       if (node === this.lastChild) {
-               this.lastChild = node.previousSibling;
-       } else {
-               node.nextSibling.previousSibling = node.previousSibling;
-       }
-
-       this.ownerDocument._nodes[node._index] = null;
-       
-       this.childNodes.length--;
-       return node;
-});
-
-Node.method('appendChild', function (node) {
-
-       if (node.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
-               for (var i = 0; i < node.childNodes.length; i++)
-                       this.appendChild(node.childNodes.item(i));
-               return node;
-       }
-
-       node.parentNode = this;
-       this.childNodes.push( node );
-       this.lastChild = node;
-       if (this.childNodes.length == 1) {
-               this.firstChild = node;
-       } else {
-               this.lastChild.previousSibling = this.childNodes[this.childNodes.length - 2]
-               this.lastChild.previousSibling.nextSibling = this.lastChild;
-       }
-
-       return node;
-});
-
-Node.method('hasChildNodes', function () {
-       if (this.childNodes.length) return true;
-       return false;
-});
-
-Node.method('hasAttributes', function () {
-       if (this.attributes.length) return true;
-       return false;
-});
-
-Node.method('cloneNode', function (deep) {
-       //log_stdout(this.constructor);
-       var newNode = new this.constructor( this.nodeName );
-       newNode.ownerDocument = this.ownerDocument;
-       newNode.namespaceURI = this.namespaceURI;
-       newNode.prefix = this.prefix;
-
-       if (deep) {
-               for (var i = 0; i < this.childNodes.length; i++)
-                       newNode.appendChild( this.childNodes.item(i).cloneNode(deep) );
-       }
-
-       for (var i = 0; i < this.attributes.length; i++)
-               newNode.attributes.setNamedItem( this.attributes.item(i) );
-
-       return newNode;
-});
-
-function DocumentType (n,p,s) {
-       this.uber('constructor');
-       this.constructor = DocumentType;
-       this.nodeType = Node.DOCUMENT_TYPE_NODE;
-       this.name = n;
-       this.entities = new NamedNodeMap();
-       this.notations = new NamedNodeMap();
-       this.publicId = p;
-       this.systemId = s;
-       this.internalSubset = null;
-}
-DocumentType.inherits(Node);
-
-function Notation (p, s) {
-       this.uber('constructor');
-       this.constructor = Notation;
-       this.nodeType = Node.NOTATION_NODE;
-       this.publicId = p;
-       this.systemId = s;
-}
-Notation.inherits(Node);
-
-function ProcessingInstruction (target, data) {
-       this.uber('constructor');
-       this.constructor = ProcessingInstruction;
-       this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
-       this.target = target;
-       this.data = data;
-}
-ProcessingInstruction.inherits(Node);
-
-function Entity (p, s, n) {
-       this.uber('constructor');
-       this.constructor = Entity;
-       this.nodeType = Node.ENTITY_NODE;
-       this.publicId = p;
-       this.systemId = s;
-       this.notationName = n;
-}
-Entity.inherits(Node);
-
-function EntityReference () {
-       this.uber('constructor');
-       this.constructor = EntityReference;
-       this.nodeType = Node.ENTITY_REFERENCE_NODE;
-}
-EntityReference.inherits(Node);
-
-// Document interface
-function Document (dt) {
-       this.uber('constructor');
-       this.constructor = Document;
-       this.nodeType = Node.DOCUMENT_NODE;
-       this.doctype = dt;
-       this.documentElement = null;
-       this.implementation = new DOMImplementation();
-       this._nodes = [];
-       //log_stdout(' --  Document constructor');
-}
-
-Document.inherits(Node);
-Document.method('createAttribute', function (tagName) {
-       var node = new Attr(tagName);
-       node.ownerDocument = this;
-       return node;
-});
-
-Document.method('createAttributeNS', function (ns,tagName) {
-       var node = this.createAttribute(tagName);
-       node.namespaceURI = ns;
-       return node;
-});
-
-Document.method('createElement', function (tagName) {
-       var node = new Element(tagName);
-       node.ownerDocument = this;
-       node._index = this._nodes.length;
-       this._nodes[this._nodes.length] = node;
-       return node;
-});
-
-Document.method('createElementNS', function (ns,tagName) {
-       var node = this.createElement(tagName);
-       node.namespaceURI = ns;
-       return node;
-});
-
-Document.method('importNode', function (node, deep) {
-       var tmp = node.clone(deep);
-       tmp.ownerDocument = this;
-       var newNode = tmp.cloneNode(deep);
-       return newNode;
-});
-
-Document.method('createDocumentFragment', function () {
-       var x = new Node();
-       x.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
-       x.ownerDocument = this;
-});
-
-Document.method('createTextNode', function (content) {
-       var node = new Text(content);
-       node.ownerDocument = this;
-       return node;
-});
-
-Document.method('createComment', function (content) {
-       var node = new Comment(content);
-       node.ownerDocument = this;
-       return node;
-});
-
-Document.method('createCDATASection', function (content) {
-       var node = new CDATASection(content);
-       node.ownerDocument = this;
-       return node;
-});
-
-Document.method('getElementById', function (id) {
-       for (var i in this._nodes) {
-               //log_stdout(' id = ' + this._nodes[i].attributes.id);
-               if (this._nodes[i] && this._nodes[i].attributes.id == id)
-                       return this._nodes[i];
-       }
-       return null;
-});
-
-Document.method('getElementsByTagName', function (tname) {
-       var list = new NodeList();
-       this.documentElement.getElementsByTagName(tname, list);
-       return list;
-});
-
-Document.method('getElementsByTagNameNS', function (ns, tname) {
-       var list = new NodeList();
-       this.documentElement.getElementsByTagNameNS(ns, tname, list);
-       return list;
-});
-
-// Attr interface
-function Attr ( name, value ) {
-       this.uber('constructor',name);
-       this.constructor = Attr;
-       this.nodeType = Node.ATTRIBUTE_NODE;
-       this.name = name;
-       this.value = this.nodeValue = value;
-       this.specified = (this.value ? true : false);
-       this.ownerElement = null;
-       //log_stdout(' --  Attr constructor');
-}
-Attr.inherits(Node);
-
-
-// Element interface
-function Element ( name ) {
-       this.uber('constructor',name);
-       this.constructor = Element;
-       this.nodeType = Node.ELEMENT_NODE;
-       this.tagName = name;
-       //log_stdout(' --  Element constructor')
-}
-Element.inherits(Node);
-
-Element.method('getAttribute', function (aname) {
-       var x = this.attributes.getNamedItem(aname);
-       if (x) return x.value;
-       return null;
-});
-
-Element.method('setAttribute', function (aname,aval) {
-       var attr = new Attr(aname, aval);
-       attr.ownerElement = this;
-       return this.attributes.setNamedItem(attr);
-});
-
-Element.method('removeAttribute', function (aname) {
-       this.attributes.removeNamedItem(aname);
-       return null;
-});
-
-Element.method('getAttributeNode', function (aname) {
-       return this.attributes.getNamedItem(aname);
-});
-
-Element.method('setAttributeNode', function (attr) {
-       attr.ownerElement = this;
-       attr.namespaceURI = (attr.namespaceURI ? attr.namespaceURI : this.namespaceURI);
-       return this.attributes.setNamedItem(attr);
-});
-
-Element.method('removeAttributeNode', function (attr) {
-       if (attr.namespaceURI) {
-               return this.attributes.removeNamedItemNS(attr.namespaceURI, attr.name);
-       } else {
-               return this.attributes.removeNamedItem(attr.name);
-       }
-});
-
-Element.method('getAttributeNS', function (ns,aname) {
-       var x = this.attributes.getNamedItemNS(ns,aname);
-       if (x) return x.value;
-       return null;
-});
-
-Element.method('setAttributeNS', function (ns,aname,aval) {
-       var attr = new Attr(aname, aval);
-       attr.ownerElement = this;
-       attr.namespaceURI = ns;
-       return this.attributes.setNamedItem(ns,attr);
-});
-
-Element.method('removeAttributeNS', function (ns,aname) {
-       this.attributes.removeNamedItemNS(ns,aname);
-       return null;
-});
-
-Element.method('getAttributeNodeNS', function (ns, aname) {
-       return this.attributes.getNamedItemNS(ns,aname);
-});
-
-Element.method('setAttributeNodeNS', function (attr) {
-       attr.ownerElement = this;
-       attr.namespaceURI = (attr.namespaceURI ? attr.namespaceURI : this.namespaceURI);
-       return this.attributes.setNamedItemNS(attr);
-});
-
-Element.method('hasAttribute', function (name) {
-       return ( this.getAttribute(name) ? true : false );
-});
-
-Element.method('hasAttributeNS', function (ns, name) {
-       return ( this.getAttributeNS(ns, name) ? true : false );
-});
-
-Element.method('getElementsByTagName', function (tname, list) {
-       if (!list) list = new NodeList();
-       if (this.tagName == tname) list.push(this);
-       //log_stdout(' --  ' + this.tagName + ' :: ' + this.childNodes.length);
-       for (var i = 0;  i < this.childNodes.length; i++) {
-               if (this.childNodes.item(i).nodeType == 1)
-                       this.childNodes.item(i).getElementsByTagName(tname, list);
-       }
-       return list;
-});
-
-Element.method('getElementsByTagNameNS', function (ns, tname, list) {
-       if (!list) list = new NodeList();
-       if (this.localName == tname && this.namespaceURI == ns) list.push(this);
-       //log_stdout(' --  {' + this.namespaceURI + '}:' + this.localName + ' :: ' + this.childNodes.length);
-       for (var i = 0;  i < this.childNodes.length; i++) {
-               if (this.childNodes.item(i).nodeType == 1)
-                       this.childNodes.item(i).getElementsByTagNameNS(ns, tname, list);
-       }
-       return list;
-});
-
-
-// CharacterData interface
-function CharacterData ( name, content ) {
-       this.uber('constructor', name);
-       this.constructor = CharacterData;
-       this.setData(content);
-       //log_stdout(' --  CharacterData constructor');
-       //log_stdout(' --  CharacterData length == ' + this.length + ' :: ' + this.data);
-}
-CharacterData.inherits(Node);
-
-CharacterData.method('setData', function (content) {
-       this.data = this.nodeValue = content;
-       if (this.data)
-               this.length = this.data.length;
-});
-CharacterData.method('substringData', function (offset,count) {
-       this.data.substring(offset,count);
-});
-CharacterData.method('appendData', function (txt) {
-       this.data = this.nodeValue = this.data + txt;
-       this.length = this.data.length;
-});
-CharacterData.method('insertData', function (offset,txt) {
-       var b = this.data.substring(0,offset);
-       var a = this.data.substring(offset);
-       this.data = this.nodeValue = b + txt + a;
-       this.length = this.data.length;
-});
-CharacterData.method('deleteData', function (offset,count) {
-       var b = this.data.substring(0,offset);
-       var a = this.data.substring(offset + count);
-       this.data = this.nodeValue = b + a;
-       this.length = this.data.length;
-});
-CharacterData.method('replaceData', function (offset,count,txt) {
-       var b = this.data.substring(0,offset);
-       var a = this.data.substring(offset + count);
-       this.data = this.nodeValue = b + txt +  a;
-       this.length = this.data.length;
-});
-
-
-
-// Text interface
-function Text ( content ) {
-       this.superclass.constructor.call(this, '#text', content);
-       this.constructor = Text;
-       this.nodeType = Node.TEXT_NODE;
-       //log_stdout(' --  Text constructor :: ' + this.data);
-}
-Text.inherits(CharacterData);
-
-
-// CDATASection interface
-function CDATASection ( content ) {
-       this.uber('constructor', '#cdata', content);
-       this.constructor = CDATASection;
-       this.nodeType = Node.COMMENT_NODE;
-       //log_stdout(' --  Comment constructor');
-}
-CDATASection.inherits(Text);
-
-// Comment interface
-function Comment ( content ) {
-       this.uber('constructor', '#comment', content);
-       this.constructor = Comment;
-       this.nodeType = Node.COMMENT_NODE;
-       //log_stdout(' --  Comment constructor');
-}
-Comment.inherits(Text);
-
-
-
-//////////////////////// XPath stuff /////////////////////////
-
-function XPathNamespaceResolver (data) {
-       this.data = data;
-}
-XPathNamespaceResolver.inherits(NamespaceResolver);
-
-XPathNamespaceResolver.method('lookupNamespaceURI', function (prefix) {
-       return this.data[prefix];
-});
-XPathNamespaceResolver.method('setNamespaceURI', function (prefix, uri) {
-       this.data[prefix] = uri;
-});
-
diff --git a/Open-ILS/src/javascript/backend/libs/jsOO.js b/Open-ILS/src/javascript/backend/libs/jsOO.js
deleted file mode 100644 (file)
index d40321c..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Function.prototype.method = function (name, func) {
-    this.prototype[name] = func;
-    return this;
-}
-
-Function.method('inherits', function (parent) {
-    var d = 0, p = (this.prototype = new parent());
-    this.constructor = this;
-    this.prototype.superclass = parent;
-    this.method('uber', function uber(name) {
-        var f, r, t = d, v = parent.prototype;
-        if (t) {
-            while (t) {
-                v = v.constructor.prototype;
-                t -= 1;
-            }
-            f = v[name];
-        } else {
-            f = p[name];
-            if (f == this[name]) {
-                f = v[name];
-            }
-        }
-        d += 1;
-        r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
-        d -= 1;
-        return r;
-    });
-    return this;
-});
-
-
-instance_of = function(o, c) {
-       while (o != null) {
-               if (o.constructor === c) {
-                       return true;
-               }
-               if (o === Object) {
-                       return false;
-               }
-               o = o.superclass;
-       }
-       return false;
-};
-
-
diff --git a/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js b/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js
deleted file mode 100644 (file)
index 7f2de1d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-try {
-       load_lib('jsOO.js');
-       load_lib('JSON_v1.js');
-} catch (e) {}
-
-var __jsonopensrfreqid = 1;
-var __jsonopensrfreq_hash = {};
-
-function JSONOpenSRFRequest () {
-        // Cache this for later ...
-        this._hash_id = __jsonopensrfreqid;
-        __jsonopensrfreqid++;
-}
-
-JSONOpenSRFRequest.method('create',function (service) {
-        this._service = service;
-        __jsonopensrfreq_hash['id' + this._hash_id] = {};
-});
-
-JSONOpenSRFRequest.method('open',function (service, method, async) {
-        this._service = service;
-        this._method = method;
-        this._async = (async ? 1 : 0);
-        __jsonopensrfreq_hash['id' + this._hash_id] = {};
-});
-
-JSONOpenSRFRequest.method('close',function () {
-        this._service = null;
-        this._method = null;
-        this._async = null;
-        __jsonopensrfreq_hash['id' + this._hash_id] = {};
-});
-
-JSONOpenSRFRequest.method('call',function (method, async) {
-        this._method = method;
-        this._async = (async ? 1 : 0);
-});
-
-JSONOpenSRFRequest.method('connect', function (service) {
-
-        if (service) this._service = service;
-
-       if (!this._service)
-               throw "call .open with a service before calling .connect";
-       try {
-               _OILS_FUNC_jsonopensrfrequest_connect(this._hash_id,this._service);
-       } catch (e) {
-               alert("Sorry, no JSONOpenSRFRequest support");
-       }
-
-        this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
-});
-
-JSONOpenSRFRequest.method('disconnect', function () {
-
-       if (!this._service)
-               throw "call .connect before calling .disconnect";
-       try {
-               _OILS_FUNC_jsonopensrfrequest_disconnect(this._hash_id);
-       } catch (e) {
-               alert("Sorry, no JSONOpenSRFRequest support");
-       }
-
-        this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
-});
-
-JSONOpenSRFRequest.method('finish', function () {
-
-       if (!this._service)
-               throw "call .connect before calling .finish";
-       try {
-               _OILS_FUNC_jsonopensrfrequest_disconnect(this._hash_id);
-               _OILS_FUNC_jsonopensrfrequest_finish(this._hash_id);
-       } catch (e) {
-               alert("Sorry, no JSONOpenSRFRequest support");
-       }
-
-        this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
-});
-
-JSONOpenSRFRequest.method('send', function () {
-
-       if (!this._service)
-               throw "call .open with a service and a method before calling .send";
-
-       var data = [];
-       for (var i = 0; i < arguments.length; i++) {
-               data[i] = arguments[i];
-       }
-
-       try {
-               //log_debug( this._hash_id + " -> " + this._service + " -> " + this._method + " -> " + this._async + " -> " + js2JSON(data));
-               _OILS_FUNC_jsonopensrfrequest_send(this._hash_id,this._service,this._method,this._async,js2JSON(data));
-       } catch (e) {
-               alert("Sorry, no JSONOpenSRFRequest support");
-       }
-
-        this.responseText = __jsonopensrfreq_hash['id' + this._hash_id].responseText;
-        this.readyState = __jsonopensrfreq_hash['id' + this._hash_id].readyState;
-        this.status = __jsonopensrfreq_hash['id' + this._hash_id].status;
-        this.statusText = __jsonopensrfreq_hash['id' + this._hash_id].statusText;
-        this.responseJSON = JSON2js(this.responseText);
-
-        if (this._async)
-                this.onreadystatechange();
-});
-
-
diff --git a/Open-ILS/src/javascript/backend/libs/xmlhttprequest.js b/Open-ILS/src/javascript/backend/libs/xmlhttprequest.js
deleted file mode 100644 (file)
index 51594e9..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-try {
-       load_lib('jsOO.js');
-       load_lib('jsDOM.js');
-} catch (e) {}
-
-var __xmlhttpreqid = 1;
-var __xmlhttpreq_hash = {};
-
-function XMLHttpRequest () {
-        // Cache this for later ...
-        this._hash_id = __xmlhttpreqid;
-        __xmlhttpreqid++;
-}
-
-XMLHttpRequest.method('open',function (method, url, async) {
-        this._method = method;
-        this._url = url;
-        this._async = (async ? 1 : 0);
-});
-
-XMLHttpRequest.method('setRequestHeader', function (header, header_value) {
-        if (!this._headers) this._headers = {}
-        this._headers[header] = header_value;
-});
-
-XMLHttpRequest.method('send', function (data) {
-
-        var headerlist = '';
-        for (var i in this._headers) {
-                headerlist = headerlist + '\n' + i + '|' + this._headers[i];
-        }
-
-        __xmlhttpreq_hash['id' + this._hash_id] = {};
-
-       try {
-               _OILS_FUNC_xmlhttprequest_send(this._hash_id,this._method,this._url,this._async,headerlist,data);
-       } catch (e) {
-               alert("Sorry, no XMLHttpRequest support");
-       }
-
-        this.responseText = __xmlhttpreq_hash['id' + this._hash_id].responseText;
-        this.readyState = __xmlhttpreq_hash['id' + this._hash_id].readyState;
-        this.status = __xmlhttpreq_hash['id' + this._hash_id].status;
-        this.statusText = __xmlhttpreq_hash['id' + this._hash_id].statusText;
-        this.responseXML = DOMImplementation.parseString(this.responseText);
-
-        if (this._async)
-                this.onreadystatechange();
-});
-
-
diff --git a/Open-ILS/src/javascript/backend/libs/xpath.js b/Open-ILS/src/javascript/backend/libs/xpath.js
deleted file mode 100644 (file)
index 25bbcfc..0000000
+++ /dev/null
@@ -1,4290 +0,0 @@
-/*
- * xpath.js
- *
- * An XPath 1.0 library for JavaScript.
- *
- * Cameron McCormack <cam (at) mcc.id.au>
- *
- * This work is licensed under the Creative Commons Attribution-ShareAlike
- * License. To view a copy of this license, visit
- * 
- *   http://creativecommons.org/licenses/by-sa/2.0/
- *
- * or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford,
- * California 94305, USA.
- *
- *
- * Patch m1: January 13, 2006
- *   Forcing namespace resolution for default namespaces.  In the current
- *   code the default namespace (no prefix) is the same as no namespace,
- *   but AFAICT this is incorrect.  If a node has a namespaceURI then it
- *   should be used, and the expression should use the NamespaceResolver
- *   to match the node's namespaceURI.
- *
- *   On a more positive note, I am using this library to test the correctness
- *   of my pure-JS DOM implementation for use in libjs environments.  You can
- *   currently find that at
- *   http://open-ils.org/cgi-bin/viewcvs.cgi/ILS/Open-ILS/src/javascript/backend/libs/jsDOM.js
- *
- * Revision 19: November 29, 2005
- *   Nodesets now store their nodes in a height balanced tree, increasing
- *   performance for the common case of selecting nodes in document order,
- *   thanks to Sébastien Cramatte <contact (at) zeninteractif.com>.
- *   AVL tree code adapted from Raimund Neumann <rnova (at) gmx.net>.
- *
- * Revision 18: October 27, 2005
- *   DOM 3 XPath support.  Caveats:
- *     - namespace prefixes aren't resolved in XPathEvaluator.createExpression,
- *       but in XPathExpression.evaluate.
- *     - XPathResult.invalidIteratorState is not implemented.
- *
- * Revision 17: October 25, 2005
- *   Some core XPath function fixes and a patch to avoid crashing certain
- *   versions of MSXML in PathExpr.prototype.getOwnerElement, thanks to
- *   Sébastien Cramatte <contact (at) zeninteractif.com>.
- *
- * Revision 16: September 22, 2005
- *   Workarounds for some IE 5.5 deficiencies.
- *   Fixed problem with prefix node tests on attribute nodes.
- *
- * Revision 15: May 21, 2005
- *   Fixed problem with QName node tests on elements with an xmlns="...".
- *
- * Revision 14: May 19, 2005
- *   Fixed QName node tests on attribute node regression.
- *
- * Revision 13: May 3, 2005
- *   Node tests are case insensitive now if working in an HTML DOM.
- *
- * Revision 12: April 26, 2005
- *   Updated licence.  Slight code changes to enable use of Dean
- *   Edwards' script compression, http://dean.edwards.name/packer/ .
- *
- * Revision 11: April 23, 2005
- *   Fixed bug with 'and' and 'or' operators, fix thanks to
- *   Sandy McArthur <sandy (at) mcarthur.org>.
- *
- * Revision 10: April 15, 2005
- *   Added support for a virtual root node, supposedly helpful for
- *   implementing XForms.  Fixed problem with QName node tests and
- *   the parent axis.
- *
- * Revision 9: March 17, 2005
- *   Namespace resolver tweaked so using the document node as the context
- *   for namespace lookups is equivalent to using the document element.
- *
- * Revision 8: February 13, 2005
- *   Handle implicit declaration of 'xmlns' namespace prefix.
- *   Fixed bug when comparing nodesets.
- *   Instance data can now be associated with a FunctionResolver, and
- *     workaround for MSXML not supporting 'localName' and 'getElementById',
- *     thanks to Grant Gongaware.
- *   Fix a few problems when the context node is the root node.
- *   
- * Revision 7: February 11, 2005
- *   Default namespace resolver fix from Grant Gongaware
- *   <grant (at) gongaware.com>.
- *
- * Revision 6: February 10, 2005
- *   Fixed bug in 'number' function.
- *
- * Revision 5: February 9, 2005
- *   Fixed bug where text nodes not getting converted to string values.
- *
- * Revision 4: January 21, 2005
- *   Bug in 'name' function, fix thanks to Bill Edney.
- *   Fixed incorrect processing of namespace nodes.
- *   Fixed NamespaceResolver to resolve 'xml' namespace.
- *   Implemented union '|' operator.
- *
- * Revision 3: January 14, 2005
- *   Fixed bug with nodeset comparisons, bug lexing < and >.
- *
- * Revision 2: October 26, 2004
- *   QName node test namespace handling fixed.  Few other bug fixes.
- *   
- * Revision 1: August 13, 2004
- *   Bug fixes from William J. Edney <bedney (at) technicalpursuit.com>.
- *   Added minimal licence.
- *
- * Initial version: June 14, 2004
- */
-
-// XPathParser ///////////////////////////////////////////////////////////////
-
-XPathParser.prototype = new Object();
-XPathParser.prototype.constructor = XPathParser;
-XPathParser.superclass = Object.prototype;
-
-function XPathParser() {
-       this.init();
-}
-
-XPathParser.prototype.init = function() {
-       this.reduceActions = [];
-
-       this.reduceActions[3] = function(rhs) {
-               return new OrOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[5] = function(rhs) {
-               return new AndOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[7] = function(rhs) {
-               return new EqualsOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[8] = function(rhs) {
-               return new NotEqualOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[10] = function(rhs) {
-               return new LessThanOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[11] = function(rhs) {
-               return new GreaterThanOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[12] = function(rhs) {
-               return new LessThanOrEqualOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[13] = function(rhs) {
-               return new GreaterThanOrEqualOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[15] = function(rhs) {
-               return new PlusOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[16] = function(rhs) {
-               return new MinusOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[18] = function(rhs) {
-               return new MultiplyOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[19] = function(rhs) {
-               return new DivOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[20] = function(rhs) {
-               return new ModOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[22] = function(rhs) {
-               return new UnaryMinusOperation(rhs[1]);
-       };
-       this.reduceActions[24] = function(rhs) {
-               return new BarOperation(rhs[0], rhs[2]);
-       };
-       this.reduceActions[25] = function(rhs) {
-               return new PathExpr(undefined, undefined, rhs[0]);
-       };
-       this.reduceActions[27] = function(rhs) {
-               rhs[0].locationPath = rhs[2];
-               return rhs[0];
-       };
-       this.reduceActions[28] = function(rhs) {
-               rhs[0].locationPath = rhs[2];
-               rhs[0].locationPath.steps.unshift(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
-               return rhs[0];
-       };
-       this.reduceActions[29] = function(rhs) {
-               return new PathExpr(rhs[0], [], undefined);
-       };
-       this.reduceActions[30] = function(rhs) {
-               if (Utilities.instance_of(rhs[0], PathExpr)) {
-                       if (rhs[0].filterPredicates == undefined) {
-                               rhs[0].filterPredicates = [];
-                       }
-                       rhs[0].filterPredicates.push(rhs[1]);
-                       return rhs[0];
-               } else {
-                       return new PathExpr(rhs[0], [rhs[1]], undefined);
-               }
-       };
-       this.reduceActions[32] = function(rhs) {
-               return rhs[1];
-       };
-       this.reduceActions[33] = function(rhs) {
-               return new XString(rhs[0]);
-       };
-       this.reduceActions[34] = function(rhs) {
-               return new XNumber(rhs[0]);
-       };
-       this.reduceActions[36] = function(rhs) {
-               return new FunctionCall(rhs[0], []);
-       };
-       this.reduceActions[37] = function(rhs) {
-               return new FunctionCall(rhs[0], rhs[2]);
-       };
-       this.reduceActions[38] = function(rhs) {
-               return [ rhs[0] ];
-       };
-       this.reduceActions[39] = function(rhs) {
-               rhs[2].unshift(rhs[0]);
-               return rhs[2];
-       };
-       this.reduceActions[43] = function(rhs) {
-               return new LocationPath(true, []);
-       };
-       this.reduceActions[44] = function(rhs) {
-               rhs[1].absolute = true;
-               return rhs[1];
-       };
-       this.reduceActions[46] = function(rhs) {
-               return new LocationPath(false, [ rhs[0] ]);
-       };
-       this.reduceActions[47] = function(rhs) {
-               rhs[0].steps.push(rhs[2]);
-               return rhs[0];
-       };
-       this.reduceActions[49] = function(rhs) {
-               return new Step(rhs[0], rhs[1], []);
-       };
-       this.reduceActions[50] = function(rhs) {
-               return new Step(Step.CHILD, rhs[0], []);
-       };
-       this.reduceActions[51] = function(rhs) {
-               return new Step(rhs[0], rhs[1], rhs[2]);
-       };
-       this.reduceActions[52] = function(rhs) {
-               return new Step(Step.CHILD, rhs[0], rhs[1]);
-       };
-       this.reduceActions[54] = function(rhs) {
-               return [ rhs[0] ];
-       };
-       this.reduceActions[55] = function(rhs) {
-               rhs[1].unshift(rhs[0]);
-               return rhs[1];
-       };
-       this.reduceActions[56] = function(rhs) {
-               if (rhs[0] == "ancestor") {
-                       return Step.ANCESTOR;
-               } else if (rhs[0] == "ancestor-or-self") {
-                       return Step.ANCESTORORSELF;
-               } else if (rhs[0] == "attribute") {
-                       return Step.ATTRIBUTE;
-               } else if (rhs[0] == "child") {
-                       return Step.CHILD;
-               } else if (rhs[0] == "descendant") {
-                       return Step.DESCENDANT;
-               } else if (rhs[0] == "descendant-or-self") {
-                       return Step.DESCENDANTORSELF;
-               } else if (rhs[0] == "following") {
-                       return Step.FOLLOWING;
-               } else if (rhs[0] == "following-sibling") {
-                       return Step.FOLLOWINGSIBLING;
-               } else if (rhs[0] == "namespace") {
-                       return Step.NAMESPACE;
-               } else if (rhs[0] == "parent") {
-                       return Step.PARENT;
-               } else if (rhs[0] == "preceding") {
-                       return Step.PRECEDING;
-               } else if (rhs[0] == "preceding-sibling") {
-                       return Step.PRECEDINGSIBLING;
-               } else if (rhs[0] == "self") {
-                       return Step.SELF;
-               }
-               return -1;
-       };
-       this.reduceActions[57] = function(rhs) {
-               return Step.ATTRIBUTE;
-       };
-       this.reduceActions[59] = function(rhs) {
-               if (rhs[0] == "comment") {
-                       return new NodeTest(NodeTest.COMMENT, undefined);
-               } else if (rhs[0] == "text") {
-                       return new NodeTest(NodeTest.TEXT, undefined);
-               } else if (rhs[0] == "processing-instruction") {
-                       return new NodeTest(NodeTest.PI, undefined);
-               } else if (rhs[0] == "node") {
-                       return new NodeTest(NodeTest.NODE, undefined);
-               }
-               return new NodeTest(-1, undefined);
-       };
-       this.reduceActions[60] = function(rhs) {
-               return new NodeTest(NodeTest.PI, rhs[2]);
-       };
-       this.reduceActions[61] = function(rhs) {
-               return rhs[1];
-       };
-       this.reduceActions[63] = function(rhs) {
-               rhs[1].absolute = true;
-               rhs[1].steps.unshift(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
-               return rhs[1];
-       };
-       this.reduceActions[64] = function(rhs) {
-               rhs[0].steps.push(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
-               rhs[0].steps.push(rhs[2]);
-               return rhs[0];
-       };
-       this.reduceActions[65] = function(rhs) {
-               return new Step(Step.SELF, new NodeTest(NodeTest.NODE, undefined), []);
-       };
-       this.reduceActions[66] = function(rhs) {
-               return new Step(Step.PARENT, new NodeTest(NodeTest.NODE, undefined), []);
-       };
-       this.reduceActions[67] = function(rhs) {
-               return new VariableReference(rhs[1]);
-       };
-       this.reduceActions[68] = function(rhs) {
-               return new NodeTest(NodeTest.NAMETESTANY, undefined);
-       };
-       this.reduceActions[69] = function(rhs) {
-               var prefix = rhs[0].substring(0, rhs[0].indexOf(":"));
-               return new NodeTest(NodeTest.NAMETESTPREFIXANY, prefix);
-       };
-       this.reduceActions[70] = function(rhs) {
-               return new NodeTest(NodeTest.NAMETESTQNAME, rhs[0]);
-       };
-};
-
-XPathParser.actionTable = [
-       " s s        sssssssss    s ss  s  ss",
-       "                 s                  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "                rrrrr               ",
-       " s s        sssssssss    s ss  s  ss",
-       "rs  rrrrrrrr s  sssssrrrrrr  rrs rs ",
-       " s s        sssssssss    s ss  s  ss",
-       "                            s       ",
-       "                            s       ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "  s                                 ",
-       "                            s       ",
-       " s           s  sssss          s  s ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "a                                   ",
-       "r       s                    rr  r  ",
-       "r      sr                    rr  r  ",
-       "r   s  rr            s       rr  r  ",
-       "r   rssrr            rss     rr  r  ",
-       "r   rrrrr            rrrss   rr  r  ",
-       "r   rrrrrsss         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrrs  rr  r  ",
-       "r   rrrrrrrr         rrrrrr  rr  r  ",
-       "r   rrrrrrrr         rrrrrr  rr  r  ",
-       "r  srrrrrrrr         rrrrrrs rr sr  ",
-       "r  srrrrrrrr         rrrrrrs rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r   rrrrrrrr         rrrrrr  rr  r  ",
-       "r   rrrrrrrr         rrrrrr  rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "                sssss               ",
-       "r  rrrrrrrrr         rrrrrrr rr sr  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "                             s      ",
-       "r  srrrrrrrr         rrrrrrs rr  r  ",
-       "r   rrrrrrrr         rrrrr   rr  r  ",
-       "              s                     ",
-       "                             s      ",
-       "                rrrrr               ",
-       " s s        sssssssss    s sss s  ss",
-       "r  srrrrrrrr         rrrrrrs rr  r  ",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s s        sssssssss      ss  s  ss",
-       " s s        sssssssss    s ss  s  ss",
-       " s           s  sssss          s  s ",
-       " s           s  sssss          s  s ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       " s           s  sssss          s  s ",
-       " s           s  sssss          s  s ",
-       "r  rrrrrrrrr         rrrrrrr rr sr  ",
-       "r  rrrrrrrrr         rrrrrrr rr sr  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "                             s      ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "                             rr     ",
-       "                             s      ",
-       "                             rs     ",
-       "r      sr                    rr  r  ",
-       "r   s  rr            s       rr  r  ",
-       "r   rssrr            rss     rr  r  ",
-       "r   rssrr            rss     rr  r  ",
-       "r   rrrrr            rrrss   rr  r  ",
-       "r   rrrrr            rrrss   rr  r  ",
-       "r   rrrrr            rrrss   rr  r  ",
-       "r   rrrrr            rrrss   rr  r  ",
-       "r   rrrrrsss         rrrrr   rr  r  ",
-       "r   rrrrrsss         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrr   rr  r  ",
-       "r   rrrrrrrr         rrrrrr  rr  r  ",
-       "                                 r  ",
-       "                                 s  ",
-       "r  srrrrrrrr         rrrrrrs rr  r  ",
-       "r  srrrrrrrr         rrrrrrs rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr  r  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       " s s        sssssssss    s ss  s  ss",
-       "r  rrrrrrrrr         rrrrrrr rr rr  ",
-       "                             r      "
-];
-
-XPathParser.actionTableNumber = [
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       "                 J                  ",
-       "a  aaaaaaaaa         aaaaaaa aa  a  ",
-       "                YYYYY               ",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       "K1  KKKKKKKK .  +*)('KKKKKK  KK# K\" ",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       "                            N       ",
-       "                            O       ",
-       "e  eeeeeeeee         eeeeeee ee ee  ",
-       "f  fffffffff         fffffff ff ff  ",
-       "d  ddddddddd         ddddddd dd dd  ",
-       "B  BBBBBBBBB         BBBBBBB BB BB  ",
-       "A  AAAAAAAAA         AAAAAAA AA AA  ",
-       "  P                                 ",
-       "                            Q       ",
-       " 1           .  +*)('          #  \" ",
-       "b  bbbbbbbbb         bbbbbbb bb  b  ",
-       "                                    ",
-       "!       S                    !!  !  ",
-       "\"      T\"                    \"\"  \"  ",
-       "$   V  $$            U       $$  $  ",
-       "&   &ZY&&            &XW     &&  &  ",
-       ")   )))))            )))\\[   ))  )  ",
-       ".   ....._^]         .....   ..  .  ",
-       "1   11111111         11111   11  1  ",
-       "5   55555555         55555`  55  5  ",
-       "7   77777777         777777  77  7  ",
-       "9   99999999         999999  99  9  ",
-       ":  c::::::::         ::::::b :: a:  ",
-       "I  fIIIIIIII         IIIIIIe II  I  ",
-       "=  =========         ======= == ==  ",
-       "?  ?????????         ??????? ?? ??  ",
-       "C  CCCCCCCCC         CCCCCCC CC CC  ",
-       "J   JJJJJJJJ         JJJJJJ  JJ  J  ",
-       "M   MMMMMMMM         MMMMMM  MM  M  ",
-       "N  NNNNNNNNN         NNNNNNN NN  N  ",
-       "P  PPPPPPPPP         PPPPPPP PP  P  ",
-       "                +*)('               ",
-       "R  RRRRRRRRR         RRRRRRR RR aR  ",
-       "U  UUUUUUUUU         UUUUUUU UU  U  ",
-       "Z  ZZZZZZZZZ         ZZZZZZZ ZZ ZZ  ",
-       "c  ccccccccc         ccccccc cc cc  ",
-       "                             j      ",
-       "L  fLLLLLLLL         LLLLLLe LL  L  ",
-       "6   66666666         66666   66  6  ",
-       "              k                     ",
-       "                             l      ",
-       "                XXXXX               ",
-       " 1 0        /.-,+*)('    & %$m #  \"!",
-       "_  f________         ______e __  _  ",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1 0        /.-,+*)('      %$  #  \"!",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       " 1           .  +*)('          #  \" ",
-       " 1           .  +*)('          #  \" ",
-       ">  >>>>>>>>>         >>>>>>> >> >>  ",
-       " 1           .  +*)('          #  \" ",
-       " 1           .  +*)('          #  \" ",
-       "Q  QQQQQQQQQ         QQQQQQQ QQ aQ  ",
-       "V  VVVVVVVVV         VVVVVVV VV aV  ",
-       "T  TTTTTTTTT         TTTTTTT TT  T  ",
-       "@  @@@@@@@@@         @@@@@@@ @@ @@  ",
-       "                             \x87      ",
-       "[  [[[[[[[[[         [[[[[[[ [[ [[  ",
-       "D  DDDDDDDDD         DDDDDDD DD DD  ",
-       "                             HH     ",
-       "                             \x88      ",
-       "                             F\x89     ",
-       "#      T#                    ##  #  ",
-       "%   V  %%            U       %%  %  ",
-       "'   'ZY''            'XW     ''  '  ",
-       "(   (ZY((            (XW     ((  (  ",
-       "+   +++++            +++\\[   ++  +  ",
-       "*   *****            ***\\[   **  *  ",
-       "-   -----            ---\\[   --  -  ",
-       ",   ,,,,,            ,,,\\[   ,,  ,  ",
-       "0   00000_^]         00000   00  0  ",
-       "/   /////_^]         /////   //  /  ",
-       "2   22222222         22222   22  2  ",
-       "3   33333333         33333   33  3  ",
-       "4   44444444         44444   44  4  ",
-       "8   88888888         888888  88  8  ",
-       "                                 ^  ",
-       "                                 \x8a  ",
-       ";  f;;;;;;;;         ;;;;;;e ;;  ;  ",
-       "<  f<<<<<<<<         <<<<<<e <<  <  ",
-       "O  OOOOOOOOO         OOOOOOO OO  O  ",
-       "`  `````````         ``````` ``  `  ",
-       "S  SSSSSSSSS         SSSSSSS SS  S  ",
-       "W  WWWWWWWWW         WWWWWWW WW  W  ",
-       "\\  \\\\\\\\\\\\\\\\\\         \\\\\\\\\\\\\\ \\\\ \\\\  ",
-       "E  EEEEEEEEE         EEEEEEE EE EE  ",
-       " 1 0        /.-,+*)('    & %$  #  \"!",
-       "]  ]]]]]]]]]         ]]]]]]] ]] ]]  ",
-       "                             G      "
-];
-
-XPathParser.gotoTable = [
-       "3456789:;<=>?@ AB  CDEFGH IJ ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "L456789:;<=>?@ AB  CDEFGH IJ ",
-       "            M        EFGH IJ ",
-       "       N;<=>?@ AB  CDEFGH IJ ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "            S        EFGH IJ ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "              e              ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                        h  J ",
-       "              i          j   ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "o456789:;<=>?@ ABpqCDEFGH IJ ",
-       "                             ",
-       "  r6789:;<=>?@ AB  CDEFGH IJ ",
-       "   s789:;<=>?@ AB  CDEFGH IJ ",
-       "    t89:;<=>?@ AB  CDEFGH IJ ",
-       "    u89:;<=>?@ AB  CDEFGH IJ ",
-       "     v9:;<=>?@ AB  CDEFGH IJ ",
-       "     w9:;<=>?@ AB  CDEFGH IJ ",
-       "     x9:;<=>?@ AB  CDEFGH IJ ",
-       "     y9:;<=>?@ AB  CDEFGH IJ ",
-       "      z:;<=>?@ AB  CDEFGH IJ ",
-       "      {:;<=>?@ AB  CDEFGH IJ ",
-       "       |;<=>?@ AB  CDEFGH IJ ",
-       "       };<=>?@ AB  CDEFGH IJ ",
-       "       ~;<=>?@ AB  CDEFGH IJ ",
-       "         \x7f=>?@ AB  CDEFGH IJ ",
-       "\x80456789:;<=>?@ AB  CDEFGH IJ\x81",
-       "            \x82        EFGH IJ ",
-       "            \x83        EFGH IJ ",
-       "                             ",
-       "                     \x84 GH IJ ",
-       "                     \x85 GH IJ ",
-       "              i          \x86   ",
-       "              i          \x87   ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "                             ",
-       "o456789:;<=>?@ AB\x8cqCDEFGH IJ ",
-       "                             ",
-       "                             "
-];
-
-XPathParser.productions = [
-       [1, 1, 2],
-       [2, 1, 3],
-       [3, 1, 4],
-       [3, 3, 3, -9, 4],
-       [4, 1, 5],
-       [4, 3, 4, -8, 5],
-       [5, 1, 6],
-       [5, 3, 5, -22, 6],
-       [5, 3, 5, -5, 6],
-       [6, 1, 7],
-       [6, 3, 6, -23, 7],
-       [6, 3, 6, -24, 7],
-       [6, 3, 6, -6, 7],
-       [6, 3, 6, -7, 7],
-       [7, 1, 8],
-       [7, 3, 7, -25, 8],
-       [7, 3, 7, -26, 8],
-       [8, 1, 9],
-       [8, 3, 8, -12, 9],
-       [8, 3, 8, -11, 9],
-       [8, 3, 8, -10, 9],
-       [9, 1, 10],
-       [9, 2, -26, 9],
-       [10, 1, 11],
-       [10, 3, 10, -27, 11],
-       [11, 1, 12],
-       [11, 1, 13],
-       [11, 3, 13, -28, 14],
-       [11, 3, 13, -4, 14],
-       [13, 1, 15],
-       [13, 2, 13, 16],
-       [15, 1, 17],
-       [15, 3, -29, 2, -30],
-       [15, 1, -15],
-       [15, 1, -16],
-       [15, 1, 18],
-       [18, 3, -13, -29, -30],
-       [18, 4, -13, -29, 19, -30],
-       [19, 1, 20],
-       [19, 3, 20, -31, 19],
-       [20, 1, 2],
-       [12, 1, 14],
-       [12, 1, 21],
-       [21, 1, -28],
-       [21, 2, -28, 14],
-       [21, 1, 22],
-       [14, 1, 23],
-       [14, 3, 14, -28, 23],
-       [14, 1, 24],
-       [23, 2, 25, 26],
-       [23, 1, 26],
-       [23, 3, 25, 26, 27],
-       [23, 2, 26, 27],
-       [23, 1, 28],
-       [27, 1, 16],
-       [27, 2, 16, 27],
-       [25, 2, -14, -3],
-       [25, 1, -32],
-       [26, 1, 29],
-       [26, 3, -20, -29, -30],
-       [26, 4, -21, -29, -15, -30],
-       [16, 3, -33, 30, -34],
-       [30, 1, 2],
-       [22, 2, -4, 14],
-       [24, 3, 14, -4, 23],
-       [28, 1, -35],
-       [28, 1, -2],
-       [17, 2, -36, -18],
-       [29, 1, -17],
-       [29, 1, -19],
-       [29, 1, -18]
-];
-
-XPathParser.DOUBLEDOT = 2;
-XPathParser.DOUBLECOLON = 3;
-XPathParser.DOUBLESLASH = 4;
-XPathParser.NOTEQUAL = 5;
-XPathParser.LESSTHANOREQUAL = 6;
-XPathParser.GREATERTHANOREQUAL = 7;
-XPathParser.AND = 8;
-XPathParser.OR = 9;
-XPathParser.MOD = 10;
-XPathParser.DIV = 11;
-XPathParser.MULTIPLYOPERATOR = 12;
-XPathParser.FUNCTIONNAME = 13;
-XPathParser.AXISNAME = 14;
-XPathParser.LITERAL = 15;
-XPathParser.NUMBER = 16;
-XPathParser.ASTERISKNAMETEST = 17;
-XPathParser.QNAME = 18;
-XPathParser.NCNAMECOLONASTERISK = 19;
-XPathParser.NODETYPE = 20;
-XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL = 21;
-XPathParser.EQUALS = 22;
-XPathParser.LESSTHAN = 23;
-XPathParser.GREATERTHAN = 24;
-XPathParser.PLUS = 25;
-XPathParser.MINUS = 26;
-XPathParser.BAR = 27;
-XPathParser.SLASH = 28;
-XPathParser.LEFTPARENTHESIS = 29;
-XPathParser.RIGHTPARENTHESIS = 30;
-XPathParser.COMMA = 31;
-XPathParser.AT = 32;
-XPathParser.LEFTBRACKET = 33;
-XPathParser.RIGHTBRACKET = 34;
-XPathParser.DOT = 35;
-XPathParser.DOLLAR = 36;
-
-XPathParser.prototype.tokenize = function(s1) {
-       var types = [];
-       var values = [];
-       var s = s1 + '\0';
-
-       var pos = 0;
-       var c = s.charAt(pos++);
-       while (1) {
-               while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
-                       c = s.charAt(pos++);
-               }
-               if (c == '\0' || pos >= s.length) {
-                       break;
-               }
-
-               if (c == '(') {
-                       types.push(XPathParser.LEFTPARENTHESIS);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == ')') {
-                       types.push(XPathParser.RIGHTPARENTHESIS);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '[') {
-                       types.push(XPathParser.LEFTBRACKET);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == ']') {
-                       types.push(XPathParser.RIGHTBRACKET);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '@') {
-                       types.push(XPathParser.AT);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == ',') {
-                       types.push(XPathParser.COMMA);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '|') {
-                       types.push(XPathParser.BAR);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '+') {
-                       types.push(XPathParser.PLUS);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '-') {
-                       types.push(XPathParser.MINUS);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '=') {
-                       types.push(XPathParser.EQUALS);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               if (c == '$') {
-                       types.push(XPathParser.DOLLAR);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-               
-               if (c == '.') {
-                       c = s.charAt(pos++);
-                       if (c == '.') {
-                               types.push(XPathParser.DOUBLEDOT);
-                               values.push("..");
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-                       if (c >= '0' && c <= '9') {
-                               var number = "." + c;
-                               c = s.charAt(pos++);
-                               while (c >= '0' && c <= '9') {
-                                       number += c;
-                                       c = s.charAt(pos++);
-                               }
-                               types.push(XPathParser.NUMBER);
-                               values.push(number);
-                               continue;
-                       }
-                       types.push(XPathParser.DOT);
-                       values.push('.');
-                       continue;
-               }
-
-               if (c == '\'' || c == '"') {
-                       var delimiter = c;
-                       var literal = "";
-                       while ((c = s.charAt(pos++)) != delimiter) {
-                               literal += c;
-                       }
-                       types.push(XPathParser.LITERAL);
-                       values.push(literal);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-
-               if (c >= '0' && c <= '9') {
-                       var number = c;
-                       c = s.charAt(pos++);
-                       while (c >= '0' && c <= '9') {
-                               number += c;
-                               c = s.charAt(pos++);
-                       }
-                       if (c == '.') {
-                               if (s.charAt(pos) >= '0' && s.charAt(pos) <= '9') {
-                                       number += c;
-                                       number += s.charAt(pos++);
-                                       c = s.charAt(pos++);
-                                       while (c >= '0' && c <= '9') {
-                                               number += c;
-                                               c = s.charAt(pos++);
-                                       }
-                               }
-                       }
-                       types.push(XPathParser.NUMBER);
-                       values.push(number);
-                       continue;
-               }
-
-               if (c == '*') {
-                       if (types.length > 0) {
-                               var last = types[types.length - 1];
-                               if (last != XPathParser.AT
-                                               && last != XPathParser.DOUBLECOLON
-                                               && last != XPathParser.LEFTPARENTHESIS
-                                               && last != XPathParser.LEFTBRACKET
-                                               && last != XPathParser.AND
-                                               && last != XPathParser.OR
-                                               && last != XPathParser.MOD
-                                               && last != XPathParser.DIV
-                                               && last != XPathParser.MULTIPLYOPERATOR
-                                               && last != XPathParser.SLASH
-                                               && last != XPathParser.DOUBLESLASH
-                                               && last != XPathParser.BAR
-                                               && last != XPathParser.PLUS
-                                               && last != XPathParser.MINUS
-                                               && last != XPathParser.EQUALS
-                                               && last != XPathParser.NOTEQUAL
-                                               && last != XPathParser.LESSTHAN
-                                               && last != XPathParser.LESSTHANOREQUAL
-                                               && last != XPathParser.GREATERTHAN
-                                               && last != XPathParser.GREATERTHANOREQUAL) {
-                                       types.push(XPathParser.MULTIPLYOPERATOR);
-                                       values.push(c);
-                                       c = s.charAt(pos++);
-                                       continue;
-                               }
-                       }
-                       types.push(XPathParser.ASTERISKNAMETEST);
-                       values.push(c);
-                       c = s.charAt(pos++);
-                       continue;
-               }
-
-               if (c == ':') {
-                       if (s.charAt(pos) == ':') {
-                               types.push(XPathParser.DOUBLECOLON);
-                               values.push("::");
-                               pos++;
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-               }
-
-               if (c == '/') {
-                       c = s.charAt(pos++);
-                       if (c == '/') {
-                               types.push(XPathParser.DOUBLESLASH);
-                               values.push("//");
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-                       types.push(XPathParser.SLASH);
-                       values.push('/');
-                       continue;
-               }
-
-               if (c == '!') {
-                       if (s.charAt(pos) == '=') {
-                               types.push(XPathParser.NOTEQUAL);
-                               values.push("!=");
-                               pos++;
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-               }
-
-               if (c == '<') {
-                       if (s.charAt(pos) == '=') {
-                               types.push(XPathParser.LESSTHANOREQUAL);
-                               values.push("<=");
-                               pos++;
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-                       types.push(XPathParser.LESSTHAN);
-                       values.push('<');
-                       c = s.charAt(pos++);
-                       continue;
-               }
-
-               if (c == '>') {
-                       if (s.charAt(pos) == '=') {
-                               types.push(XPathParser.GREATERTHANOREQUAL);
-                               values.push(">=");
-                               pos++;
-                               c = s.charAt(pos++);
-                               continue;
-                       }
-                       types.push(XPathParser.GREATERTHAN);
-                       values.push('>');
-                       c = s.charAt(pos++);
-                       continue;
-               }
-
-               if (c == '_' || Utilities.isLetter(c.charCodeAt(0))) {
-                       var name = c;
-                       c = s.charAt(pos++);
-                       while (Utilities.isNCNameChar(c.charCodeAt(0))) {
-                               name += c;
-                               c = s.charAt(pos++);
-                       }
-                       if (types.length > 0) {
-                               var last = types[types.length - 1];
-                               if (last != XPathParser.AT
-                                               && last != XPathParser.DOUBLECOLON
-                                               && last != XPathParser.LEFTPARENTHESIS
-                                               && last != XPathParser.LEFTBRACKET
-                                               && last != XPathParser.AND
-                                               && last != XPathParser.OR
-                                               && last != XPathParser.MOD
-                                               && last != XPathParser.DIV
-                                               && last != XPathParser.MULTIPLYOPERATOR
-                                               && last != XPathParser.SLASH
-                                               && last != XPathParser.DOUBLESLASH
-                                               && last != XPathParser.BAR
-                                               && last != XPathParser.PLUS
-                                               && last != XPathParser.MINUS
-                                               && last != XPathParser.EQUALS
-                                               && last != XPathParser.NOTEQUAL
-                                               && last != XPathParser.LESSTHAN
-                                               && last != XPathParser.LESSTHANOREQUAL
-                                               && last != XPathParser.GREATERTHAN
-                                               && last != XPathParser.GREATERTHANOREQUAL) {
-                                       if (name == "and") {
-                                               types.push(XPathParser.AND);
-                                               values.push(name);
-                                               continue;
-                                       }
-                                       if (name == "or") {
-                                               types.push(XPathParser.OR);
-                                               values.push(name);
-                                               continue;
-                                       }
-                                       if (name == "mod") {
-                                               types.push(XPathParser.MOD);
-                                               values.push(name);
-                                               continue;
-                                       }
-                                       if (name == "div") {
-                                               types.push(XPathParser.DIV);
-                                               values.push(name);
-                                               continue;
-                                       }
-                               }
-                       }
-                       if (c == ':') {
-                               if (s.charAt(pos) == '*') {
-                                       types.push(XPathParser.NCNAMECOLONASTERISK);
-                                       values.push(name + ":*");
-                                       pos++;
-                                       c = s.charAt(pos++);
-                                       continue;
-                               }
-                               if (s.charAt(pos) == '_' || Utilities.isLetter(s.charCodeAt(pos))) {
-                                       name += ':';
-                                       c = s.charAt(pos++);
-                                       while (Utilities.isNCNameChar(c.charCodeAt(0))) {
-                                               name += c;
-                                               c = s.charAt(pos++);
-                                       }
-                                       if (c == '(') {
-                                               types.push(XPathParser.FUNCTIONNAME);
-                                               values.push(name);
-                                               continue;
-                                       }
-                                       types.push(XPathParser.QNAME);
-                                       values.push(name);
-                                       continue;
-                               }
-                               if (s.charAt(pos) == ':') {
-                                       types.push(XPathParser.AXISNAME);
-                                       values.push(name);
-                                       continue;
-                               }
-                       }
-                       if (c == '(') {
-                               if (name == "comment" || name == "text" || name == "node") {
-                                       types.push(XPathParser.NODETYPE);
-                                       values.push(name);
-                                       continue;
-                               }
-                               if (name == "processing-instruction") {
-                                       if (s.charAt(pos) == ')') {
-                                               types.push(XPathParser.NODETYPE);
-                                       } else {
-                                               types.push(XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL);
-                                       }
-                                       values.push(name);
-                                       continue;
-                               }
-                               types.push(XPathParser.FUNCTIONNAME);
-                               values.push(name);
-                               continue;
-                       }
-                       types.push(XPathParser.QNAME);
-                       values.push(name);
-                       continue;
-               }
-
-               throw new Error("Unexpected character " + c);
-       }
-       types.push(1);
-       values.push("[EOF]");
-       return [types, values];
-};
-
-XPathParser.SHIFT = 's';
-XPathParser.REDUCE = 'r';
-XPathParser.ACCEPT = 'a';
-
-XPathParser.prototype.parse = function(s) {
-       var types;
-       var values;
-       var res = this.tokenize(s);
-       if (res == undefined) {
-               return undefined;
-       }
-       types = res[0];
-       values = res[1];
-       var tokenPos = 0;
-       var state = [];
-       var tokenType = [];
-       var tokenValue = [];
-       var s;
-       var a;
-       var t;
-
-       state.push(0);
-       tokenType.push(1);
-       tokenValue.push("_S");
-
-       a = types[tokenPos];
-       t = values[tokenPos++];
-       while (1) {
-               s = state[state.length - 1];
-               switch (XPathParser.actionTable[s].charAt(a - 1)) {
-                       case XPathParser.SHIFT:
-                               tokenType.push(-a);
-                               tokenValue.push(t);
-                               state.push(XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32);
-                               a = types[tokenPos];
-                               t = values[tokenPos++];
-                               break;
-                       case XPathParser.REDUCE:
-                               var num = XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][1];
-                               var rhs = [];
-                               for (var i = 0; i < num; i++) {
-                                       tokenType.pop();
-                                       rhs.unshift(tokenValue.pop());
-                                       state.pop();
-                               }
-                               var s_ = state[state.length - 1];
-                               tokenType.push(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0]);
-                               if (this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32] == undefined) {
-                                       tokenValue.push(rhs[0]);
-                               } else {
-                                       tokenValue.push(this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32](rhs));
-                               }
-                               state.push(XPathParser.gotoTable[s_].charCodeAt(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0] - 2) - 33);
-                               break;
-                       case XPathParser.ACCEPT:
-                               return new XPath(tokenValue.pop());
-                       default:
-                               throw new Error("XPath parse error");
-               }
-       }
-};
-
-// XPath /////////////////////////////////////////////////////////////////////
-
-XPath.prototype = new Object();
-XPath.prototype.constructor = XPath;
-XPath.superclass = Object.prototype;
-
-function XPath(e) {
-       this.expression = e;
-}
-
-XPath.prototype.toString = function() {
-       return this.expression.toString();
-};
-
-XPath.prototype.evaluate = function(c) {
-       c.contextNode = c.expressionContextNode;
-       c.contextSize = 1;
-       c.contextPosition = 1;
-       c.caseInsensitive = false;
-       if (c.contextNode != null) {
-               var doc = c.contextNode;
-               if (doc.nodeType != 9 /*Node.DOCUMENT_NODE*/) {
-                       doc = doc.ownerDocument;
-               }
-               try {
-                       c.caseInsensitive = doc.implementation.hasFeature("HTML", "2.0");
-               } catch (e) {
-                       c.caseInsensitive = true;
-               }
-       }
-       return this.expression.evaluate(c);
-};
-
-XPath.XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
-XPath.XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
-
-// Expression ////////////////////////////////////////////////////////////////
-
-Expression.prototype = new Object();
-Expression.prototype.constructor = Expression;
-Expression.superclass = Object.prototype;
-
-function Expression() {
-}
-
-Expression.prototype.init = function() {
-};
-
-Expression.prototype.toString = function() {
-       return "<Expression>";
-};
-
-Expression.prototype.evaluate = function(c) {
-       throw new Error("Could not evaluate expression.");
-};
-
-// UnaryOperation ////////////////////////////////////////////////////////////
-
-UnaryOperation.prototype = new Expression();
-UnaryOperation.prototype.constructor = UnaryOperation;
-UnaryOperation.superclass = Expression.prototype;
-
-function UnaryOperation(rhs) {
-       if (arguments.length > 0) {
-               this.init(rhs);
-       }
-}
-
-UnaryOperation.prototype.init = function(rhs) {
-       this.rhs = rhs;
-};
-
-// UnaryMinusOperation ///////////////////////////////////////////////////////
-
-UnaryMinusOperation.prototype = new UnaryOperation();
-UnaryMinusOperation.prototype.constructor = UnaryMinusOperation;
-UnaryMinusOperation.superclass = UnaryOperation.prototype;
-
-function UnaryMinusOperation(rhs) {
-       if (arguments.length > 0) {
-               this.init(rhs);
-       }
-}
-
-UnaryMinusOperation.prototype.init = function(rhs) {
-       UnaryMinusOperation.superclass.init.call(this, rhs);
-};
-
-UnaryMinusOperation.prototype.evaluate = function(c) {
-       return this.rhs.evaluate(c).number().negate();
-};
-
-UnaryMinusOperation.prototype.toString = function() {
-       return "-" + this.rhs.toString();
-};
-
-// BinaryOperation ///////////////////////////////////////////////////////////
-
-BinaryOperation.prototype = new Expression();
-BinaryOperation.prototype.constructor = BinaryOperation;
-BinaryOperation.superclass = Expression.prototype;
-
-function BinaryOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-BinaryOperation.prototype.init = function(lhs, rhs) {
-       this.lhs = lhs;
-       this.rhs = rhs;
-};
-
-// OrOperation ///////////////////////////////////////////////////////////////
-
-OrOperation.prototype = new BinaryOperation();
-OrOperation.prototype.constructor = OrOperation;
-OrOperation.superclass = BinaryOperation.prototype;
-
-function OrOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-OrOperation.prototype.init = function(lhs, rhs) {
-       OrOperation.superclass.init.call(this, lhs, rhs);
-};
-
-OrOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " or " + this.rhs.toString() + ")";
-};
-
-OrOperation.prototype.evaluate = function(c) {
-       var b = this.lhs.evaluate(c).bool();
-       if (b.booleanValue()) {
-               return b;
-       }
-       return this.rhs.evaluate(c).bool();
-};
-
-// AndOperation //////////////////////////////////////////////////////////////
-
-AndOperation.prototype = new BinaryOperation();
-AndOperation.prototype.constructor = AndOperation;
-AndOperation.superclass = BinaryOperation.prototype;
-
-function AndOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-AndOperation.prototype.init = function(lhs, rhs) {
-       AndOperation.superclass.init.call(this, lhs, rhs);
-};
-
-AndOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " and " + this.rhs.toString() + ")";
-};
-
-AndOperation.prototype.evaluate = function(c) {
-       var b = this.lhs.evaluate(c).bool();
-       if (!b.booleanValue()) {
-               return b;
-       }
-       return this.rhs.evaluate(c).bool();
-};
-
-// EqualsOperation ///////////////////////////////////////////////////////////
-
-EqualsOperation.prototype = new BinaryOperation();
-EqualsOperation.prototype.constructor = EqualsOperation;
-EqualsOperation.superclass = BinaryOperation.prototype;
-
-function EqualsOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-EqualsOperation.prototype.init = function(lhs, rhs) {
-       EqualsOperation.superclass.init.call(this, lhs, rhs);
-};
-
-EqualsOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " = " + this.rhs.toString() + ")";
-};
-
-EqualsOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).equals(this.rhs.evaluate(c));
-};
-
-// NotEqualOperation /////////////////////////////////////////////////////////
-
-NotEqualOperation.prototype = new BinaryOperation();
-NotEqualOperation.prototype.constructor = NotEqualOperation;
-NotEqualOperation.superclass = BinaryOperation.prototype;
-
-function NotEqualOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-NotEqualOperation.prototype.init = function(lhs, rhs) {
-       NotEqualOperation.superclass.init.call(this, lhs, rhs);
-};
-
-NotEqualOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " != " + this.rhs.toString() + ")";
-};
-
-NotEqualOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).notequal(this.rhs.evaluate(c));
-};
-
-// LessThanOperation /////////////////////////////////////////////////////////
-
-LessThanOperation.prototype = new BinaryOperation();
-LessThanOperation.prototype.constructor = LessThanOperation;
-LessThanOperation.superclass = BinaryOperation.prototype;
-
-function LessThanOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-LessThanOperation.prototype.init = function(lhs, rhs) {
-       LessThanOperation.superclass.init.call(this, lhs, rhs);
-};
-
-LessThanOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).lessthan(this.rhs.evaluate(c));
-};
-
-LessThanOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " < " + this.rhs.toString() + ")";
-};
-
-// GreaterThanOperation //////////////////////////////////////////////////////
-
-GreaterThanOperation.prototype = new BinaryOperation();
-GreaterThanOperation.prototype.constructor = GreaterThanOperation;
-GreaterThanOperation.superclass = BinaryOperation.prototype;
-
-function GreaterThanOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-GreaterThanOperation.prototype.init = function(lhs, rhs) {
-       GreaterThanOperation.superclass.init.call(this, lhs, rhs);
-};
-
-GreaterThanOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).greaterthan(this.rhs.evaluate(c));
-};
-
-GreaterThanOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " > " + this.rhs.toString() + ")";
-};
-
-// LessThanOrEqualOperation //////////////////////////////////////////////////
-
-LessThanOrEqualOperation.prototype = new BinaryOperation();
-LessThanOrEqualOperation.prototype.constructor = LessThanOrEqualOperation;
-LessThanOrEqualOperation.superclass = BinaryOperation.prototype;
-
-function LessThanOrEqualOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-LessThanOrEqualOperation.prototype.init = function(lhs, rhs) {
-       LessThanOrEqualOperation.superclass.init.call(this, lhs, rhs);
-};
-
-LessThanOrEqualOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).lessthanorequal(this.rhs.evaluate(c));
-};
-
-LessThanOrEqualOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " <= " + this.rhs.toString() + ")";
-};
-
-// GreaterThanOrEqualOperation ///////////////////////////////////////////////
-
-GreaterThanOrEqualOperation.prototype = new BinaryOperation();
-GreaterThanOrEqualOperation.prototype.constructor = GreaterThanOrEqualOperation;
-GreaterThanOrEqualOperation.superclass = BinaryOperation.prototype;
-
-function GreaterThanOrEqualOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-GreaterThanOrEqualOperation.prototype.init = function(lhs, rhs) {
-       GreaterThanOrEqualOperation.superclass.init.call(this, lhs, rhs);
-};
-
-GreaterThanOrEqualOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).greaterthanorequal(this.rhs.evaluate(c));
-};
-
-GreaterThanOrEqualOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " >= " + this.rhs.toString() + ")";
-};
-
-// PlusOperation /////////////////////////////////////////////////////////////
-
-PlusOperation.prototype = new BinaryOperation();
-PlusOperation.prototype.constructor = PlusOperation;
-PlusOperation.superclass = BinaryOperation.prototype;
-
-function PlusOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-PlusOperation.prototype.init = function(lhs, rhs) {
-       PlusOperation.superclass.init.call(this, lhs, rhs);
-};
-
-PlusOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).number().plus(this.rhs.evaluate(c).number());
-};
-
-PlusOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " + " + this.rhs.toString() + ")";
-};
-
-// MinusOperation ////////////////////////////////////////////////////////////
-
-MinusOperation.prototype = new BinaryOperation();
-MinusOperation.prototype.constructor = MinusOperation;
-MinusOperation.superclass = BinaryOperation.prototype;
-
-function MinusOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-MinusOperation.prototype.init = function(lhs, rhs) {
-       MinusOperation.superclass.init.call(this, lhs, rhs);
-};
-
-MinusOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).number().minus(this.rhs.evaluate(c).number());
-};
-
-MinusOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " - " + this.rhs.toString() + ")";
-};
-
-// MultiplyOperation /////////////////////////////////////////////////////////
-
-MultiplyOperation.prototype = new BinaryOperation();
-MultiplyOperation.prototype.constructor = MultiplyOperation;
-MultiplyOperation.superclass = BinaryOperation.prototype;
-
-function MultiplyOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-MultiplyOperation.prototype.init = function(lhs, rhs) {
-       MultiplyOperation.superclass.init.call(this, lhs, rhs);
-};
-
-MultiplyOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).number().multiply(this.rhs.evaluate(c).number());
-};
-
-MultiplyOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " * " + this.rhs.toString() + ")";
-};
-
-// DivOperation //////////////////////////////////////////////////////////////
-
-DivOperation.prototype = new BinaryOperation();
-DivOperation.prototype.constructor = DivOperation;
-DivOperation.superclass = BinaryOperation.prototype;
-
-function DivOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-DivOperation.prototype.init = function(lhs, rhs) {
-       DivOperation.superclass.init.call(this, lhs, rhs);
-};
-
-DivOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).number().div(this.rhs.evaluate(c).number());
-};
-
-DivOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " div " + this.rhs.toString() + ")";
-};
-
-// ModOperation //////////////////////////////////////////////////////////////
-
-ModOperation.prototype = new BinaryOperation();
-ModOperation.prototype.constructor = ModOperation;
-ModOperation.superclass = BinaryOperation.prototype;
-
-function ModOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-ModOperation.prototype.init = function(lhs, rhs) {
-       ModOperation.superclass.init.call(this, lhs, rhs);
-};
-
-ModOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).number().mod(this.rhs.evaluate(c).number());
-};
-
-ModOperation.prototype.toString = function() {
-       return "(" + this.lhs.toString() + " mod " + this.rhs.toString() + ")";
-};
-
-// BarOperation //////////////////////////////////////////////////////////////
-
-BarOperation.prototype = new BinaryOperation();
-BarOperation.prototype.constructor = BarOperation;
-BarOperation.superclass = BinaryOperation.prototype;
-
-function BarOperation(lhs, rhs) {
-       if (arguments.length > 0) {
-               this.init(lhs, rhs);
-       }
-}
-
-BarOperation.prototype.init = function(lhs, rhs) {
-       BarOperation.superclass.init.call(this, lhs, rhs);
-};
-
-BarOperation.prototype.evaluate = function(c) {
-       return this.lhs.evaluate(c).nodeset().union(this.rhs.evaluate(c).nodeset());
-};
-
-BarOperation.prototype.toString = function() {
-       return this.lhs.toString() + " | " + this.rhs.toString();
-};
-
-// PathExpr //////////////////////////////////////////////////////////////////
-
-PathExpr.prototype = new Expression();
-PathExpr.prototype.constructor = PathExpr;
-PathExpr.superclass = Expression.prototype;
-
-function PathExpr(filter, filterPreds, locpath) {
-       if (arguments.length > 0) {
-               this.init(filter, filterPreds, locpath);
-       }
-}
-
-PathExpr.prototype.init = function(filter, filterPreds, locpath) {
-       PathExpr.superclass.init.call(this);
-       this.filter = filter;
-       this.filterPredicates = filterPreds;
-       this.locationPath = locpath;
-};
-
-PathExpr.prototype.evaluate = function(c) {
-       var nodes;
-       var xpc = new XPathContext();
-       xpc.variableResolver = c.variableResolver;
-       xpc.functionResolver = c.functionResolver;
-       xpc.namespaceResolver = c.namespaceResolver;
-       xpc.expressionContextNode = c.expressionContextNode;
-       xpc.virtualRoot = c.virtualRoot;
-       xpc.caseInsensitive = c.caseInsensitive;
-       if (this.filter == null) {
-               nodes = [ c.contextNode ];
-       } else {
-               var ns = this.filter.evaluate(c);
-               if (!Utilities.instance_of(ns, XNodeSet)) {
-                       if (this.filterPredicates != null && this.filterPredicates.length > 0 || this.locationPath != null) {
-                               throw new Error("Path expression filter must evaluate to a nodset if predicates or location path are used");
-                       }
-                       return ns;
-               }
-               nodes = ns.toArray();
-               if (this.filterPredicates != null) {
-                       // apply each of the predicates in turn
-                       for (var j = 0; j < this.filterPredicates.length; j++) {
-                               var pred = this.filterPredicates[j];
-                               var newNodes = [];
-                               xpc.contextSize = nodes.length;
-                               for (xpc.contextPosition = 1; xpc.contextPosition <= xpc.contextSize; xpc.contextPosition++) {
-                                       xpc.contextNode = nodes[xpc.contextPosition - 1];
-                                       if (this.predicateMatches(pred, xpc)) {
-                                               newNodes.push(xpc.contextNode);
-                                       }
-                               }
-                               nodes = newNodes;
-                       }
-               }
-       }
-       if (this.locationPath != null) {
-               if (this.locationPath.absolute) {
-                       if (nodes[0].nodeType != 9 /*Node.DOCUMENT_NODE*/) {
-                               if (xpc.virtualRoot != null) {
-                                       nodes = [ xpc.virtualRoot ];
-                               } else {
-                                       if (nodes[0].ownerDocument == null) {
-                                               // IE 5.5 doesn't have ownerDocument?
-                                               var n = nodes[0];
-                                               while (n.parentNode != null) {
-                                                       n = n.parentNode;
-                                               }
-                                               nodes = [ n ];
-                                       } else {
-                                               nodes = [ nodes[0].ownerDocument ];
-                                       }
-                               }
-                       } else {
-                               nodes = [ nodes[0] ];
-                       }
-               }
-               for (var i = 0; i < this.locationPath.steps.length; i++) {
-                       var step = this.locationPath.steps[i];
-                       var newNodes = [];
-                       for (var j = 0; j < nodes.length; j++) {
-                               xpc.contextNode = nodes[j];
-                               switch (step.axis) {
-                                       case Step.ANCESTOR:
-                                               // look at all the ancestor nodes
-                                               if (xpc.contextNode === xpc.virtualRoot) {
-                                                       break;
-                                               }
-                                               var m;
-                                               if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
-                                                       m = this.getOwnerElement(xpc.contextNode);
-                                               } else {
-                                                       m = xpc.contextNode.parentNode;
-                                               }
-                                               while (m != null) {
-                                                       if (step.nodeTest.matches(m, xpc)) {
-                                                               newNodes.push(m);
-                                                       }
-                                                       if (m === xpc.virtualRoot) {
-                                                               break;
-                                                       }
-                                                       m = m.parentNode;
-                                               }
-                                               break;
-
-                                       case Step.ANCESTORORSELF:
-                                               // look at all the ancestor nodes and the current node
-                                               for (var m = xpc.contextNode; m != null; m = m.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ ? this.getOwnerElement(m) : m.parentNode) {
-                                                       if (step.nodeTest.matches(m, xpc)) {
-                                                               newNodes.push(m);
-                                                       }
-                                                       if (m === xpc.virtualRoot) {
-                                                               break;
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.ATTRIBUTE:
-                                               // look at the attributes
-                                               var nnm = xpc.contextNode.attributes;
-                                               if (nnm != null) {
-                                                       for (var k = 0; k < nnm.length; k++) {
-                                                               var m = nnm.item(k);
-                                                               if (step.nodeTest.matches(m, xpc)) {
-                                                                       newNodes.push(m);
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.CHILD:
-                                               // look at all child elements
-                                               for (var m = xpc.contextNode.firstChild; m != null; m = m.nextSibling) {
-                                                       if (step.nodeTest.matches(m, xpc)) {
-                                                               newNodes.push(m);
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.DESCENDANT:
-                                               // look at all descendant nodes
-                                               var st = [ xpc.contextNode.firstChild ];
-                                               while (st.length > 0) {
-                                                       for (var m = st.pop(); m != null; ) {
-                                                               if (step.nodeTest.matches(m, xpc)) {
-                                                                       newNodes.push(m);
-                                                               }
-                                                               if (m.firstChild != null) {
-                                                                       st.push(m.nextSibling);
-                                                                       m = m.firstChild;
-                                                               } else {
-                                                                       m = m.nextSibling;
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.DESCENDANTORSELF:
-                                               // look at self
-                                               if (step.nodeTest.matches(xpc.contextNode, xpc)) {
-                                                       newNodes.push(xpc.contextNode);
-                                               }
-                                               // look at all descendant nodes
-                                               var st = [ xpc.contextNode.firstChild ];
-                                               while (st.length > 0) {
-                                                       for (var m = st.pop(); m != null; ) {
-                                                               if (step.nodeTest.matches(m, xpc)) {
-                                                                       newNodes.push(m);
-                                                               }
-                                                               if (m.firstChild != null) {
-                                                                       st.push(m.nextSibling);
-                                                                       m = m.firstChild;
-                                                               } else {
-                                                                       m = m.nextSibling;
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.FOLLOWING:
-                                               if (xpc.contextNode === xpc.virtualRoot) {
-                                                       break;
-                                               }
-                                               var st = [];
-                                               if (xpc.contextNode.firstChild != null) {
-                                                       st.unshift(xpc.contextNode.firstChild);
-                                               } else {
-                                                       st.unshift(xpc.contextNode.nextSibling);
-                                               }
-                                               for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != 9 /*Node.DOCUMENT_NODE*/ && m !== xpc.virtualRoot; m = m.parentNode) {
-                                                       st.unshift(m.nextSibling);
-                                               }
-                                               do {
-                                                       for (var m = st.pop(); m != null; ) {
-                                                               if (step.nodeTest.matches(m, xpc)) {
-                                                                       newNodes.push(m);
-                                                               }
-                                                               if (m.firstChild != null) {
-                                                                       st.push(m.nextSibling);
-                                                                       m = m.firstChild;
-                                                               } else {
-                                                                       m = m.nextSibling;
-                                                               }
-                                                       }
-                                               } while (st.length > 0);
-                                               break;
-                                               
-                                       case Step.FOLLOWINGSIBLING:
-                                               if (xpc.contextNode === xpc.virtualRoot) {
-                                                       break;
-                                               }
-                                               for (var m = xpc.contextNode.nextSibling; m != null; m = m.nextSibling) {
-                                                       if (step.nodeTest.matches(m, xpc)) {
-                                                               newNodes.push(m);
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.NAMESPACE:
-                                               var n = {};
-                                               if (xpc.contextNode.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-                                                       n["xml"] = XPath.XML_NAMESPACE_URI;
-                                                       n["xmlns"] = XPath.XMLNS_NAMESPACE_URI;
-                                                       for (var m = xpc.contextNode; m != null && m.nodeType == 1 /*Node.ELEMENT_NODE*/; m = m.parentNode) {
-                                                               for (var k = 0; k < m.attributes.length; k++) {
-                                                                       var attr = m.attributes.item(k);
-                                                                       var nm = String(attr.name);
-                                                                       if (nm == "xmlns") {
-                                                                               if (n[""] == undefined) {
-                                                                                       n[""] = attr.value;
-                                                                               }
-                                                                       } else if (nm.length > 6 && nm.substring(0, 6) == "xmlns:") {
-                                                                               var pre = nm.substring(6, nm.length);
-                                                                               if (n[pre] == undefined) {
-                                                                                       n[pre] = attr.value;
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                                       for (var pre in n) {
-                                                               var nsn = new NamespaceNode(pre, n[pre], xpc.contextNode);
-                                                               if (step.nodeTest.matches(nsn, xpc)) {
-                                                                       newNodes.push(nsn);
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.PARENT:
-                                               m = null;
-                                               if (xpc.contextNode !== xpc.virtualRoot) {
-                                                       if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
-                                                               m = this.getOwnerElement(xpc.contextNode);
-                                                       } else {
-                                                               m = xpc.contextNode.parentNode;
-                                                       }
-                                               }
-                                               if (m != null && step.nodeTest.matches(m, xpc)) {
-                                                       newNodes.push(m);
-                                               }
-                                               break;
-
-                                       case Step.PRECEDING:
-                                               var st;
-                                               if (xpc.virtualRoot != null) {
-                                                       st = [ xpc.virtualRoot ];
-                                               } else {
-                                                       st = xpc.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
-                                                               ? [ xpc.contextNode ]
-                                                               : [ xpc.contextNode.ownerDocument ];
-                                               }
-                                               outer: while (st.length > 0) {
-                                                       for (var m = st.pop(); m != null; ) {
-                                                               if (m == xpc.contextNode) {
-                                                                       break outer;
-                                                               }
-                                                               if (step.nodeTest.matches(m, xpc)) {
-                                                                       newNodes.unshift(m);
-                                                               }
-                                                               if (m.firstChild != null) {
-                                                                       st.push(m.nextSibling);
-                                                                       m = m.firstChild;
-                                                               } else {
-                                                                       m = m.nextSibling;
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.PRECEDINGSIBLING:
-                                               if (xpc.contextNode === xpc.virtualRoot) {
-                                                       break;
-                                               }
-                                               for (var m = xpc.contextNode.previousSibling; m != null; m = m.previousSibling) {
-                                                       if (step.nodeTest.matches(m, xpc)) {
-                                                               newNodes.push(m);
-                                                       }
-                                               }
-                                               break;
-
-                                       case Step.SELF:
-                                               if (step.nodeTest.matches(xpc.contextNode, xpc)) {
-                                                       newNodes.push(xpc.contextNode);
-                                               }
-                                               break;
-
-                                       default:
-                               }
-                       }
-                       nodes = newNodes;
-                       // apply each of the predicates in turn
-                       for (var j = 0; j < step.predicates.length; j++) {
-                               var pred = step.predicates[j];
-                               var newNodes = [];
-                               xpc.contextSize = nodes.length;
-                               for (xpc.contextPosition = 1; xpc.contextPosition <= xpc.contextSize; xpc.contextPosition++) {
-                                       xpc.contextNode = nodes[xpc.contextPosition - 1];
-                                       if (this.predicateMatches(pred, xpc)) {
-                                               newNodes.push(xpc.contextNode);
-                                       } else {
-                                       }
-                               }
-                               nodes = newNodes;
-                       }
-               }
-       }
-       var ns = new XNodeSet();
-       ns.addArray(nodes);
-       return ns;
-};
-
-PathExpr.prototype.predicateMatches = function(pred, c) {
-       var res = pred.evaluate(c);
-       if (Utilities.instance_of(res, XNumber)) {
-               return c.contextPosition == res.numberValue();
-       }
-       return res.booleanValue();
-};
-
-PathExpr.prototype.toString = function() {
-       if (this.filter != undefined) {
-               var s = this.filter.toString();
-               if (Utilities.instance_of(this.filter, XString)) {
-                       s = "'" + s + "'";
-               }
-               if (this.filterPredicates != undefined) {
-                       for (var i = 0; i < this.filterPredicates.length; i++) {
-                               s = s + "[" + this.filterPredicates[i].toString() + "]";
-                       }
-               }
-               if (this.locationPath != undefined) {
-                       if (!this.locationPath.absolute) {
-                               s += "/";
-                       }
-                       s += this.locationPath.toString();
-               }
-               return s;
-       }
-       return this.locationPath.toString();
-};
-
-PathExpr.prototype.getOwnerElement = function(n) {
-       // DOM 2 has ownerElement
-       if (n.ownerElement) {
-               return n.ownerElement;
-       }
-       // DOM 1 Internet Explorer can use selectSingleNode (ironically)
-       try {
-               if (n.selectSingleNode) {
-                       return n.selectSingleNode("..");
-               }
-       } catch (e) {
-       }
-       // Other DOM 1 implementations must use this egregious search
-       var doc = n.nodeType == 9 /*Node.DOCUMENT_NODE*/
-                       ? n
-                       : n.ownerDocument;
-       var elts = doc.getElementsByTagName("*");
-       for (var i = 0; i < elts.length; i++) {
-               var elt = elts.item(i);
-               var nnm = elt.attributes;
-               for (var j = 0; j < nnm.length; j++) {
-                       var an = nnm.item(j);
-                       if (an === n) {
-                               return elt;
-                       }
-               }
-       }
-       return null;
-};
-
-// LocationPath //////////////////////////////////////////////////////////////
-
-LocationPath.prototype = new Object();
-LocationPath.prototype.constructor = LocationPath;
-LocationPath.superclass = Object.prototype;
-
-function LocationPath(abs, steps) {
-       if (arguments.length > 0) {
-               this.init(abs, steps);
-       }
-}
-
-LocationPath.prototype.init = function(abs, steps) {
-       this.absolute = abs;
-       this.steps = steps;
-};
-
-LocationPath.prototype.toString = function() {
-       var s;
-       if (this.absolute) {
-               s = "/";
-       } else {
-               s = "";
-       }
-       for (var i = 0; i < this.steps.length; i++) {
-               if (i != 0) {
-                       s += "/";
-               }
-               s += this.steps[i].toString();
-       }
-       return s;
-};
-
-// Step //////////////////////////////////////////////////////////////////////
-
-Step.prototype = new Object();
-Step.prototype.constructor = Step;
-Step.superclass = Object.prototype;
-
-function Step(axis, nodetest, preds) {
-       if (arguments.length > 0) {
-               this.init(axis, nodetest, preds);
-       }
-}
-
-Step.prototype.init = function(axis, nodetest, preds) {
-       this.axis = axis;
-       this.nodeTest = nodetest;
-       this.predicates = preds;
-};
-
-Step.prototype.toString = function() {
-       var s;
-       switch (this.axis) {
-               case Step.ANCESTOR:
-                       s = "ancestor";
-                       break;
-               case Step.ANCESTORORSELF:
-                       s = "ancestor-or-self";
-                       break;
-               case Step.ATTRIBUTE:
-                       s = "attribute";
-                       break;
-               case Step.CHILD:
-                       s = "child";
-                       break;
-               case Step.DESCENDANT:
-                       s = "descendant";
-                       break;
-               case Step.DESCENDANTORSELF:
-                       s = "descendant-or-self";
-                       break;
-               case Step.FOLLOWING:
-                       s = "following";
-                       break;
-               case Step.FOLLOWINGSIBLING:
-                       s = "following-sibling";
-                       break;
-               case Step.NAMESPACE:
-                       s = "namespace";
-                       break;
-               case Step.PARENT:
-                       s = "parent";
-                       break;
-               case Step.PRECEDING:
-                       s = "preceding";
-                       break;
-               case Step.PRECEDINGSIBLING:
-                       s = "preceding-sibling";
-                       break;
-               case Step.SELF:
-                       s = "self";
-                       break;
-       }
-       s += "::";
-       s += this.nodeTest.toString();
-       for (var i = 0; i < this.predicates.length; i++) {
-               s += "[" + this.predicates[i].toString() + "]";
-       }
-       return s;
-};
-
-Step.ANCESTOR = 0;
-Step.ANCESTORORSELF = 1;
-Step.ATTRIBUTE = 2;
-Step.CHILD = 3;
-Step.DESCENDANT = 4;
-Step.DESCENDANTORSELF = 5;
-Step.FOLLOWING = 6;
-Step.FOLLOWINGSIBLING = 7;
-Step.NAMESPACE = 8;
-Step.PARENT = 9;
-Step.PRECEDING = 10;
-Step.PRECEDINGSIBLING = 11;
-Step.SELF = 12;
-
-// NodeTest //////////////////////////////////////////////////////////////////
-
-NodeTest.prototype = new Object();
-NodeTest.prototype.constructor = NodeTest;
-NodeTest.superclass = Object.prototype;
-
-function NodeTest(type, value) {
-       if (arguments.length > 0) {
-               this.init(type, value);
-       }
-}
-
-NodeTest.prototype.init = function(type, value) {
-       this.type = type;
-       this.value = value;
-};
-
-NodeTest.prototype.toString = function() {
-       switch (this.type) {
-               case NodeTest.NAMETESTANY:
-                       return "*";
-               case NodeTest.NAMETESTPREFIXANY:
-                       return this.value + ":*";
-               case NodeTest.NAMETESTRESOLVEDANY:
-                       return "{" + this.value + "}*";
-               case NodeTest.NAMETESTQNAME:
-                       return this.value;
-               case NodeTest.NAMETESTRESOLVEDNAME:
-                       return "{" + this.namespaceURI + "}" + this.value;
-               case NodeTest.COMMENT:
-                       return "comment()";
-               case NodeTest.TEXT:
-                       return "text()";
-               case NodeTest.PI:
-                       if (this.value != undefined) {
-                               return "processing-instruction(\"" + this.value + "\")";
-                       }
-                       return "processing-instruction()";
-               case NodeTest.NODE:
-                       return "node()";
-       }
-       return "<unknown nodetest type>";
-};
-
-NodeTest.prototype.matches = function(n, xpc) {
-       switch (this.type) {
-               case NodeTest.NAMETESTANY:
-                       if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
-                                       || n.nodeType == 1 /*Node.ELEMENT_NODE*/
-                                       || n.nodeType == XPathNamespace.XPATH_NAMESPACE_NODE) {
-                               return true;
-                       }
-                       return false;
-               case NodeTest.NAMETESTPREFIXANY:
-                       if ((n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ || n.nodeType == 1 /*Node.ELEMENT_NODE*/)) {
-                               var ns = xpc.namespaceResolver.getNamespace(this.value, xpc.expressionContextNode);
-                               if (ns == null) {
-                                       throw new Error("Cannot resolve QName " + this.value);
-                               }
-                               return true;    
-                       }
-                       return false;
-               case NodeTest.NAMETESTQNAME:
-                       if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
-                                       || n.nodeType == 1 /*Node.ELEMENT_NODE*/
-                                       || n.nodeType == XPathNamespace.XPATH_NAMESPACE_NODE) {
-                               var test = Utilities.resolveQName(this.value, xpc.namespaceResolver, xpc.expressionContextNode, false);
-                               if (test[0] == null) {
-                                       throw new Error("Cannot resolve QName " + this.value);
-                               }
-                               test[0] = String(test[0]);
-                               test[1] = String(test[1]);
-                               if (test[0] == "") {
-                                       test[0] = null;
-                               }
-                               var node = Utilities.resolveQName(n.nodeName, xpc.namespaceResolver, n, n.nodeType == 1 /*Node.ELEMENT_NODE*/);
-                               node[0] = String(node[0]);
-                               node[1] = String(node[1]);
-                               if (node[0] == "") {
-                                       if (n.namespaceURI) {
-                                               node[0] = n.namespaceURI;
-                                       } else {
-                                               node[0] = null;
-                                       }
-                               }
-                               if (xpc.caseInsensitive) {
-                                       return test[0] == node[0] && String(test[1]).toLowerCase() == String(node[1]).toLowerCase();
-                               }
-                               return test[0] == node[0] && test[1] == node[1];
-                       }
-                       return false;
-               case NodeTest.COMMENT:
-                       return n.nodeType == 8 /*Node.COMMENT_NODE*/;
-               case NodeTest.TEXT:
-                       return n.nodeType == 3 /*Node.TEXT_NODE*/ || n.nodeType == 4 /*Node.CDATA_SECTION_NODE*/;
-               case NodeTest.PI:
-                       return n.nodeType == 7 /*Node.PROCESSING_INSTRUCTION_NODE*/
-                               && (this.value == null || n.nodeName == this.value);
-               case NodeTest.NODE:
-                       return n.nodeType == 9 /*Node.DOCUMENT_NODE*/
-                               || n.nodeType == 1 /*Node.ELEMENT_NODE*/
-                               || n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
-                               || n.nodeType == 3 /*Node.TEXT_NODE*/
-                               || n.nodeType == 4 /*Node.CDATA_SECTION_NODE*/
-                               || n.nodeType == 8 /*Node.COMMENT_NODE*/
-                               || n.nodeType == 7 /*Node.PROCESSING_INSTRUCTION_NODE*/;
-       }
-       return false;
-};
-
-NodeTest.NAMETESTANY = 0;
-NodeTest.NAMETESTPREFIXANY = 1;
-NodeTest.NAMETESTQNAME = 2;
-NodeTest.COMMENT = 3;
-NodeTest.TEXT = 4;
-NodeTest.PI = 5;
-NodeTest.NODE = 6;
-
-// VariableReference /////////////////////////////////////////////////////////
-
-VariableReference.prototype = new Expression();
-VariableReference.prototype.constructor = VariableReference;
-VariableReference.superclass = Expression.prototype;
-
-function VariableReference(v) {
-       if (arguments.length > 0) {
-               this.init(v);
-       }
-}
-
-VariableReference.prototype.init = function(v) {
-       this.variable = v;
-};
-
-VariableReference.prototype.toString = function() {
-       return "$" + this.variable;
-};
-
-VariableReference.prototype.evaluate = function(c) {
-       return c.variableResolver.getVariable(this.variable, c);
-};
-
-// FunctionCall //////////////////////////////////////////////////////////////
-
-FunctionCall.prototype = new Expression();
-FunctionCall.prototype.constructor = FunctionCall;
-FunctionCall.superclass = Expression.prototype;
-
-function FunctionCall(fn, args) {
-       if (arguments.length > 0) {
-               this.init(fn, args);
-       }
-}
-
-FunctionCall.prototype.init = function(fn, args) {
-       this.functionName = fn;
-       this.arguments = args;
-};
-
-FunctionCall.prototype.toString = function() {
-       var s = this.functionName + "(";
-       for (var i = 0; i < this.arguments.length; i++) {
-               if (i > 0) {
-                       s += ", ";
-               }
-               s += this.arguments[i].toString();
-       }
-       return s + ")";
-};
-
-FunctionCall.prototype.evaluate = function(c) {
-       var f = c.functionResolver.getFunction(this.functionName, c);
-       if (f == undefined) {
-               throw new Error("Unknown function " + this.functionName);
-       }
-       var a = [c].concat(this.arguments);
-       return f.apply(c.functionResolver.thisArg, a);
-};
-
-// XString ///////////////////////////////////////////////////////////////////
-
-XString.prototype = new Expression();
-XString.prototype.constructor = XString;
-XString.superclass = Expression.prototype;
-
-function XString(s) {
-       if (arguments.length > 0) {
-               this.init(s);
-       }
-}
-
-XString.prototype.init = function(s) {
-       this.str = s;
-};
-
-XString.prototype.toString = function() {
-       return this.str;
-};
-
-XString.prototype.evaluate = function(c) {
-       return this;
-};
-
-XString.prototype.string = function() {
-       return this;
-};
-
-XString.prototype.number = function() {
-       return new XNumber(this.str);
-};
-
-XString.prototype.bool = function() {
-       return new XBoolean(this.str);
-};
-
-XString.prototype.nodeset = function() {
-       throw new Error("Cannot convert string to nodeset");
-};
-
-XString.prototype.stringValue = function() {
-       return this.str;
-};
-
-XString.prototype.numberValue = function() {
-       return this.number().numberValue();
-};
-
-XString.prototype.booleanValue = function() {
-       return this.bool().booleanValue();
-};
-
-XString.prototype.equals = function(r) {
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.bool().equals(r);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.number().equals(r);
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithString(this, Operators.equals);
-       }
-       return new XBoolean(this.str == r.str);
-};
-
-XString.prototype.notequal = function(r) {
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.bool().notequal(r);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.number().notequal(r);
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithString(this, Operators.notequal);
-       }
-       return new XBoolean(this.str != r.str);
-};
-
-XString.prototype.lessthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.greaterthanorequal);
-       }
-       return this.number().lessthan(r.number());
-};
-
-XString.prototype.greaterthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.lessthanorequal);
-       }
-       return this.number().greaterthan(r.number());
-};
-
-XString.prototype.lessthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.greaterthan);
-       }
-       return this.number().lessthanorequal(r.number());
-};
-
-XString.prototype.greaterthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.lessthan);
-       }
-       return this.number().greaterthanorequal(r.number());
-};
-
-// XNumber ///////////////////////////////////////////////////////////////////
-
-XNumber.prototype = new Expression();
-XNumber.prototype.constructor = XNumber;
-XNumber.superclass = Expression.prototype;
-
-function XNumber(n) {
-       if (arguments.length > 0) {
-               this.init(n);
-       }
-}
-
-XNumber.prototype.init = function(n) {
-       this.num = Number(n);
-};
-
-XNumber.prototype.toString = function() {
-       return this.num;
-};
-
-XNumber.prototype.evaluate = function(c) {
-       return this;
-};
-
-XNumber.prototype.string = function() {
-       return new XString(this.num);
-};
-
-XNumber.prototype.number = function() {
-       return this;
-};
-
-XNumber.prototype.bool = function() {
-       return new XBoolean(this.num);
-};
-
-XNumber.prototype.nodeset = function() {
-       throw new Error("Cannot convert number to nodeset");
-};
-
-XNumber.prototype.stringValue = function() {
-       return this.string().stringValue();
-};
-
-XNumber.prototype.numberValue = function() {
-       return this.num;
-};
-
-XNumber.prototype.booleanValue = function() {
-       return this.bool().booleanValue();
-};
-
-XNumber.prototype.negate = function() {
-       return new XNumber(-this.num);
-};
-
-XNumber.prototype.equals = function(r) {
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.bool().equals(r);
-       }
-       if (Utilities.instance_of(r, XString)) {
-               return this.equals(r.number());
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.equals);
-       }
-       return new XBoolean(this.num == r.num);
-};
-
-XNumber.prototype.notequal = function(r) {
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.bool().notequal(r);
-       }
-       if (Utilities.instance_of(r, XString)) {
-               return this.notequal(r.number());
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.notequal);
-       }
-       return new XBoolean(this.num != r.num);
-};
-
-XNumber.prototype.lessthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.greaterthanorequal);
-       }
-       if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
-               return this.lessthan(r.number());
-       }
-       return new XBoolean(this.num < r.num);
-};
-
-XNumber.prototype.greaterthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.lessthanorequal);
-       }
-       if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
-               return this.greaterthan(r.number());
-       }
-       return new XBoolean(this.num > r.num);
-};
-
-XNumber.prototype.lessthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.greaterthan);
-       }
-       if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
-               return this.lessthanorequal(r.number());
-       }
-       return new XBoolean(this.num <= r.num);
-};
-
-XNumber.prototype.greaterthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this, Operators.lessthan);
-       }
-       if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
-               return this.greaterthanorequal(r.number());
-       }
-       return new XBoolean(this.num >= r.num);
-};
-
-XNumber.prototype.plus = function(r) {
-       return new XNumber(this.num + r.num);
-};
-
-XNumber.prototype.minus = function(r) {
-       return new XNumber(this.num - r.num);
-};
-
-XNumber.prototype.multiply = function(r) {
-       return new XNumber(this.num * r.num);
-};
-
-XNumber.prototype.div = function(r) {
-       return new XNumber(this.num / r.num);
-};
-
-XNumber.prototype.mod = function(r) {
-       return new XNumber(this.num % r.num);
-};
-
-// XBoolean //////////////////////////////////////////////////////////////////
-
-XBoolean.prototype = new Expression();
-XBoolean.prototype.constructor = XBoolean;
-XBoolean.superclass = Expression.prototype;
-
-function XBoolean(b) {
-       if (arguments.length > 0) {
-               this.init(b);
-       }
-}
-
-XBoolean.prototype.init = function(b) {
-       this.b = Boolean(b);
-};
-
-XBoolean.prototype.toString = function() {
-       return this.b.toString();
-};
-
-XBoolean.prototype.evaluate = function(c) {
-       return this;
-};
-
-XBoolean.prototype.string = function() {
-       return new XString(this.b);
-};
-
-XBoolean.prototype.number = function() {
-       return new XNumber(this.b);
-};
-
-XBoolean.prototype.bool = function() {
-       return this;
-};
-
-XBoolean.prototype.nodeset = function() {
-       throw new Error("Cannot convert boolean to nodeset");
-};
-
-XBoolean.prototype.stringValue = function() {
-       return this.string().stringValue();
-};
-
-XBoolean.prototype.numberValue = function() {
-       return this.num().numberValue();
-};
-
-XBoolean.prototype.booleanValue = function() {
-       return this.b;
-};
-
-XBoolean.prototype.not = function() {
-       return new XBoolean(!this.b);
-};
-
-XBoolean.prototype.equals = function(r) {
-       if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {
-               return this.equals(r.bool());
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithBoolean(this, Operators.equals);
-       }
-       return new XBoolean(this.b == r.b);
-};
-
-XBoolean.prototype.notequal = function(r) {
-       if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {
-               return this.notequal(r.bool());
-       }
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithBoolean(this, Operators.notequal);
-       }
-       return new XBoolean(this.b != r.b);
-};
-
-XBoolean.prototype.lessthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.greaterthanorequal);
-       }
-       return this.number().lessthan(r.number());
-};
-
-XBoolean.prototype.greaterthan = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.lessthanorequal);
-       }
-       return this.number().greaterthan(r.number());
-};
-
-XBoolean.prototype.lessthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.greaterthan);
-       }
-       return this.number().lessthanorequal(r.number());
-};
-
-XBoolean.prototype.greaterthanorequal = function(r) {
-       if (Utilities.instance_of(r, XNodeSet)) {
-               return r.compareWithNumber(this.number(), Operators.lessthan);
-       }
-       return this.number().greaterthanorequal(r.number());
-};
-
-// AVLTree ///////////////////////////////////////////////////////////////////
-
-AVLTree.prototype = new Object();
-AVLTree.prototype.constructor = AVLTree;
-AVLTree.superclass = Object.prototype;
-
-function AVLTree(n) {
-       this.init(n);
-}
-
-AVLTree.prototype.init = function(n) {
-       this.left = null;
-    this.right = null;
-       this.node = n;
-       this.depth = 1;
-};
-
-AVLTree.prototype.balance = function() {
-    var ldepth = this.left  == null ? 0 : this.left.depth;
-    var rdepth = this.right == null ? 0 : this.right.depth;
-
-       if (ldepth > rdepth + 1) {
-        // LR or LL rotation
-        var lldepth = this.left.left  == null ? 0 : this.left.left.depth;
-        var lrdepth = this.left.right == null ? 0 : this.left.right.depth;
-
-        if (lldepth < lrdepth) {
-            // LR rotation consists of a RR rotation of the left child
-            this.left.rotateRR();
-            // plus a LL rotation of this node, which happens anyway 
-        }
-        this.rotateLL();       
-    } else if (ldepth + 1 < rdepth) {
-        // RR or RL rorarion
-               var rrdepth = this.right.right == null ? 0 : this.right.right.depth;
-               var rldepth = this.right.left  == null ? 0 : this.right.left.depth;
-        
-        if (rldepth > rrdepth) {
-            // RR rotation consists of a LL rotation of the right child
-            this.right.rotateLL();
-            // plus a RR rotation of this node, which happens anyway 
-        }
-        this.rotateRR();
-    }       
-};
-
-AVLTree.prototype.rotateLL = function() {
-    // the left side is too long => rotate from the left (_not_ leftwards)
-    var nodeBefore = this.node;
-    var rightBefore = this.right;
-    this.node = this.left.node;
-    this.right = this.left;
-    this.left = this.left.left;
-    this.right.left = this.right.right;
-    this.right.right = rightBefore;
-    this.right.node = nodeBefore;
-    this.right.updateInNewLocation();
-    this.updateInNewLocation();
-};
-
-AVLTree.prototype.rotateRR = function() {
-    // the right side is too long => rotate from the right (_not_ rightwards)
-    var nodeBefore = this.node;
-    var leftBefore = this.left;
-    this.node = this.right.node;
-    this.left = this.right;
-    this.right = this.right.right;
-    this.left.right = this.left.left;
-    this.left.left = leftBefore;
-    this.left.node = nodeBefore;
-    this.left.updateInNewLocation();
-    this.updateInNewLocation();
-}; 
-       
-AVLTree.prototype.updateInNewLocation = function() {
-    this.getDepthFromChildren();
-};
-
-AVLTree.prototype.getDepthFromChildren = function() {
-    this.depth = this.node == null ? 0 : 1;
-    if (this.left != null) {
-        this.depth = this.left.depth + 1;
-    }
-    if (this.right != null && this.depth <= this.right.depth) {
-        this.depth = this.right.depth + 1;
-    }
-};
-
-AVLTree.prototype.order = function(n1, n2) {
-       if (n1 === n2) {
-               return 0;
-       }
-       var d1 = 0;
-       var d2 = 0;
-       for (var m1 = n1; m1 != null; m1 = m1.parentNode) {
-               d1++;
-       }
-       for (var m2 = n2; m2 != null; m2 = m2.parentNode) {
-               d2++;
-       }
-       if (d1 > d2) {
-               while (d1 > d2) {
-                       n1 = n1.parentNode;
-                       d1--;
-               }
-               if (n1 == n2) {
-                       return 1;
-               }
-       } else if (d2 > d1) {
-               while (d2 > d1) {
-                       n2 = n2.parentNode;
-                       d2--;
-               }
-               if (n1 == n2) {
-                       return -1;
-               }
-       }
-       while (n1.parentNode != n2.parentNode) {
-               n1 = n1.parentNode;
-               n2 = n2.parentNode;
-       }
-       while (n1.previousSibling != null && n2.previousSibling != null) {
-               n1 = n1.previousSibling;
-               n2 = n2.previousSibling;
-       }
-       if (n1.previousSibling == null) {
-               return -1;
-       }
-       return 1;
-};
-
-AVLTree.prototype.add = function(n)  {
-       if (n === this.node) {
-        return false;
-    }
-       
-       var o = this.order(n, this.node);
-       
-    var ret = false;
-    if (o == -1) {
-        if (this.left == null) {
-            this.left = new AVLTree(n);
-            ret = true;
-        } else {
-            ret = this.left.add(n);
-            if (ret) {
-                this.balance();
-            }
-        }
-    } else if (o == 1) {
-        if (this.right == null) {
-            this.right = new AVLTree(n);
-            ret = true;
-        } else {
-            ret = this.right.add(n);
-            if (ret) {
-                this.balance();
-            }
-        }
-    }
-       
-    if (ret) {
-        this.getDepthFromChildren();
-    }
-    return ret;
-};
-
-// XNodeSet //////////////////////////////////////////////////////////////////
-
-XNodeSet.prototype = new Expression();
-XNodeSet.prototype.constructor = XNodeSet;
-XNodeSet.superclass = Expression.prototype;
-
-function XNodeSet() {
-       this.init();
-}
-
-XNodeSet.prototype.init = function() {
-       this.tree = null;
-       this.size = 0;
-};
-
-XNodeSet.prototype.toString = function() {
-       var p = this.first();
-       if (p == null) {
-               return "";
-       }
-       return this.stringForNode(p);
-};
-
-XNodeSet.prototype.evaluate = function(c) {
-       return this;
-};
-
-XNodeSet.prototype.string = function() {
-       return new XString(this.toString());
-};
-
-XNodeSet.prototype.stringValue = function() {
-       return this.toString();
-};
-
-XNodeSet.prototype.number = function() {
-       return new XNumber(this.string());
-};
-
-XNodeSet.prototype.numberValue = function() {
-       return Number(this.string());
-};
-
-XNodeSet.prototype.bool = function() {
-       return new XBoolean(this.tree != null);
-};
-
-XNodeSet.prototype.booleanValue = function() {
-       return this.tree != null;
-};
-
-XNodeSet.prototype.nodeset = function() {
-       return this;
-};
-
-XNodeSet.prototype.stringForNode = function(n) {
-       if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/) {
-               n = n.documentElement;
-       }
-       if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-               return this.stringForNodeRec(n);
-       }
-       if (n.isNamespaceNode) {
-               return n.namespace;
-       }
-       return n.nodeValue;
-};
-
-XNodeSet.prototype.stringForNodeRec = function(n) {
-       var s = "";
-       for (var n2 = n.firstChild; n2 != null; n2 = n2.nextSibling) {
-               if (n2.nodeType == 3 /*Node.TEXT_NODE*/) {
-                       s += n2.nodeValue;
-               } else if (n2.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-                       s += this.stringForNodeRec(n2);
-               }
-       }
-       return s;
-};
-
-XNodeSet.prototype.first = function() {
-       var p = this.tree;
-       if (p == null) {
-               return null;
-       }
-       while (p.left != null) {
-               p = p.left;
-       }
-       return p.node;
-};
-
-XNodeSet.prototype.add = function(n) {
-    var added;
-    if (this.tree == null) {
-        this.tree = new AVLTree(n);
-        added = true;
-    } else {
-        added = this.tree.add(n);
-    }
-    if (added) {
-        this.size++;
-    }
-};
-
-XNodeSet.prototype.addArray = function(ns) {
-       for (var i = 0; i < ns.length; i++) {
-               this.add(ns[i]);
-       }
-};
-
-XNodeSet.prototype.toArray = function() {
-       var a = [];
-       this.toArrayRec(this.tree, a);
-       return a;
-};
-
-XNodeSet.prototype.toArrayRec = function(t, a) {
-       if (t != null) {
-               this.toArrayRec(t.left, a);
-               a.push(t.node);
-               this.toArrayRec(t.right, a);
-       }
-};
-
-XNodeSet.prototype.compareWithString = function(r, o) {
-       var a = this.toArray();
-       for (var i = 0; i < a.length; i++) {
-               var n = a[i];
-               var l = new XString(this.stringForNode(n));
-               var res = o(l, r);
-               if (res.booleanValue()) {
-                       return res;
-               }
-       }
-       return new XBoolean(false);
-};
-
-XNodeSet.prototype.compareWithNumber = function(r, o) {
-       var a = this.toArray();
-       for (var i = 0; i < a.length; i++) {
-               var n = a[i];
-               var l = new XNumber(this.stringForNode(n));
-               var res = o(l, r);
-               if (res.booleanValue()) {
-                       return res;
-               }
-       }
-       return new XBoolean(false);
-};
-
-XNodeSet.prototype.compareWithBoolean = function(r, o) {
-       return o(this.bool(), r);
-};
-
-XNodeSet.prototype.compareWithNodeSet = function(r, o) {
-       var a = this.toArray();
-       for (var i = 0; i < a.length; i++) {
-               var n = a[i];
-               var l = new XString(this.stringForNode(n));
-               var b = r.toArray();
-               for (var j = 0; j < b.length; j++) {
-                       var n2 = b[j];
-                       var r = new XString(this.stringForNode(n2));
-                       var res = o(l, r);
-                       if (res.booleanValue()) {
-                               return res;
-                       }
-               }
-       }
-       return new XBoolean(false);
-};
-
-XNodeSet.prototype.equals = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithString(r, Operators.equals);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.equals);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.equals);
-       }
-       return this.compareWithNodeSet(r, Operators.equals);
-};
-
-XNodeSet.prototype.notequal = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithString(r, Operators.notequal);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.notequal);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.notequal);
-       }
-       return this.compareWithNodeSet(r, Operators.notequal);
-};
-
-XNodeSet.prototype.lessthan = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithNumber(r.number(), Operators.lessthan);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.lessthan);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.lessthan);
-       }
-       return this.compareWithNodeSet(r, Operators.lessthan);
-};
-
-XNodeSet.prototype.greaterthan = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithNumber(r.number(), Operators.greaterthan);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.greaterthan);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.greaterthan);
-       }
-       return this.compareWithNodeSet(r, Operators.greaterthan);
-};
-
-XNodeSet.prototype.lessthanorequal = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithNumber(r.number(), Operators.lessthanorequal);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.lessthanorequal);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.lessthanorequal);
-       }
-       return this.compareWithNodeSet(r, Operators.lessthanorequal);
-};
-
-XNodeSet.prototype.greaterthanorequal = function(r) {
-       if (Utilities.instance_of(r, XString)) {
-               return this.compareWithNumber(r.number(), Operators.greaterthanorequal);
-       }
-       if (Utilities.instance_of(r, XNumber)) {
-               return this.compareWithNumber(r, Operators.greaterthanorequal);
-       }
-       if (Utilities.instance_of(r, XBoolean)) {
-               return this.compareWithBoolean(r, Operators.greaterthanorequal);
-       }
-       return this.compareWithNodeSet(r, Operators.greaterthanorequal);
-};
-
-XNodeSet.prototype.union = function(r) {
-       var ns = new XNodeSet();
-       ns.tree = this.tree;
-       ns.size = this.size;
-       ns.addArray(r.toArray());
-       return ns;
-};
-
-// XPathNamespace ////////////////////////////////////////////////////////////
-
-XPathNamespace.prototype = new Object();
-XPathNamespace.prototype.constructor = XPathNamespace;
-XPathNamespace.superclass = Object.prototype;
-
-function XPathNamespace(pre, ns, p) {
-       this.isXPathNamespace = true;
-       this.ownerDocument = p.ownerDocument;
-       this.nodeName = "#namespace";
-       this.prefix = pre;
-       this.localName = pre;
-       this.namespaceURI = ns;
-       this.nodeValue = ns;
-       this.ownerElement = p;
-       this.nodeType = XPathNamespace.XPATH_NAMESPACE_NODE;
-}
-
-XPathNamespace.prototype.toString = function() {
-       return "{ \"" + this.prefix + "\", \"" + this.namespaceURI + "\" }";
-};
-
-// Operators /////////////////////////////////////////////////////////////////
-
-var Operators = new Object();
-
-Operators.equals = function(l, r) {
-       return l.equals(r);
-};
-
-Operators.notequal = function(l, r) {
-       return l.notequal(r);
-};
-
-Operators.lessthan = function(l, r) {
-       return l.lessthan(r);
-};
-
-Operators.greaterthan = function(l, r) {
-       return l.greaterthan(r);
-};
-
-Operators.lessthanorequal = function(l, r) {
-       return l.lessthanorequal(r);
-};
-
-Operators.greaterthanorequal = function(l, r) {
-       return l.greaterthanorequal(r);
-};
-
-// XPathContext //////////////////////////////////////////////////////////////
-
-XPathContext.prototype = new Object();
-XPathContext.prototype.constructor = XPathContext;
-XPathContext.superclass = Object.prototype;
-
-function XPathContext(vr, nr, fr) {
-       this.variableResolver = vr != null ? vr : new VariableResolver();
-       this.namespaceResolver = nr != null ? nr : new NamespaceResolver();
-       this.functionResolver = fr != null ? fr : new FunctionResolver();
-}
-
-// VariableResolver //////////////////////////////////////////////////////////
-
-VariableResolver.prototype = new Object();
-VariableResolver.prototype.constructor = VariableResolver;
-VariableResolver.superclass = Object.prototype;
-
-function VariableResolver() {
-}
-
-VariableResolver.prototype.getVariable = function(vn, c) {
-       var parts = Utilities.splitQName(vn);
-       if (parts[0] != null) {
-               parts[0] = c.namespaceResolver.getNamespace(parts[0], c.expressionContextNode);
-        if (parts[0] == null) {
-            throw new Error("Cannot resolve QName " + fn);
-        }
-       }
-       return this.getVariableWithName(parts[0], parts[1], c.expressionContextNode);
-};
-
-VariableResolver.prototype.getVariableWithName = function(ns, ln, c) {
-       return null;
-};
-
-// FunctionResolver //////////////////////////////////////////////////////////
-
-FunctionResolver.prototype = new Object();
-FunctionResolver.prototype.constructor = FunctionResolver;
-FunctionResolver.superclass = Object.prototype;
-
-function FunctionResolver(thisArg) {
-       this.thisArg = thisArg != null ? thisArg : Functions;
-       this.functions = new Object();
-       this.addStandardFunctions();
-}
-
-FunctionResolver.prototype.addStandardFunctions = function() {
-       this.functions["{}last"] = Functions.last;
-       this.functions["{}position"] = Functions.position;
-       this.functions["{}count"] = Functions.count;
-       this.functions["{}id"] = Functions.id;
-       this.functions["{}local-name"] = Functions.localName;
-       this.functions["{}namespace-uri"] = Functions.namespaceURI;
-       this.functions["{}name"] = Functions.name;
-       this.functions["{}string"] = Functions.string;
-       this.functions["{}concat"] = Functions.concat;
-       this.functions["{}starts-with"] = Functions.startsWith;
-       this.functions["{}contains"] = Functions.contains;
-       this.functions["{}substring-before"] = Functions.substringBefore;
-       this.functions["{}substring-after"] = Functions.substringAfter;
-       this.functions["{}substring"] = Functions.substring;
-       this.functions["{}string-length"] = Functions.stringLength;
-       this.functions["{}normalize-space"] = Functions.normalizeSpace;
-       this.functions["{}translate"] = Functions.translate;
-       this.functions["{}boolean"] = Functions.boolean_;
-       this.functions["{}not"] = Functions.not;
-       this.functions["{}true"] = Functions.true_;
-       this.functions["{}false"] = Functions.false_;
-       this.functions["{}lang"] = Functions.lang;
-       this.functions["{}number"] = Functions.number;
-       this.functions["{}sum"] = Functions.sum;
-       this.functions["{}floor"] = Functions.floor;
-       this.functions["{}ceiling"] = Functions.ceiling;
-       this.functions["{}round"] = Functions.round;
-};
-
-FunctionResolver.prototype.addFunction = function(ns, ln, f) {
-       this.functions["{" + ns + "}" + ln] = f;
-};
-
-FunctionResolver.prototype.getFunction = function(fn, c) {
-       var parts = Utilities.resolveQName(fn, c.namespaceResolver, c.contextNode, false);
-    if (parts[0] == null) {
-        throw new Error("Cannot resolve QName " + fn);
-    }
-       return this.getFunctionWithName(parts[0], parts[1], c.contextNode);
-};
-
-FunctionResolver.prototype.getFunctionWithName = function(ns, ln, c) {
-       return this.functions["{" + ns + "}" + ln];
-};
-
-// NamespaceResolver /////////////////////////////////////////////////////////
-
-NamespaceResolver.prototype = new Object();
-NamespaceResolver.prototype.constructor = NamespaceResolver;
-NamespaceResolver.superclass = Object.prototype;
-
-function NamespaceResolver() {
-}
-
-NamespaceResolver.prototype.getNamespace = function(prefix, n) {
-       if (prefix == "xml") {
-               return XPath.XML_NAMESPACE_URI;
-       } else if (prefix == "xmlns") {
-               return XPath.XMLNS_NAMESPACE_URI;
-       }
-       if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/) {
-               n = n.documentElement;
-       } else if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
-               n = PathExpr.prototype.getOwnerElement(n);
-       } else if (n.nodeType != 1 /*Node.ELEMENT_NODE*/) {
-               n = n.parentNode;
-       }
-       while (n != null && n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-               var nnm = n.attributes;
-               for (var i = 0; i < nnm.length; i++) {
-                       var a = nnm.item(i);
-                       var aname = a.nodeName;
-                       if (aname == "xmlns" && prefix == ""
-                                       || aname == "xmlns:" + prefix) {
-                               return String(a.nodeValue);
-                       }
-               }
-               n = n.parentNode;
-       }
-       return null;
-};
-
-// Functions /////////////////////////////////////////////////////////////////
-
-Functions = new Object();
-
-Functions.last = function() {
-       var c = arguments[0];
-       if (arguments.length != 1) {
-               throw new Error("Function last expects ()");
-       }
-       return new XNumber(c.contextSize);
-};
-
-Functions.position = function() {
-       var c = arguments[0];
-       if (arguments.length != 1) {
-               throw new Error("Function position expects ()");
-       }
-       return new XNumber(c.contextPosition);
-};
-
-Functions.count = function() {
-       var c = arguments[0];
-       var ns;
-       if (arguments.length != 2 || !Utilities.instance_of(ns = arguments[1].evaluate(c), XNodeSet)) {
-               throw new Error("Function count expects (node-set)");
-       }
-       return new XNumber(ns.size);
-};
-
-Functions.id = function() {
-       var c = arguments[0];
-       var id;
-       if (arguments.length != 2) {
-               throw new Error("Function id expects (object)");
-       }
-       id = arguments[1].evaluate(c);
-       if (Utilities.instance_of(id, XNodeSet)) {
-               id = id.toArray().join(" ");
-       } else {
-               id = id.stringValue();
-       }
-       var ids = id.split(/[\x0d\x0a\x09\x20]+/);
-       var count = 0;
-       var ns = new XNodeSet();
-       var doc = c.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
-                       ? c.contextNode
-                       : c.contextNode.ownerDocument;
-       for (var i = 0; i < ids.length; i++) {
-               var n;
-               if (doc.getElementById) {
-                       n = doc.getElementById(ids[i]);
-               } else {
-                       n = Utilities.getElementById(doc, ids[i]);
-               }
-               if (n != null) {
-                       ns.add(n);
-                       count++;
-               }
-       }
-       return ns;
-};
-
-Functions.localName = function() {
-       var c = arguments[0];
-       var n;
-       if (arguments.length == 1) {
-               n = c.contextNode;
-       } else if (arguments.length == 2) {
-               n = arguments[1].evaluate(c).first();
-       } else {
-               throw new Error("Function local-name expects (node-set?)");
-       }
-       if (n == null) {
-               return new XString("");
-       }
-       return new XString(n.localName ? n.localName : n.baseName);
-};
-
-Functions.namespaceURI = function() {
-       var c = arguments[0];
-       var n;
-       if (arguments.length == 1) {
-               n = c.contextNode;
-       } else if (arguments.length == 2) {
-               n = arguments[1].evaluate(c).first();
-       } else {
-               throw new Error("Function namespace-uri expects (node-set?)");
-       }
-       if (n == null) {
-               return new XString("");
-       }
-       return new XString(n.namespaceURI);
-};
-
-Functions.name = function() {
-       var c = arguments[0];
-       var n;
-       if (arguments.length == 1) {
-               n = c.contextNode;
-       } else if (arguments.length == 2) {
-               n = arguments[1].evaluate(c).first();
-       } else {
-               throw new Error("Function name expects (node-set?)");
-       }
-       if (n == null) {
-               return new XString("");
-       }
-       if (n.nodeType == 1 /*Node.ELEMENT_NODE*/ || n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
-               return new XString(n.nodeName);
-       } else if (n.localName == null) {
-               return new XString("");
-       } else {
-               return new XString(n.localName);
-       }
-};
-
-Functions.string = function() {
-       var c = arguments[0];
-       if (arguments.length == 1) {
-               return XNodeSet.prototype.stringForNode(c.contextNode);
-       } else if (arguments.length == 2) {
-               return arguments[1].evaluate(c).string();
-       }
-       throw new Error("Function string expects (object?)");
-};
-
-Functions.concat = function() {
-       var c = arguments[0];
-       if (arguments.length < 3) {
-               throw new Error("Function concat expects (string, string, string*)");
-       }
-       var s = "";
-       for (var i = 1; i < arguments.length; i++) {
-               s += arguments[i].evaluate(c).stringValue();
-       }
-       return new XString(s);
-};
-
-Functions.startsWith = function() {
-       var c = arguments[0];
-       if (arguments.length != 3) {
-               throw new Error("Function startsWith expects (string, string)");
-       }
-       var s1 = arguments[1].evaluate(c).stringValue();
-       var s2 = arguments[2].evaluate(c).stringValue();
-       return new XBoolean(s1.substring(0, s2.length) == s2);
-};
-
-Functions.contains = function() {
-       var c = arguments[0];
-       if (arguments.length != 3) {
-               throw new Error("Function contains expects (string, string)");
-       }
-       var s1 = arguments[1].evaluate(c).stringValue();
-       var s2 = arguments[2].evaluate(c).stringValue();
-       return new XBoolean(s1.indexOf(s2) != -1);
-};
-
-Functions.substringBefore = function() {
-       var c = arguments[0];
-       if (arguments.length != 3) {
-               throw new Error("Function substring-before expects (string, string)");
-       }
-       var s1 = arguments[1].evaluate(c).stringValue();
-       var s2 = arguments[2].evaluate(c).stringValue();
-       return new XString(s1.substring(0, s1.indexOf(s2)));
-};
-
-Functions.substringAfter = function() {
-       var c = arguments[0];
-       if (arguments.length != 3) {
-               throw new Error("Function substring-after expects (string, string)");
-       }
-       var s1 = arguments[1].evaluate(c).stringValue();
-       var s2 = arguments[2].evaluate(c).stringValue();
-       if (s2.length == 0) {
-               return new XString(s1);
-       }
-       var i = s1.indexOf(s2);
-       if (i == -1) {
-               return new XString("");
-       }
-       return new XString(s1.substring(s1.indexOf(s2) + 1));
-};
-
-Functions.substring = function() {
-       var c = arguments[0];
-       if (!(arguments.length == 3 || arguments.length == 4)) {
-               throw new Error("Function substring expects (string, number, number?)");
-       }
-       var s = arguments[1].evaluate(c).stringValue();
-       var n1 = Math.round(arguments[2].evaluate(c).numberValue()) - 1;
-       var n2 = arguments.length == 4 ? n1 + Math.round(arguments[3].evaluate(c).numberValue()) : undefined;
-       return new XString(s.substring(n1, n2));
-};
-
-Functions.stringLength = function() {
-       var c = arguments[0];
-       var s;
-       if (arguments.length == 1) {
-               s = XNodeSet.prototype.stringForNode(c.contextNode);
-       } else if (arguments.length == 2) {
-               s = arguments[1].evaluate(c).stringValue();
-       } else {
-               throw new Error("Function string-length expects (string?)");
-       }
-       return new XNumber(s.length);
-};
-
-Functions.normalizeSpace = function() {
-       var c = arguments[0];
-       var s;
-       if (arguments.length == 1) {
-               s = XNodeSet.prototype.stringForNode(c.contextNode);
-       } else if (arguments.length == 2) {
-               s = arguments[1].evaluate(c).stringValue();
-       } else {
-               throw new Error("Function normalize-space expects (string?)");
-       }
-       var i = 0;
-       var j = s.length - 1;
-       while (Utilities.isSpace(s.charCodeAt(j))) {
-               j--;
-       }
-       var t = "";
-       while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {
-               i++;
-       }
-       while (i <= j) {
-               if (Utilities.isSpace(s.charCodeAt(i))) {
-                       t += " ";
-                       while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {
-                               i++;
-                       }
-               } else {
-                       t += s.charAt(i);
-                       i++;
-               }
-       }
-       return new XString(t);
-};
-
-Functions.translate = function() {
-       var c = arguments[0];
-       if (arguments.length != 4) {
-               throw new Error("Function translate expects (string, string, string)");
-       }
-       var s1 = arguments[1].evaluate(c).stringValue();
-       var s2 = arguments[2].evaluate(c).stringValue();
-       var s3 = arguments[3].evaluate(c).stringValue();
-       var map = [];
-       for (var i = 0; i < s2.length; i++) {
-               var j = s2.charCodeAt(i);
-               if (map[j] == undefined) {
-                       var k = i > s3.length ? "" : s3.charAt(i);
-                       map[j] = k;
-               }
-       }
-       var t = "";
-       for (var i = 0; i < s1.length; i++) {
-               var c = s1.charCodeAt(i);
-               var r = map[c];
-               if (r == undefined) {
-                       t += s1.charAt(i);
-               } else {
-                       t += r;
-               }
-       }
-       return new XString(t);
-};
-
-Functions.boolean_ = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function boolean expects (object)");
-       }
-       return arguments[1].evaluate(c).bool();
-};
-
-Functions.not = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function not expects (object)");
-       }
-       return arguments[1].evaluate(c).bool().not();
-};
-
-Functions.true_ = function() {
-       if (arguments.length != 1) {
-               throw new Error("Function true expects ()");
-       }
-       return new XBoolean(true);
-};
-
-Functions.false_ = function() {
-       if (arguments.length != 1) {
-               throw new Error("Function false expects ()");
-       }
-       return new XBoolean(false);
-};
-
-Functions.lang = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function lang expects (string)");
-       }
-       var lang;
-       for (var n = c.contextNode; n != null && n.nodeType != 9 /*Node.DOCUMENT_NODE*/; n = n.parentNode) {
-               var a = n.getAttributeNS(XPath.XML_NAMESPACE_URI, "lang");
-               if (a != null) {
-                       lang = String(a);
-                       break;
-               }
-       }
-       if (lang == null) {
-               return new XBoolean(false);
-       }
-       var s = arguments[1].evaluate(c).stringValue();
-       return new XBoolean(lang.substring(0, s.length) == s
-                               && (lang.length == s.length || lang.charAt(s.length) == '-'));
-};
-
-Functions.number = function() {
-       var c = arguments[0];
-       if (!(arguments.length == 1 || arguments.length == 2)) {
-               throw new Error("Function number expects (object?)");
-       }
-       if (arguments.length == 1) {
-               return new XNumber(XNodeSet.prototype.stringForNode(c.contextNode));
-       }
-       return arguments[1].evaluate(c).number();
-};
-
-Functions.sum = function() {
-       var c = arguments[0];
-       var ns;
-       if (arguments.length != 2 || !Utilities.instance_of((ns = arguments[1].evaluate(c)), XNodeSet)) {
-               throw new Error("Function sum expects (node-set)");
-       }
-       ns = ns.toArray();
-       var n = 0;
-       for (var i = 0; i < ns.length; i++) {
-               n += new XNumber(XNodeSet.prototype.stringForNode(ns[i])).numberValue();
-       }
-       return new XNumber(n);
-};
-
-Functions.floor = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function floor expects (number)");
-       }
-       return new XNumber(Math.floor(arguments[1].evaluate(c).numberValue()));
-};
-
-Functions.ceiling = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function ceiling expects (number)");
-       }
-       return new XNumber(Math.ceil(arguments[1].evaluate(c).numberValue()));
-};
-
-Functions.round = function() {
-       var c = arguments[0];
-       if (arguments.length != 2) {
-               throw new Error("Function round expects (number)");
-       }
-       return new XNumber(Math.round(arguments[1].evaluate(c).numberValue()));
-};
-
-// Utilities /////////////////////////////////////////////////////////////////
-
-Utilities = new Object();
-
-Utilities.splitQName = function(qn) {
-       var i = qn.indexOf(":");
-       if (i == -1) {
-               return [ null, qn ];
-       }
-       return [ qn.substring(0, i), qn.substring(i + 1) ];
-};
-
-Utilities.resolveQName = function(qn, nr, n, useDefault) {
-       var parts = Utilities.splitQName(qn);
-       if (parts[0] != null) {
-               parts[0] = nr.getNamespace(parts[0], n);
-       } else {
-               if (useDefault) {
-                       parts[0] = nr.getNamespace("", n);
-                       if (parts[0] == null) {
-                               parts[0] = "";
-                       }
-               } else {
-                       parts[0] = "";
-               }
-       }
-       return parts;
-};
-
-Utilities.isSpace = function(c) {
-       return c == 0x9 || c == 0xd || c == 0xa || c == 0x20;
-};
-
-Utilities.isLetter = function(c) {
-       return c >= 0x0041 && c <= 0x005A ||
-               c >= 0x0061 && c <= 0x007A ||
-               c >= 0x00C0 && c <= 0x00D6 ||
-               c >= 0x00D8 && c <= 0x00F6 ||
-               c >= 0x00F8 && c <= 0x00FF ||
-               c >= 0x0100 && c <= 0x0131 ||
-               c >= 0x0134 && c <= 0x013E ||
-               c >= 0x0141 && c <= 0x0148 ||
-               c >= 0x014A && c <= 0x017E ||
-               c >= 0x0180 && c <= 0x01C3 ||
-               c >= 0x01CD && c <= 0x01F0 ||
-               c >= 0x01F4 && c <= 0x01F5 ||
-               c >= 0x01FA && c <= 0x0217 ||
-               c >= 0x0250 && c <= 0x02A8 ||
-               c >= 0x02BB && c <= 0x02C1 ||
-               c == 0x0386 ||
-               c >= 0x0388 && c <= 0x038A ||
-               c == 0x038C ||
-               c >= 0x038E && c <= 0x03A1 ||
-               c >= 0x03A3 && c <= 0x03CE ||
-               c >= 0x03D0 && c <= 0x03D6 ||
-               c == 0x03DA ||
-               c == 0x03DC ||
-               c == 0x03DE ||
-               c == 0x03E0 ||
-               c >= 0x03E2 && c <= 0x03F3 ||
-               c >= 0x0401 && c <= 0x040C ||
-               c >= 0x040E && c <= 0x044F ||
-               c >= 0x0451 && c <= 0x045C ||
-               c >= 0x045E && c <= 0x0481 ||
-               c >= 0x0490 && c <= 0x04C4 ||
-               c >= 0x04C7 && c <= 0x04C8 ||
-               c >= 0x04CB && c <= 0x04CC ||
-               c >= 0x04D0 && c <= 0x04EB ||
-               c >= 0x04EE && c <= 0x04F5 ||
-               c >= 0x04F8 && c <= 0x04F9 ||
-               c >= 0x0531 && c <= 0x0556 ||
-               c == 0x0559 ||
-               c >= 0x0561 && c <= 0x0586 ||
-               c >= 0x05D0 && c <= 0x05EA ||
-               c >= 0x05F0 && c <= 0x05F2 ||
-               c >= 0x0621 && c <= 0x063A ||
-               c >= 0x0641 && c <= 0x064A ||
-               c >= 0x0671 && c <= 0x06B7 ||
-               c >= 0x06BA && c <= 0x06BE ||
-               c >= 0x06C0 && c <= 0x06CE ||
-               c >= 0x06D0 && c <= 0x06D3 ||
-               c == 0x06D5 ||
-               c >= 0x06E5 && c <= 0x06E6 ||
-               c >= 0x0905 && c <= 0x0939 ||
-               c == 0x093D ||
-               c >= 0x0958 && c <= 0x0961 ||
-               c >= 0x0985 && c <= 0x098C ||
-               c >= 0x098F && c <= 0x0990 ||
-               c >= 0x0993 && c <= 0x09A8 ||
-               c >= 0x09AA && c <= 0x09B0 ||
-               c == 0x09B2 ||
-               c >= 0x09B6 && c <= 0x09B9 ||
-               c >= 0x09DC && c <= 0x09DD ||
-               c >= 0x09DF && c <= 0x09E1 ||
-               c >= 0x09F0 && c <= 0x09F1 ||
-               c >= 0x0A05 && c <= 0x0A0A ||
-               c >= 0x0A0F && c <= 0x0A10 ||
-               c >= 0x0A13 && c <= 0x0A28 ||
-               c >= 0x0A2A && c <= 0x0A30 ||
-               c >= 0x0A32 && c <= 0x0A33 ||
-               c >= 0x0A35 && c <= 0x0A36 ||
-               c >= 0x0A38 && c <= 0x0A39 ||
-               c >= 0x0A59 && c <= 0x0A5C ||
-               c == 0x0A5E ||
-               c >= 0x0A72 && c <= 0x0A74 ||
-               c >= 0x0A85 && c <= 0x0A8B ||
-               c == 0x0A8D ||
-               c >= 0x0A8F && c <= 0x0A91 ||
-               c >= 0x0A93 && c <= 0x0AA8 ||
-               c >= 0x0AAA && c <= 0x0AB0 ||
-               c >= 0x0AB2 && c <= 0x0AB3 ||
-               c >= 0x0AB5 && c <= 0x0AB9 ||
-               c == 0x0ABD ||
-               c == 0x0AE0 ||
-               c >= 0x0B05 && c <= 0x0B0C ||
-               c >= 0x0B0F && c <= 0x0B10 ||
-               c >= 0x0B13 && c <= 0x0B28 ||
-               c >= 0x0B2A && c <= 0x0B30 ||
-               c >= 0x0B32 && c <= 0x0B33 ||
-               c >= 0x0B36 && c <= 0x0B39 ||
-               c == 0x0B3D ||
-               c >= 0x0B5C && c <= 0x0B5D ||
-               c >= 0x0B5F && c <= 0x0B61 ||
-               c >= 0x0B85 && c <= 0x0B8A ||
-               c >= 0x0B8E && c <= 0x0B90 ||
-               c >= 0x0B92 && c <= 0x0B95 ||
-               c >= 0x0B99 && c <= 0x0B9A ||
-               c == 0x0B9C ||
-               c >= 0x0B9E && c <= 0x0B9F ||
-               c >= 0x0BA3 && c <= 0x0BA4 ||
-               c >= 0x0BA8 && c <= 0x0BAA ||
-               c >= 0x0BAE && c <= 0x0BB5 ||
-               c >= 0x0BB7 && c <= 0x0BB9 ||
-               c >= 0x0C05 && c <= 0x0C0C ||
-               c >= 0x0C0E && c <= 0x0C10 ||
-               c >= 0x0C12 && c <= 0x0C28 ||
-               c >= 0x0C2A && c <= 0x0C33 ||
-               c >= 0x0C35 && c <= 0x0C39 ||
-               c >= 0x0C60 && c <= 0x0C61 ||
-               c >= 0x0C85 && c <= 0x0C8C ||
-               c >= 0x0C8E && c <= 0x0C90 ||
-               c >= 0x0C92 && c <= 0x0CA8 ||
-               c >= 0x0CAA && c <= 0x0CB3 ||
-               c >= 0x0CB5 && c <= 0x0CB9 ||
-               c == 0x0CDE ||
-               c >= 0x0CE0 && c <= 0x0CE1 ||
-               c >= 0x0D05 && c <= 0x0D0C ||
-               c >= 0x0D0E && c <= 0x0D10 ||
-               c >= 0x0D12 && c <= 0x0D28 ||
-               c >= 0x0D2A && c <= 0x0D39 ||
-               c >= 0x0D60 && c <= 0x0D61 ||
-               c >= 0x0E01 && c <= 0x0E2E ||
-               c == 0x0E30 ||
-               c >= 0x0E32 && c <= 0x0E33 ||
-               c >= 0x0E40 && c <= 0x0E45 ||
-               c >= 0x0E81 && c <= 0x0E82 ||
-               c == 0x0E84 ||
-               c >= 0x0E87 && c <= 0x0E88 ||
-               c == 0x0E8A ||
-               c == 0x0E8D ||
-               c >= 0x0E94 && c <= 0x0E97 ||
-               c >= 0x0E99 && c <= 0x0E9F ||
-               c >= 0x0EA1 && c <= 0x0EA3 ||
-               c == 0x0EA5 ||
-               c == 0x0EA7 ||
-               c >= 0x0EAA && c <= 0x0EAB ||
-               c >= 0x0EAD && c <= 0x0EAE ||
-               c == 0x0EB0 ||
-               c >= 0x0EB2 && c <= 0x0EB3 ||
-               c == 0x0EBD ||
-               c >= 0x0EC0 && c <= 0x0EC4 ||
-               c >= 0x0F40 && c <= 0x0F47 ||
-               c >= 0x0F49 && c <= 0x0F69 ||
-               c >= 0x10A0 && c <= 0x10C5 ||
-               c >= 0x10D0 && c <= 0x10F6 ||
-               c == 0x1100 ||
-               c >= 0x1102 && c <= 0x1103 ||
-               c >= 0x1105 && c <= 0x1107 ||
-               c == 0x1109 ||
-               c >= 0x110B && c <= 0x110C ||
-               c >= 0x110E && c <= 0x1112 ||
-               c == 0x113C ||
-               c == 0x113E ||
-               c == 0x1140 ||
-               c == 0x114C ||
-               c == 0x114E ||
-               c == 0x1150 ||
-               c >= 0x1154 && c <= 0x1155 ||
-               c == 0x1159 ||
-               c >= 0x115F && c <= 0x1161 ||
-               c == 0x1163 ||
-               c == 0x1165 ||
-               c == 0x1167 ||
-               c == 0x1169 ||
-               c >= 0x116D && c <= 0x116E ||
-               c >= 0x1172 && c <= 0x1173 ||
-               c == 0x1175 ||
-               c == 0x119E ||
-               c == 0x11A8 ||
-               c == 0x11AB ||
-               c >= 0x11AE && c <= 0x11AF ||
-               c >= 0x11B7 && c <= 0x11B8 ||
-               c == 0x11BA ||
-               c >= 0x11BC && c <= 0x11C2 ||
-               c == 0x11EB ||
-               c == 0x11F0 ||
-               c == 0x11F9 ||
-               c >= 0x1E00 && c <= 0x1E9B ||
-               c >= 0x1EA0 && c <= 0x1EF9 ||
-               c >= 0x1F00 && c <= 0x1F15 ||
-               c >= 0x1F18 && c <= 0x1F1D ||
-               c >= 0x1F20 && c <= 0x1F45 ||
-               c >= 0x1F48 && c <= 0x1F4D ||
-               c >= 0x1F50 && c <= 0x1F57 ||
-               c == 0x1F59 ||
-               c == 0x1F5B ||
-               c == 0x1F5D ||
-               c >= 0x1F5F && c <= 0x1F7D ||
-               c >= 0x1F80 && c <= 0x1FB4 ||
-               c >= 0x1FB6 && c <= 0x1FBC ||
-               c == 0x1FBE ||
-               c >= 0x1FC2 && c <= 0x1FC4 ||
-               c >= 0x1FC6 && c <= 0x1FCC ||
-               c >= 0x1FD0 && c <= 0x1FD3 ||
-               c >= 0x1FD6 && c <= 0x1FDB ||
-               c >= 0x1FE0 && c <= 0x1FEC ||
-               c >= 0x1FF2 && c <= 0x1FF4 ||
-               c >= 0x1FF6 && c <= 0x1FFC ||
-               c == 0x2126 ||
-               c >= 0x212A && c <= 0x212B ||
-               c == 0x212E ||
-               c >= 0x2180 && c <= 0x2182 ||
-               c >= 0x3041 && c <= 0x3094 ||
-               c >= 0x30A1 && c <= 0x30FA ||
-               c >= 0x3105 && c <= 0x312C ||
-               c >= 0xAC00 && c <= 0xD7A3 ||
-               c >= 0x4E00 && c <= 0x9FA5 ||
-               c == 0x3007 ||
-               c >= 0x3021 && c <= 0x3029;
-};
-
-Utilities.isNCNameChar = function(c) {
-       return c >= 0x0030 && c <= 0x0039 
-               || c >= 0x0660 && c <= 0x0669 
-               || c >= 0x06F0 && c <= 0x06F9 
-               || c >= 0x0966 && c <= 0x096F 
-               || c >= 0x09E6 && c <= 0x09EF 
-               || c >= 0x0A66 && c <= 0x0A6F 
-               || c >= 0x0AE6 && c <= 0x0AEF 
-               || c >= 0x0B66 && c <= 0x0B6F 
-               || c >= 0x0BE7 && c <= 0x0BEF 
-               || c >= 0x0C66 && c <= 0x0C6F 
-               || c >= 0x0CE6 && c <= 0x0CEF 
-               || c >= 0x0D66 && c <= 0x0D6F 
-               || c >= 0x0E50 && c <= 0x0E59 
-               || c >= 0x0ED0 && c <= 0x0ED9 
-               || c >= 0x0F20 && c <= 0x0F29
-               || c == 0x002E
-               || c == 0x002D
-               || c == 0x005F
-               || Utilities.isLetter(c)
-               || c >= 0x0300 && c <= 0x0345 
-               || c >= 0x0360 && c <= 0x0361 
-               || c >= 0x0483 && c <= 0x0486 
-               || c >= 0x0591 && c <= 0x05A1 
-               || c >= 0x05A3 && c <= 0x05B9 
-               || c >= 0x05BB && c <= 0x05BD 
-               || c == 0x05BF 
-               || c >= 0x05C1 && c <= 0x05C2 
-               || c == 0x05C4 
-               || c >= 0x064B && c <= 0x0652 
-               || c == 0x0670 
-               || c >= 0x06D6 && c <= 0x06DC 
-               || c >= 0x06DD && c <= 0x06DF 
-               || c >= 0x06E0 && c <= 0x06E4 
-               || c >= 0x06E7 && c <= 0x06E8 
-               || c >= 0x06EA && c <= 0x06ED 
-               || c >= 0x0901 && c <= 0x0903 
-               || c == 0x093C 
-               || c >= 0x093E && c <= 0x094C 
-               || c == 0x094D 
-               || c >= 0x0951 && c <= 0x0954 
-               || c >= 0x0962 && c <= 0x0963 
-               || c >= 0x0981 && c <= 0x0983 
-               || c == 0x09BC 
-               || c == 0x09BE 
-               || c == 0x09BF 
-               || c >= 0x09C0 && c <= 0x09C4 
-               || c >= 0x09C7 && c <= 0x09C8 
-               || c >= 0x09CB && c <= 0x09CD 
-               || c == 0x09D7 
-               || c >= 0x09E2 && c <= 0x09E3 
-               || c == 0x0A02 
-               || c == 0x0A3C 
-               || c == 0x0A3E 
-               || c == 0x0A3F 
-               || c >= 0x0A40 && c <= 0x0A42 
-               || c >= 0x0A47 && c <= 0x0A48 
-               || c >= 0x0A4B && c <= 0x0A4D 
-               || c >= 0x0A70 && c <= 0x0A71 
-               || c >= 0x0A81 && c <= 0x0A83 
-               || c == 0x0ABC 
-               || c >= 0x0ABE && c <= 0x0AC5 
-               || c >= 0x0AC7 && c <= 0x0AC9 
-               || c >= 0x0ACB && c <= 0x0ACD 
-               || c >= 0x0B01 && c <= 0x0B03 
-               || c == 0x0B3C 
-               || c >= 0x0B3E && c <= 0x0B43 
-               || c >= 0x0B47 && c <= 0x0B48 
-               || c >= 0x0B4B && c <= 0x0B4D 
-               || c >= 0x0B56 && c <= 0x0B57 
-               || c >= 0x0B82 && c <= 0x0B83 
-               || c >= 0x0BBE && c <= 0x0BC2 
-               || c >= 0x0BC6 && c <= 0x0BC8 
-               || c >= 0x0BCA && c <= 0x0BCD 
-               || c == 0x0BD7 
-               || c >= 0x0C01 && c <= 0x0C03 
-               || c >= 0x0C3E && c <= 0x0C44 
-               || c >= 0x0C46 && c <= 0x0C48 
-               || c >= 0x0C4A && c <= 0x0C4D 
-               || c >= 0x0C55 && c <= 0x0C56 
-               || c >= 0x0C82 && c <= 0x0C83 
-               || c >= 0x0CBE && c <= 0x0CC4 
-               || c >= 0x0CC6 && c <= 0x0CC8 
-               || c >= 0x0CCA && c <= 0x0CCD 
-               || c >= 0x0CD5 && c <= 0x0CD6 
-               || c >= 0x0D02 && c <= 0x0D03 
-               || c >= 0x0D3E && c <= 0x0D43 
-               || c >= 0x0D46 && c <= 0x0D48 
-               || c >= 0x0D4A && c <= 0x0D4D 
-               || c == 0x0D57 
-               || c == 0x0E31 
-               || c >= 0x0E34 && c <= 0x0E3A 
-               || c >= 0x0E47 && c <= 0x0E4E 
-               || c == 0x0EB1 
-               || c >= 0x0EB4 && c <= 0x0EB9 
-               || c >= 0x0EBB && c <= 0x0EBC 
-               || c >= 0x0EC8 && c <= 0x0ECD 
-               || c >= 0x0F18 && c <= 0x0F19 
-               || c == 0x0F35 
-               || c == 0x0F37 
-               || c == 0x0F39 
-               || c == 0x0F3E 
-               || c == 0x0F3F 
-               || c >= 0x0F71 && c <= 0x0F84 
-               || c >= 0x0F86 && c <= 0x0F8B 
-               || c >= 0x0F90 && c <= 0x0F95 
-               || c == 0x0F97 
-               || c >= 0x0F99 && c <= 0x0FAD 
-               || c >= 0x0FB1 && c <= 0x0FB7 
-               || c == 0x0FB9 
-               || c >= 0x20D0 && c <= 0x20DC 
-               || c == 0x20E1 
-               || c >= 0x302A && c <= 0x302F 
-               || c == 0x3099 
-               || c == 0x309A
-               || c == 0x00B7 
-               || c == 0x02D0 
-               || c == 0x02D1 
-               || c == 0x0387 
-               || c == 0x0640 
-               || c == 0x0E46 
-               || c == 0x0EC6 
-               || c == 0x3005 
-               || c >= 0x3031 && c <= 0x3035 
-               || c >= 0x309D && c <= 0x309E 
-               || c >= 0x30FC && c <= 0x30FE;
-};
-
-Utilities.coalesceText = function(n) {
-       for (var m = n.firstChild; m != null; m = m.nextSibling) {
-               if (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
-                       var s = m.nodeValue;
-                       var first = m;
-                       m = m.nextSibling;
-                       while (m != null && (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/)) {
-                               s += m.nodeValue;
-                               var del = m;
-                               m = m.nextSibling;
-                               del.parentNode.removeChild(del);
-                       }
-                       if (first.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
-                               var p = first.parentNode;
-                               if (first.nextSibling == null) {
-                                       p.removeChild(first);
-                                       p.appendChild(p.ownerDocument.createTextNode(s));
-                               } else {
-                                       var next = first.nextSibling;
-                                       p.removeChild(first);
-                                       p.insertBefore(p.ownerDocument.createTextNode(s), next);
-                               }
-                       } else {
-                               first.nodeValue = s;
-                       }
-                       if (m == null) {
-                               break;
-                       }
-               } else if (m.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-                       Utilities.coalesceText(m);
-               }
-       }
-};
-
-Utilities.instance_of = function(o, c) {
-       while (o != null) {
-               if (o.constructor === c) {
-                       return true;
-               }
-               if (o === Object) {
-                       return false;
-               }
-               o = o.constructor.superclass;
-       }
-       return false;
-};
-
-Utilities.getElementById = function(n, id) {
-       // Note that this does not check the DTD to check for actual
-       // attributes of type ID, so this may be a bit wrong.
-       if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
-               if (n.getAttribute("id") == id
-                               || n.getAttributeNS(null, "id") == id) {
-                       return n;
-               }
-       }
-       for (var m = n.firstChild; m != null; m = m.nextSibling) {
-               var res = Utilities.getElementById(m, id);
-               if (res != null) {
-                       return res;
-               }
-       }
-       return null;
-};
-
-// XPathException ////////////////////////////////////////////////////////////
-
-XPathException.prototype = {};
-XPathException.prototype.constructor = XPathException;
-XPathException.superclass = Object.prototype;
-
-function XPathException(c, e) {
-       this.code = c;
-       this.exception = e;
-}
-
-XPathException.prototype.toString = function() {
-       var msg = this.exception ? ": " + this.exception.toString() : "";
-       switch (this.code) {
-               case XPathException.INVALID_EXPRESSION_ERR:
-                       return "Invalid expression" + msg;
-               case XPathException.TYPE_ERR:
-                       return "Type error" + msg;
-       }
-};
-
-XPathException.INVALID_EXPRESSION_ERR = 51;
-XPathException.TYPE_ERR = 52;
-
-// XPathExpression ///////////////////////////////////////////////////////////
-
-XPathExpression.prototype = {};
-XPathExpression.prototype.constructor = XPathExpression;
-XPathExpression.superclass = Object.prototype;
-
-function XPathExpression(e, r, p) {
-       this.xpath = p.parse(e);
-       this.context = new XPathContext();
-       this.context.namespaceResolver = new XPathNSResolverWrapper(r);
-}
-
-XPathExpression.prototype.evaluate = function(n, t, res) {
-       this.context.expressionContextNode = n;
-       var result = this.xpath.evaluate(this.context);
-       return new XPathResult(result, t);
-}
-
-// XPathNSResolverWrapper ////////////////////////////////////////////////////
-
-XPathNSResolverWrapper.prototype = {};
-XPathNSResolverWrapper.prototype.constructor = XPathNSResolverWrapper;
-XPathNSResolverWrapper.superclass = Object.prototype;
-
-function XPathNSResolverWrapper(r) {
-       this.xpathNSResolver = r;
-}
-
-XPathNSResolverWrapper.prototype.getNamespace = function(prefix, n) {
-    if (this.xpathNSResolver == null) {
-        return null;
-    }
-       return this.xpathNSResolver.lookupNamespaceURI(prefix);
-};
-
-// NodeXPathNSResolver ///////////////////////////////////////////////////////
-
-NodeXPathNSResolver.prototype = {};
-NodeXPathNSResolver.prototype.constructor = NodeXPathNSResolver;
-NodeXPathNSResolver.superclass = Object.prototype;
-
-function NodeXPathNSResolver(n) {
-       this.node = n;
-       this.namespaceResolver = new NamespaceResolver();
-}
-
-NodeXPathNSResolver.prototype.lookupNamespaceURI = function(prefix) {
-       return this.namespaceResolver.getNamespace(prefix, this.node);
-};
-
-// XPathResult ///////////////////////////////////////////////////////////////
-
-XPathResult.prototype = {};
-XPathResult.prototype.constructor = XPathResult;
-XPathResult.superclass = Object.prototype;
-
-function XPathResult(v, t) {
-       if (t == XPathResult.ANY_TYPE) {
-               if (v.constructor === XString) {
-                       t = XPathResult.STRING_TYPE;
-               } else if (v.constructor === XNumber) {
-                       t = XPathResult.NUMBER_TYPE;
-               } else if (v.constructor === XBoolean) {
-                       t = XPathResult.BOOLEAN_TYPE;
-               } else if (v.constructor === XNodeSet) {
-                       t = XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
-               }
-       }
-       this.resultType = t;
-       switch (t) {
-               case XPathResult.NUMBER_TYPE:
-                       this.numberValue = v.numberValue();
-                       return;
-               case XPathResult.STRING_TYPE:
-                       this.stringValue = v.stringValue();
-                       return;
-               case XPathResult.BOOLEAN_TYPE:
-                       this.booleanValue = v.booleanValue();
-                       return;
-               case XPathResult.ANY_UNORDERED_NODE_TYPE:
-               case XPathResult.FIRST_UNORDERED_NODE_TYPE:
-                       if (v.constructor === XNodeSet) {
-                               this.singleNodeValue = v.first();
-                               return;
-                       }
-                       break;
-               case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
-               case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
-                       if (v.constructor === XNodeSet) {
-                               this.invalidIteratorState = false;
-                               this.nodes = v.toArray();
-                               this.iteratorIndex = 0;
-                               return;
-                       }
-                       break;
-               case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
-               case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
-                       if (v.constructor === XNodeSet) {
-                               this.nodes = v.toArray();
-                               this.snapshotLength = this.nodes.length;
-                               return;
-                       }
-                       break;
-       }
-       throw new XPathException(XPathException.TYPE_ERR);
-};
-
-XPathResult.prototype.iterateNext = function() {
-       if (this.resultType != XPathResult.UNORDERED_NODE_ITERATOR_TYPE
-                       && this.resultType != XPathResult.ORDERED_NODE_ITERATOR_TYPE) {
-               throw new XPathException(XPathException.TYPE_ERR);
-       }
-       return this.nodes[this.iteratorIndex++];
-};
-
-XPathResult.prototype.snapshotItem = function(i) {
-       if (this.resultType != XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE
-                       && this.resultType != XPathResult.ORDERED_NODE_SNAPSHOT_TYPE) {
-               throw new XPathException(XPathException.TYPE_ERR);
-       }
-       return this.nodes[i];
-};
-
-XPathResult.ANY_TYPE = 0;
-XPathResult.NUMBER_TYPE = 1;
-XPathResult.STRING_TYPE = 2;
-XPathResult.BOOLEAN_TYPE = 3;
-XPathResult.UNORDERED_NODE_ITERATOR_TYPE = 4;
-XPathResult.ORDERED_NODE_ITERATOR_TYPE = 5;
-XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE = 6;
-XPathResult.ORDERED_NODE_SNAPSHOT_TYPE = 7;
-XPathResult.ANY_UNORDERED_NODE_TYPE = 8;
-XPathResult.FIRST_ORDERED_NODE_TYPE = 9;
-
-// DOM 3 XPath support ///////////////////////////////////////////////////////
-
-function installDOM3XPathSupport(doc, p) {
-       doc.createExpression = function(e, r) {
-               try {
-                       return new XPathExpression(e, r, p);
-               } catch (e) {
-                       throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, e);
-               }
-       };
-       doc.createNSResolver = function(n) {
-               return new NodeXPathNSResolver(n);
-       };
-       doc.evaluate = function(e, cn, r, t, res) {
-               if (!cn) cn = doc;
-               if (t < 0 || t > 9) {
-                       throw { code: 0, toString: function() { return "Request type not supported"; } };
-               }
-               return doc.createExpression(e, r, p).evaluate(cn, t, res);
-       };
-};
-
-// ---------------------------------------------------------------------------
-
-// Install DOM 3 XPath support for the current document.
-try {
-       var shouldInstall = true;
-       try {
-               if (document.implementation
-                               && document.implementation.hasFeature
-                               && document.implementation.hasFeature("XPath", null)) {
-                       shouldInstall = false;
-               }
-       } catch (e) {
-       }
-       if (shouldInstall) {
-               installDOM3XPathSupport(document, new XPathParser());
-       }
-} catch (e) {
-}
diff --git a/Open-ILS/src/javascript/backend/penalty/patron_penalty.js b/Open-ILS/src/javascript/backend/penalty/patron_penalty.js
deleted file mode 100644 (file)
index 07ed2ee..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-function go() {
-
-/* load the lib script */
-load_lib('circ/circ_lib.js');
-load_lib('JSON_v1.js');
-log_vars('patron_penalty');
-
-var config = findGroupConfig(patronProfile);
-
-if( config ) {
-
-       /* check the fine limit */
-       if( config.fineThreshold >= 0 && patronFines >= config.fineThreshold ) 
-               result.fatalEvents.push('PATRON_EXCEEDS_FINES');
-
-       /* check the overdue limit */
-       if( config.overdueThreshold >= 0 && patronOverdueCount >= config.overdueThreshold )
-               result.fatalEvents.push('PATRON_EXCEEDS_OVERDUE_COUNT');
-
-} else {
-       log_warn("profile has no configured information: " + patronProfile);
-}
-
-
-
-
-
-
-} go();
-
-
diff --git a/Open-ILS/src/javascript/backend/test/xmlhttprequest-test.js b/Open-ILS/src/javascript/backend/test/xmlhttprequest-test.js
deleted file mode 100644 (file)
index 6743942..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// suck in what we need
-log_stdout('------------------------------LOAD---------------------------------------');
-load_lib('xmlhttprequest.js');
-
-log_stdout('------------------------------START---------------------------------------');
-
-log_stdout("recordID is",params.recordID);
-
-// xpath namespace resolver
-var ns_res = new XPathNamespaceResolver(
-       { marc : "http://www.loc.gov/MARC21/slim",
-         mods : "http://www.loc.gov/mods/v3" }
-);
-
-// xmlhttprequest uses the perl xml parser to get the xml doc from 
-var x = new XMLHttpRequest();
-x.open('POST','http://dev.gapines.org/restgateway');
-x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-x.send('service=open-ils.storage&method=open-ils.storage.direct.biblio.record_entry.retrieve&param=' + params.recordID);
-
-
-// use the DOM to parse the marc record
-var marc = DOMImplementation.parseString(x.responseXML.evaluate('//marc/text()').singleNodeValue.data);
-
-
-
-// and then get the title
-var res = marc.evaluate(
-       "/marc:record/marc:datafield[@tag='245']/marc:subfield[@code='a']/text()",
-       marc,
-       ns_res
-);
-
-// print the title we just grabbed
-log_stdout(res.singleNodeValue.data);
-
-log_stdout('------------------------------END---------------------------------------');
-
index e09a8b0..5c32308 100644 (file)
@@ -42,7 +42,6 @@ my $build = Module::Build->new(
         'File::Temp' => '0',
         'Getopt::Long' => '0',
         'IO::Scalar' => '0',
-        'JavaScript::SpiderMonkey' => '0',
         'List::Util' => '0',
         'Locale::Country' => '0',
         'LWP::UserAgent' => '0',
index ba2ac1e..f00deef 100644 (file)
@@ -35,7 +35,6 @@ lib/OpenILS/Application/Circ/HoldNotify.pm
 lib/OpenILS/Application/Circ/Holds.pm
 lib/OpenILS/Application/Circ/Money.pm
 lib/OpenILS/Application/Circ/NonCat.pm
-lib/OpenILS/Application/Circ/ScriptBuilder.pm
 lib/OpenILS/Application/Circ/StatCat.pm
 lib/OpenILS/Application/Circ/Survey.pm
 lib/OpenILS/Application/Circ/Transit.pm
@@ -150,8 +149,6 @@ lib/OpenILS/Utils/OfflineStore.pm
 lib/OpenILS/Utils/Penalty.pm
 lib/OpenILS/Utils/PermitHold.pm
 lib/OpenILS/Utils/RemoteAccount.pm
-lib/OpenILS/Utils/ScriptRunner.pm
-lib/OpenILS/Utils/SpiderMonkey.pm
 lib/OpenILS/Utils/ZClient.pm
 lib/OpenILS/WWW/AddedContent.pm
 lib/OpenILS/WWW/AddedContent/Amazon.pm
index b3281c9..b74c8c3 100644 (file)
@@ -11,8 +11,6 @@ use DateTime;
 my $U = "OpenILS::Application::AppUtils";
 
 my %scripts;
-my $script_libs;
-my $legacy_script_support = 0;
 my $booking_status;
 my $opac_renewal_use_circ_lib;
 my $desk_renewal_use_circ_lib;
@@ -36,51 +34,7 @@ my $MK_ENV_FLESH = {
     flesh_fields => {acp => ['call_number','parts','floating'], acn => ['record']}
 };
 
-sub initialize {
-
-    my $self = shift;
-    my $conf = OpenSRF::Utils::SettingsClient->new;
-    my @pfx2 = ( "apps", "open-ils.circ","app_settings" );
-
-    $legacy_script_support = $conf->config_value(@pfx2, 'legacy_script_support');
-    $legacy_script_support = ($legacy_script_support and $legacy_script_support =~ /true/i);
-
-    my $lb  = $conf->config_value(  @pfx2, 'script_path' );
-    $lb = [ $lb ] unless ref($lb);
-    $script_libs = $lb;
-
-    return unless $legacy_script_support;
-
-    my @pfx = ( @pfx2, "scripts" );
-    my $p   = $conf->config_value(  @pfx, 'circ_permit_patron' );
-    my $c   = $conf->config_value(  @pfx, 'circ_permit_copy' );
-    my $d   = $conf->config_value(  @pfx, 'circ_duration' );
-    my $f   = $conf->config_value(  @pfx, 'circ_recurring_fines' );
-    my $m   = $conf->config_value(  @pfx, 'circ_max_fines' );
-    my $pr  = $conf->config_value(  @pfx, 'circ_permit_renew' );
-
-    $logger->error( "Missing circ script(s)" ) 
-        unless( $p and $c and $d and $f and $m and $pr );
-
-    $scripts{circ_permit_patron}   = $p;
-    $scripts{circ_permit_copy}     = $c;
-    $scripts{circ_duration}        = $d;
-    $scripts{circ_recurring_fines} = $f;
-    $scripts{circ_max_fines}       = $m;
-    $scripts{circ_permit_renew}    = $pr;
-
-    $logger->debug(
-        "circulator: Loaded rules scripts for circ: " .
-        "circ permit patron = $p, ".
-        "circ permit copy = $c, ".
-        "circ duration = $d, ".
-        "circ recurring fines = $f, " .
-        "circ max fines = $m, ".
-        "circ renew permit = $pr.  ".
-        "lib paths = @$lb. ".
-        "legacy script support = ". ($legacy_script_support) ? 'yes' : 'no'
-        );
-}
+sub initialize {}
 
 __PACKAGE__->register_method(
     method  => "run_method",
@@ -278,16 +232,7 @@ sub run_method {
     $circulator->mk_env();
     $circulator->noop(1) if $circulator->claims_never_checked_out;
 
-    if($legacy_script_support and not $circulator->is_checkin) {
-        $circulator->mk_script_runner();
-        $circulator->legacy_script_support(1);
-        $circulator->circ_permit_patron($scripts{circ_permit_patron});
-        $circulator->circ_permit_copy($scripts{circ_permit_copy});      
-        $circulator->circ_duration($scripts{circ_duration});             
-        $circulator->circ_permit_renew($scripts{circ_permit_renew});
-    }
     return circ_events($circulator) if $circulator->bail_out;
-
     
     $circulator->override(1) if $api =~ /override/o;
 
@@ -428,7 +373,6 @@ use OpenILS::Application::Circ::Holds;
 use OpenILS::Application::Circ::Transit;
 use OpenSRF::Utils::Logger qw(:logger);
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
-use OpenILS::Application::Circ::ScriptBuilder;
 use OpenILS::Const qw/:const/;
 use OpenILS::Utils::Penalty;
 use OpenILS::Application::Circ::CircCommon;
@@ -514,7 +458,6 @@ my @AUTOLOAD_FIELDS = qw/
     matrix_test_result
     circ_matrix_matchpoint
     circ_test_success
-    legacy_script_support
     is_deposit
     is_rental
     deposit_billing
@@ -815,85 +758,6 @@ sub mk_env {
     }
 }
 
-# --------------------------------------------------------------------------
-# This builds the script runner environment and fetches most of the
-# objects we need
-# --------------------------------------------------------------------------
-sub mk_script_runner {
-    my $self = shift;
-    my $args = {};
-
-
-    my @fields = 
-        qw/copy copy_barcode copy_id patron 
-            patron_id patron_barcode volume title editor/;
-
-    # Translate our objects into the ScriptBuilder args hash
-    $$args{$_} = $self->$_() for @fields;
-
-    $args->{ignore_user_status} = 1 if $self->is_checkin;
-    $$args{fetch_patron_by_circ_copy} = 1;
-    $$args{fetch_patron_circ_info} = 1 unless $self->is_checkin;
-
-    if( my $pco = $self->pending_checkouts ) {
-        $logger->info("circulator: we were given a pending checkouts number of $pco");
-        $$args{patronItemsOut} = $pco;
-    }
-
-    # This fetches most of the objects we need
-    $self->script_runner(
-        OpenILS::Application::Circ::ScriptBuilder->build($args));
-
-    # Now we translate the ScriptBuilder objects back into self
-    $self->$_($$args{$_}) for @fields;
-
-    my @evts = @{$args->{_events}} if $args->{_events};
-
-    $logger->debug("circulator: script builder returned events: @evts") if @evts;
-
-
-    if(@evts) {
-        # Anything besides ASSET_COPY_NOT_FOUND will stop processing
-        if(!$self->is_noncat and 
-            @evts == 1 and 
-            $evts[0]->{textcode} eq 'ASSET_COPY_NOT_FOUND') {
-                $self->is_precat(1);
-
-        } else {
-            my @e = grep { $_->{textcode} ne 'ASSET_COPY_NOT_FOUND' } @evts;
-            return $self->bail_on_events(@e);
-        }
-    }
-
-    if($self->copy) {
-        $self->is_precat(1) if $self->copy->call_number == OILS_PRECAT_CALL_NUMBER;
-        if($self->copy->deposit_amount and $self->copy->deposit_amount > 0) {
-            $self->is_deposit(1) if $U->is_true($self->copy->deposit);
-            $self->is_rental(1) unless $U->is_true($self->copy->deposit);
-        }
-    }
-
-    # We can't renew if there is no copy
-    return $self->bail_on_events(@evts) if 
-        $self->is_renewal and !$self->copy;
-
-    # Set some circ-specific flags in the script environment
-    my $evt = "environment";
-    $self->script_runner->insert("$evt.isRenewal", ($self->is_renewal) ? 1 : undef);
-
-    if( $self->is_noncat ) {
-      $self->script_runner->insert("$evt.isNonCat", 1);
-      $self->script_runner->insert("$evt.nonCatType", $self->noncat_type);
-    }
-
-    if( $self->is_precat ) {
-        $self->script_runner->insert("environment.isPrecat", 1, 1);
-    }
-
-    $self->script_runner->add_path( $_ ) for @$script_libs;
-
-    return 1;
-}
 
 # --------------------------------------------------------------------------
 # Does the circ permit work
@@ -1096,69 +960,41 @@ sub run_patron_permit_scripts {
 
     my @allevents; 
 
-    if(!$self->legacy_script_support) {
-
-        my $results = $self->run_indb_circ_test;
-        unless($self->circ_test_success) {
-            my @trimmed_results;
 
-            if ($self->is_noncat) {
-                # no_item result is OK during noncat checkout
-                @trimmed_results = grep { ($_->{fail_part} || '') ne 'no_item' } @$results;
+    my $results = $self->run_indb_circ_test;
+    unless($self->circ_test_success) {
+        my @trimmed_results;
 
-            } else {
+        if ($self->is_noncat) {
+            # no_item result is OK during noncat checkout
+            @trimmed_results = grep { ($_->{fail_part} || '') ne 'no_item' } @$results;
 
-                if ($self->checkout_is_for_hold) {
-                    # if this checkout will fulfill a hold, ignore CIRC blocks
-                    # and rely instead on the (later-checked) FULFILL block
+        } else {
 
-                    my @pen_names = grep {$_} map {$_->{fail_part}} @$results;
-                    my $fblock_pens = $self->editor->search_config_standing_penalty(
-                        {name => [@pen_names], block_list => {like => '%CIRC%'}});
+            if ($self->checkout_is_for_hold) {
+                # if this checkout will fulfill a hold, ignore CIRC blocks
+                # and rely instead on the (later-checked) FULFILL block
 
-                    for my $res (@$results) {
-                        my $name = $res->{fail_part} || '';
-                        next if grep {$_->name eq $name} @$fblock_pens;
-                        push(@trimmed_results, $res);
-                    }
+                my @pen_names = grep {$_} map {$_->{fail_part}} @$results;
+                my $fblock_pens = $self->editor->search_config_standing_penalty(
+                    {name => [@pen_names], block_list => {like => '%CIRC%'}});
 
-                } else { 
-                    # not for hold or noncat
-                    @trimmed_results = @$results;
+                for my $res (@$results) {
+                    my $name = $res->{fail_part} || '';
+                    next if grep {$_->name eq $name} @$fblock_pens;
+                    push(@trimmed_results, $res);
                 }
-            }
-
-            # update the final set of test results
-            $self->matrix_test_result(\@trimmed_results); 
 
-            push @allevents, $self->matrix_test_result_events;
+            } else { 
+                # not for hold or noncat
+                @trimmed_results = @$results;
+            }
         }
 
-    } else {
+        # update the final set of test results
+        $self->matrix_test_result(\@trimmed_results); 
 
-        # --------------------------------------------------------------------- 
-        # # Now run the patron permit script 
-        # ---------------------------------------------------------------------
-        $runner->load($self->circ_permit_patron);
-        my $result = $runner->run or 
-            throw OpenSRF::EX::ERROR ("Circ Permit Patron Script Died: $@");
-
-        my $patron_events = $result->{events};
-
-        OpenILS::Utils::Penalty->calculate_penalties($self->editor, $self->patron->id, $self->circ_lib);
-        my $mask = ($self->is_renewal) ? 'RENEW' : 'CIRC';
-        my $penalties = OpenILS::Utils::Penalty->retrieve_penalties($self->editor, $patronid, $self->circ_lib, $mask);
-        $penalties = $penalties->{fatal_penalties};
-
-        for my $pen (@$penalties) {
-            # CIRC blocks are ignored if this is a FULFILL scenario
-            next if $mask eq 'CIRC' and $self->checkout_is_for_hold;
-            my $event = OpenILS::Event->new($pen->name);
-            $event->{desc} = $pen->label;
-            push(@allevents, $event);
-        }
-
-        push(@allevents, OpenILS::Event->new($_)) for (@$patron_events);
+        push @allevents, $self->matrix_test_result_events;
     }
 
     for (@allevents) {
@@ -1345,33 +1181,17 @@ sub run_copy_permit_scripts {
 
     my @allevents;
 
-    if(!$self->legacy_script_support) {
-        my $results = $self->run_indb_circ_test;
-        push @allevents, $self->matrix_test_result_events
-            unless $self->circ_test_success;
-    } else {
-    
-       # ---------------------------------------------------------------------
-       # Capture all of the copy permit events
-       # ---------------------------------------------------------------------
-       $runner->load($self->circ_permit_copy);
-       my $result = $runner->run or 
-            throw OpenSRF::EX::ERROR ("Circ Permit Copy Script Died: $@");
-       my $copy_events = $result->{events};
-
-       # ---------------------------------------------------------------------
-       # Now collect all of the events together
-       # ---------------------------------------------------------------------
-       push( @allevents, OpenILS::Event->new($_)) for @$copy_events;
-    }
+    my $results = $self->run_indb_circ_test;
+    push @allevents, $self->matrix_test_result_events
+        unless $self->circ_test_success;
 
     # See if this copy has an alert message
     my $ae = $self->check_copy_alert();
     push( @allevents, $ae ) if $ae;
 
-   # uniquify the events
-   my %hash = map { ($_->{ilsevent} => $_) } @allevents;
-   @allevents = values %hash;
+    # uniquify the events
+    my %hash = map { ($_->{ilsevent} => $_) } @allevents;
+    @allevents = values %hash;
 
     $logger->info("circulator: permit_copy script returned events: @allevents") if @allevents;
 
@@ -1911,25 +1731,11 @@ sub run_checkout_scripts {
     my $max_fine_name;
     my $hard_due_date_name;
 
-    if(!$self->legacy_script_support) {
-        $self->run_indb_circ_test();
-        $duration = $self->circ_matrix_matchpoint->duration_rule;
-        $recurring = $self->circ_matrix_matchpoint->recurring_fine_rule;
-        $max_fine = $self->circ_matrix_matchpoint->max_fine_rule;
-        $hard_due_date = $self->circ_matrix_matchpoint->hard_due_date;
-
-    } else {
-
-       $runner->load($self->circ_duration);
-
-       my $result = $runner->run or 
-            throw OpenSRF::EX::ERROR ("Circ Duration Script Died: $@");
-
-       $duration_name   = $result->{durationRule};
-       $recurring_name  = $result->{recurringFinesRule};
-       $max_fine_name   = $result->{maxFine};
-       $hard_due_date_name  = $result->{hardDueDate};
-    }
+    $self->run_indb_circ_test();
+    $duration = $self->circ_matrix_matchpoint->duration_rule;
+    $recurring = $self->circ_matrix_matchpoint->recurring_fine_rule;
+    $max_fine = $self->circ_matrix_matchpoint->max_fine_rule;
+    $hard_due_date = $self->circ_matrix_matchpoint->hard_due_date;
 
     $duration_name = $duration->name if $duration;
     if( $duration_name ne OILS_UNLIMITED_CIRC_DURATION ) {
@@ -3896,7 +3702,6 @@ sub have_event {
 }
 
 
-
 sub run_renew_permit {
     my $self = shift;
 
@@ -3907,32 +3712,9 @@ sub run_renew_permit {
         $self->push_events(new OpenILS::Event("COPY_NEEDED_FOR_HOLD")) if $hold;
     }
 
-    if(!$self->legacy_script_support) {
-        my $results = $self->run_indb_circ_test;
-        $self->push_events($self->matrix_test_result_events)
-            unless $self->circ_test_success;
-    } else {
-
-        my $runner = $self->script_runner;
-
-        $runner->load($self->circ_permit_renew);
-        my $result = $runner->run or 
-            throw OpenSRF::EX::ERROR ("Circ Permit Renew Script Died: $@");
-        if ($result->{"events"}) {
-            $self->push_events(
-                map { new OpenILS::Event($_) } @{$result->{"events"}}
-            );
-            $logger->activity(
-                "circulator: circ_permit_renew for user " .
-                $self->patron->id . " returned " .
-                scalar(@{$result->{"events"}}) . " event(s)"
-            );
-        }
-
-        $self->mk_script_runner;
-    }
-
-    $logger->debug("circulator: re-creating script runner to be safe");
+    my $results = $self->run_indb_circ_test;
+    $self->push_events($self->matrix_test_result_events)
+        unless $self->circ_test_success;
 }
 
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/ScriptBuilder.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/ScriptBuilder.pm
deleted file mode 100644 (file)
index 1eebc7d..0000000
+++ /dev/null
@@ -1,426 +0,0 @@
-package OpenILS::Application::Circ::ScriptBuilder;
-use strict; use warnings;
-use OpenILS::Utils::ScriptRunner;
-use OpenILS::Utils::CStoreEditor qw/:funcs/;
-use OpenILS::Application::AppUtils;
-use OpenSRF::Utils::Logger qw/$logger/;
-use OpenILS::Application::Circ::Holds;
-use DateTime::Format::ISO8601;
-use OpenSRF::Utils qw/:datetime/;
-use Scalar::Util qw/weaken/;
-my $U = "OpenILS::Application::AppUtils";
-use Data::Dumper;
-
-my $holdcode = "OpenILS::Application::Circ::Holds";
-
-my $evt = "environment";
-my %GROUP_SET;
-my $GROUP_TREE;
-my $ORG_TREE;
-my @ORG_LIST;
-my @OU_TYPES;
-
-
-# -----------------------------------------------------------------------
-# Possible Args:
-#  copy
-#  copy_id
-#  copy_barcode
-#
-#  patron
-#  patron_id
-#  patron_barcode
-#
-#  fetch_patron_circ_info - load info on items out, overdues, and fines.
-#
-#  _direct - this is a hash of key/value pairs to shove directly into the 
-#  script runner.  Use this to cover data not covered by this module
-# -----------------------------------------------------------------------
-sub build {
-    my( $class, $args ) = @_;
-
-    my $evt;
-    my @evts;
-
-    my $rollback;
-    my $editor = $$args{editor};
-
-    unless($editor) {
-        $editor = new_editor(xact => 1);
-        $rollback = 1;
-    }
-
-    $args->{_direct} = {} unless $args->{_direct};
-    #$args->{editor} = $editor;
-    
-    $evt = fetch_bib_data($editor, $args);
-    push(@evts, $evt) if $evt;
-    $evt = fetch_user_data($editor, $args);
-    push(@evts, $evt) if $evt;
-
-    if(@evts) {
-        my @e;
-        push( @e, $_->{textcode} ) for @evts;
-        $logger->info("script_builder: some events occurred: @e");
-        $logger->debug("script_builder: some events occurred: " . Dumper(\@evts));
-        $args->{_events} = \@evts;
-    }
-
-    my $r = build_runner($editor, $args);
-    $editor->rollback if $rollback;
-    return $r;
-}
-
-
-sub build_runner {
-    my $editor  = shift;
-    my $ctx     = shift;
-
-    my $runner = OpenILS::Utils::ScriptRunner->new;
-
-    my $gt = $GROUP_TREE;
-    $runner->insert( "$evt.groupTree",  $gt, 1);
-
-
-    $runner->insert( "$evt.patron",     $ctx->{patron}, 1);
-    $runner->insert( "$evt.copy",           $ctx->{copy}, 1);
-    $runner->insert( "$evt.volume",     $ctx->{volume}, 1);
-    $runner->insert( "$evt.title",      $ctx->{title}, 1);
-
-    if( ref $ctx->{requestor} ) {
-        $runner->insert( "$evt.requestor",  $ctx->{requestor}, 1);
-        if($ctx->{requestor}->ws_ou) {
-            $runner->insert( "$evt.location",   
-                $editor->retrieve_actor_org_unit($ctx->{requestor}->ws_ou), 1);
-        }
-    }
-
-    $runner->insert( "$evt.patronItemsOut", $ctx->{patronItemsOut}, 1 );
-    $runner->insert( "$evt.patronOverdueCount", $ctx->{patronOverdue}, 1 );
-    $runner->insert( "$evt.patronFines", $ctx->{patronFines}, 1 );
-
-    $runner->insert("$evt.$_", $ctx->{_direct}->{$_}, 1) for keys %{$ctx->{_direct}};
-
-    insert_org_methods( $editor, $runner );
-    insert_copy_methods( $editor, $ctx, $runner );
-   insert_user_funcs( $editor, $ctx, $runner );
-
-    return $runner;
-}
-
-sub fetch_bib_data {
-    my $e = shift;
-    my $ctx = shift;
-
-    my $flesh = { 
-        flesh => 2, 
-        flesh_fields => { 
-            acp => [ 'location', 'status', 'circ_lib', 'age_protect', 'call_number' ],
-            acn => [ 'record' ]
-        } 
-    };
-
-    if( $ctx->{copy} ) {
-        $ctx->{copy_id} = $ctx->{copy}->id 
-            unless $ctx->{copy_id} or $ctx->{copy_barcode};
-    }
-
-    my $copy;
-
-    if($ctx->{copy_id}) {
-        $copy = $e->retrieve_asset_copy(
-            [$ctx->{copy_id}, $flesh ]) or return $e->event;
-
-    } elsif( $ctx->{copy_barcode} ) {
-
-        $copy = $e->search_asset_copy(
-            [{barcode => $ctx->{copy_barcode}, deleted => 'f'}, $flesh ])->[0]
-            or return $e->event;
-    }
-
-    return undef unless $copy;
-
-    my $vol = $copy->call_number;
-    my $rec = $vol->record;
-    $ctx->{copy} = $copy;
-    $ctx->{volume} = $vol;
-    $copy->call_number($vol->id);
-    $ctx->{title} = $rec;
-    $vol->record($rec->id);
-
-    return undef;
-}
-
-
-
-sub fetch_user_data {
-    my( $e, $ctx ) = @_;
-
-    my $flesh = {
-        flesh => 2,
-        flesh_fields => {
-            au => [ qw/ profile home_ou card / ],
-            aou => [ 'ou_type' ],
-        }
-    };
-
-    if( $ctx->{patron} ) {
-        $ctx->{patron_id} = $ctx->{patron}->id unless $ctx->{patron_id};
-    }
-
-    my $patron;
-    
-    if( $ctx->{patron_id} ) {
-        $patron = $e->retrieve_actor_user([$ctx->{patron_id}, $flesh]);
-
-    } elsif( $ctx->{patron_barcode} ) {
-
-        my $card = $e->search_actor_card( 
-            { barcode => $ctx->{patron_barcode} } )->[0] or return $e->event;
-
-        $patron = $e->search_actor_user( 
-            [{ card => $card->id }, $flesh ]
-            )->[0] or return $e->event;
-
-    } elsif( $ctx->{fetch_patron_by_circ_copy} ) {
-
-        if( my $copy = $ctx->{copy} ) {
-            my $circs = $e->search_action_circulation(
-                { target_copy => $copy->id, checkin_time => undef });
-
-            if( my $circ = $circs->[0] ) {
-                $patron = $e->retrieve_actor_user([$circ->usr, $flesh])
-                    or return $e->event;
-            }
-        }
-    }
-
-    return undef unless $ctx->{patron} = $patron;
-
-    flatten_groups($e);
-
-    $ctx->{requestor} = $ctx->{requestor} || $e->requestor;
-
-    if( $ctx->{fetch_patron_circ_info} ) {
-        my $circ_counts = $U->storagereq('open-ils.storage.actor.user.checked_out.count', $patron->id);
-
-        $ctx->{patronOverdue} = $circ_counts->{overdue}  + $circ_counts->{long_overdue};
-        my $out = $ctx->{patronOverdue} + $circ_counts->{out};
-
-        $ctx->{patronItemsOut} = $out 
-            unless( $ctx->{patronItemsOut} and $ctx->{patronItemsOut} > $out );
-
-        $logger->debug("script_builder: patron overdue count is " . $ctx->{patronOverdue});
-    }
-
-    if( $ctx->{fetch_patron_money_info} ) {
-        $ctx->{patronFines} = $U->patron_money_owed($patron->id);
-        $logger->debug("script_builder: patron fines determined to be ".$ctx->{patronFines});
-    }
-
-    unless( $ctx->{ignore_user_status} ) {
-        return OpenILS::Event->new('PATRON_INACTIVE')
-            unless $U->is_true($patron->active);
-    
-        return OpenILS::Event->new('PATRON_CARD_INACTIVE')
-            unless $U->is_true($patron->card->active);
-    
-        my $expire = DateTime::Format::ISO8601->new->parse_datetime(
-            cleanse_ISO8601($patron->expire_date));
-    
-        return OpenILS::Event->new('PATRON_ACCOUNT_EXPIRED')
-            if( CORE::time > $expire->epoch ) ;
-    }
-
-    return undef;
-}
-
-
-sub flatten_groups {
-    my $e = shift;
-    my $tree = shift;
-
-    if(!%GROUP_SET) {
-        $GROUP_TREE = $e->search_permission_grp_tree(
-            [
-                { parent => undef }, 
-                { 
-                flesh => 100,
-                    flesh_fields => { pgt => ['children'] }
-                } 
-            ]
-        )->[0];
-        $tree = $GROUP_TREE;
-    }
-
-    return undef unless $tree;
-    $GROUP_SET{$tree->id} = $tree;
-    if( $tree->children ) {
-        flatten_groups($e, $_) for @{$tree->children};
-    }
-}
-
-sub flatten_org_tree {
-    my $tree = shift;
-    return undef unless $tree;
-    push( @ORG_LIST, $tree );
-    if( $tree->children ) {
-        flatten_org_tree($_) for @{$tree->children};
-    }
-}
-
-
-
-sub insert_org_methods {
-    my ( $editor, $runner ) = @_;
-
-    if(!$ORG_TREE) {
-        $ORG_TREE = $U->get_org_tree;
-        flatten_org_tree($ORG_TREE);
-    }
-
-    my $r = $runner;
-    weaken($r);
-
-    $r->insert(__OILS_FUNC_isOrgDescendent  => 
-        sub {
-            my( $write_key, $sname, $id ) = @_;
-            my ($parent)    = grep { $_->shortname eq $sname } @ORG_LIST;
-            my ($child)     = grep { $_->id == $id } @ORG_LIST;
-            my $val = is_org_descendent( $parent, $child );
-            $logger->debug("script_builder: is_org_desc $sname:$id returned val $val, writing to $write_key");
-            $r->insert($write_key, $val, 1) if $val;
-            return $val;
-        }
-    );
-
-    $r->insert(__OILS_FUNC_hasCommonAncestor  => 
-        sub {
-            my( $write_key, $orgid1, $orgid2, $depth ) = @_;
-            my $val = has_common_ancestor( $orgid1, $orgid2, $depth );
-            $logger->debug("script_builder: has_common_ancestor resturned $val");
-            $r->insert($write_key, $val, 1) if $val;
-            return $val;
-        }
-    );
-}
-
-
-sub is_org_descendent {
-    my( $parent, $child ) = @_;
-    return 0 unless $parent and $child;
-    $logger->debug("script_builder: is_org_desc checking parent=".$parent->id.", child=".$child->id);
-    do {
-        return 0 unless defined $child->parent_ou;
-        return 1 if $parent->id == $child->id;
-    } while( ($child) = grep { $_->id == $child->parent_ou } @ORG_LIST );
-    return 0;
-}
-
-sub has_common_ancestor {
-    my( $org1, $org2, $depth ) = @_;
-    return 0 unless $org1 and $org2;
-    $logger->debug("script_builder: has_common_ancestor checking orgs $org1 : $org2");
-
-    return 1 if $org1 == $org2;
-    ($org1) = grep { $_->id == $org1 } @ORG_LIST;
-    ($org2) = grep { $_->id == $org2 } @ORG_LIST;
-
-    my $p1 = find_parent_at_depth($org1, $depth);
-    my $p2 = find_parent_at_depth($org2, $depth);
-
-    return 1 if $p1->id == $p2->id;
-    return 0;
-}
-
-
-sub find_parent_at_depth {
-    my $org = shift;
-    my $depth = shift;
-    return undef unless $org and $depth;
-    fetch_ou_types();
-    do {
-        my ($t) = grep { $_->id == $org->ou_type } @OU_TYPES;
-        return $org if $t->depth == $depth;
-    } while( ($org) = grep { $_->id == $org->parent_ou } @ORG_LIST );
-    return undef;   
-}
-
-
-sub fetch_ou_types {
-    return if @OU_TYPES;
-    @OU_TYPES = @{new_editor()->retrieve_all_actor_org_unit_type()};
-}
-
-sub insert_copy_methods {
-    my( $e, $ctx,  $runner ) = @_;
-    my $reqr = $ctx->{requestor} || $e->requestor;
-    if( my $copy = $ctx->{copy} ) {
-        $runner->insert_method( 'environment.copy', '__OILS_FUNC_fetch_best_hold', sub {
-                my $key = shift;
-                $logger->debug("script_builder: searching for permitted hold for copy ".$copy->barcode);
-                my ($hold) = $holdcode->find_nearest_permitted_hold( $e, $copy, $reqr, 1 );  # do we need a new editor here since the xact may be dead??
-                $runner->insert( $key, $hold, 1 );
-            }
-        );
-    }
-}
-
-sub insert_user_funcs {
-   my( $e, $ctx, $runner ) = @_;
-
-   # tells how many holds a user has
-    $runner->insert(__OILS_FUNC_userHoldCount  => 
-        sub {
-            my( $write_key, $userid ) = @_;
-         my $val = $holdcode->__user_hold_count(new_editor(), $userid);
-         $logger->info("script_runner: user hold count is $val");
-            $runner->insert($write_key, $val, 1) if $val;
-            return $val;
-        }
-    );
-
-    $runner->insert(__OILS_FUNC_userCircsByCircmod  => 
-        sub {
-            my( $write_key, $userid ) = @_;
-            use OpenSRF::Utils::JSON;
-
-            # this bug ugly thing generates a count of checkouts by circ_modifier
-             my $query = {
-                "select" => {
-                    "acp" => ["circ_modifier"],
-                    "circ"=>[{
-                        "aggregate"=> OpenSRF::Utils::JSON->true,
-                        "transform"=>"count",
-                        "alias"=>"count",
-                        "column"=>"id"
-                    }],
-                },
-                "from"=>{"acp"=>{"circ"=>{"field"=>"target_copy","fkey"=>"id"}}},
-                "where"=>{
-                    "+circ"=>{
-                        "checkin_time"=>undef,
-                        "usr"=>$userid,
-                        "-or"=>[
-                            {"stop_fines"=>["MAXFINES","LONGOVERDUE"]},
-                            {"stop_fines"=>undef}
-                        ]
-                    }
-                }
-            };
-
-            my $mods = $e->json_query($query);
-            my $breakdown = {};
-            $breakdown->{$_->{circ_modifier}} = $_->{count} for @$mods;
-            $logger->info("script_runner: Loaded checkouts by circ_modifier breakdown:". 
-                OpenSRF::Utils::JSON->perl2JSON($breakdown));
-            $runner->insert($write_key, $breakdown, 1) if (keys %$breakdown);
-        }
-    );
-
-}
-
-
-
-
-1;
index eb40e97..2a98825 100644 (file)
@@ -7,7 +7,6 @@ use Carp;
 use OpenILS::SIP;
 use OpenILS::SIP::Transaction;
 use OpenILS::Application::AppUtils;
-use OpenILS::Application::Circ::ScriptBuilder;
 # use Data::Dumper;
 use OpenILS::Const qw/:const/;
 use OpenSRF::Utils qw/:datetime/;
@@ -157,20 +156,6 @@ sub new {
     syslog("LOG_DEBUG", "OILS: Item('$item_id'): found with title '%s'", $self->title_id);
 
     my $config = OpenILS::SIP->config();    # FIXME : will not always match!
-    my $legacy = $config->{implementation_config}->{legacy_script_support} || undef;
-
-    if( defined $legacy ) {
-        $self->{legacy_script_support} = ($legacy =~ /t(rue)?/io) ? 1 : 0;
-        syslog("LOG_DEBUG", "legacy_script_support is set in SIP config: " . $self->{legacy_script_support});
-
-    } else {
-        my $lss = OpenSRF::Utils::SettingsClient->new->config_value(
-            apps         => 'open-ils.circ',
-            app_settings => 'legacy_script_support'
-        );
-        $self->{legacy_script_support} = ($lss =~ /t(rue)?/io) ? 1 : 0;
-        syslog("LOG_DEBUG", "legacy_script_support is set in SRF config: " . $self->{legacy_script_support});
-    }
 
     return $self;
 }
@@ -245,52 +230,20 @@ sub run_attr_script {
     return 1 if $self->{ran_script};
     $self->{ran_script} = 1;
 
-    if($self->{legacy_script_support}){
-
-        syslog('LOG_DEBUG', "Legacy script support is ON");
-        my $config = OpenILS::SIP->config();
-        my $path               = $config->{implementation_config}->{scripts}->{path};
-        my $item_config_script = $config->{implementation_config}->{scripts}->{item_config};
-
-        $path = ref($path) eq 'ARRAY' ? $path : [$path];
-        my $path_str = join(", ", @$path);
-
-        syslog('LOG_DEBUG', "OILS: Script path = [$path_str], Item config script = $item_config_script");
-
-        my $runner = OpenILS::Application::Circ::ScriptBuilder->build({
-            copy   => $self->{copy},
-            editor => OpenILS::SIP->editor(),
-        });
-
-        $runner->add_path($_) for @$path;
-        $runner->load($item_config_script);
+    # use the in-db circ modifier configuration 
+    my $config = {magneticMedia => 'f', SIPMediaType => '001'};     # defaults
+    my $mod = $self->{copy}->circ_modifier;
 
-        unless( $self->{item_config_result} = $runner->run ) {      # assignment, not comparison
-            $runner->cleanup;
-            warn "Item config script [$path_str : $item_config_script] failed to run: $@\n";
-            syslog('LOG_ERR', "OILS: Item config script [$path_str : $item_config_script] failed to run: $@");
-            return undef;
+    if($mod) {
+        my $mod_obj = OpenILS::SIP->editor()->retrieve_config_circ_modifier($mod);
+        if($mod_obj) {
+            $config->{magneticMedia} = $mod_obj->magnetic_media;
+            $config->{SIPMediaType}  = $mod_obj->sip2_media_type;
         }
-
-        $runner->cleanup;
-
-    } else {
-
-        # use the in-db circ modifier configuration 
-        my $config = {magneticMedia => 'f', SIPMediaType => '001'};     # defaults
-        my $mod = $self->{copy}->circ_modifier;
-
-        if($mod) {
-            my $mod_obj = OpenILS::SIP->editor()->retrieve_config_circ_modifier($mod);
-            if($mod_obj) {
-                $config->{magneticMedia} = $mod_obj->magnetic_media;
-                $config->{SIPMediaType}  = $mod_obj->sip2_media_type;
-            }
-        }
-
-        $self->{item_config_result} = { item_config => $config };
     }
 
+    $self->{item_config_result} = { item_config => $config };
+
     return 1;
 }
 
index 39e59be..f2153a8 100644 (file)
 package OpenILS::Utils::PermitHold;
 use strict; use warnings;
-use Data::Dumper;
 use OpenSRF::Utils;
-use OpenSRF::Utils::SettingsClient;
-use OpenILS::Utils::ScriptRunner;
-use OpenILS::Application::AppUtils;
-use DateTime::Format::ISO8601;
-use OpenILS::Application::Circ::ScriptBuilder;
 use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Application::AppUtils;
 use OpenILS::Event;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
-my $U   = "OpenILS::Application::AppUtils";
-
-my $script;         # - the permit script
-my $script_libs;    # - extra script libs
-my $legacy_script_support;
-
-# mental note:  open-ils.storage.biblio.record_entry.ranged_tree
+my $U  = "OpenILS::Application::AppUtils";
 
 
 # params within a hash are: copy, patron, 
 # requestor, request_lib, title, title_descriptor
 sub permit_copy_hold {
     my $params  = shift;
-    my @allevents;
-
-    unless(defined $legacy_script_support) {
-        my $conf = OpenSRF::Utils::SettingsClient->new;
-        $legacy_script_support = $conf->config_value(
-            apps => 'open-ils.circ' => app_settings => 'legacy_script_support');
-        $legacy_script_support = ($legacy_script_support and 
-            $legacy_script_support =~ /true/i) ? 1 : 0;
-    }
-
-    return indb_hold_permit($params) unless $legacy_script_support;
-
-    my $ctx = {
-        patron_id   => $$params{patron_id},
-        patron      => $$params{patron},
-        copy            => $$params{copy},
-        requestor   => $$params{requestor},
-        title           => $$params{title},
-        volume      => $$params{volume},
-        flesh_age_protect => 1,
-        _direct => {
-            requestLib  => $$params{request_lib},
-            pickupLib   => $$params{pickup_lib},
-            newHold    => $$params{new_hold},
-        }
-    };
-
-    my $runner = OpenILS::Application::Circ::ScriptBuilder->build($ctx);
-
-    my $ets = $ctx->{_events};
-
-    # --------------------------------------------------------------
-    # Strip the expired event since holds are still allowed to be
-    # captured on expired patrons.  
-    # --------------------------------------------------------------
-    if( $ets and @$ets ) {
-        $ets = [ grep { $_->{textcode} ne 'PATRON_ACCOUNT_EXPIRED' } @$ets ];
-    } else { $ets = []; }
-
-    if( @$ets ) {
-        push( @allevents, @$ets);
-
-        # --------------------------------------------------------------
-        # If scriptbuilder returned any events, then the script context
-        # is undefined and should not be used
-        # --------------------------------------------------------------
-
-    } else {
-
-        # check the various holdable flags
-        push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') )
-            unless $U->is_true($ctx->{copy}->holdable);
-    
-        push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') )
-            unless $U->is_true($ctx->{copy}->location->holdable);
-    
-        push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') )
-            unless $U->is_true($ctx->{copy}->status->holdable);
-    
-      my $evt;
-
-      # grab the data safely
-      my $rlib = ref($$params{request_lib}) ? $$params{request_lib}->id : $$params{request_lib};
-      my $olib = ref($ctx->{volume}) ? $ctx->{volume}->owning_lib : -1;
-      my $rid  = ref($ctx->{requestor}) ? $ctx->{requestor}->id : -2;
-        my $pid  = ($params->{patron}) ? $params->{patron}->id : $params->{patron_id};
-
-      if( ($rid ne $pid) and ($olib eq $rlib) ) {
-         $logger->info("Item owning lib $olib is the same as the request lib.  No age_protection will be checked");
-      } else {
-         $logger->info("item owning lib = $olib, request lib = $rlib, requestor=$rid, patron=$pid. checking age_protection");
-           $evt = check_age_protect($ctx->{patron}, $ctx->{copy});
-           push( @allevents, $evt ) if $evt;
-      }
-    
-        $logger->debug("Running permit_copy_hold on copy " . $$params{copy}->id);
-    
-        load_scripts($runner);
-        my $result = $runner->run or 
-            throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@");
-
-        # --------------------------------------------------------------
-        # Extract and uniquify the event list
-        # --------------------------------------------------------------
-        my $events = $result->{events};
-        $logger->debug("circ_permit_hold for user $pid returned events: [@$events]");
-    
-        push( @allevents, OpenILS::Event->new($_)) for @$events;
-    }
-
-    my %hash = map { ($_->{ilsevent} => $_) } @allevents;
-    @allevents = values %hash;
-
-    $runner->cleanup;
-
-    return \@allevents if $$params{show_event_list};
-    return 1 unless @allevents;
-    return 0;
-}
-
-
-sub load_scripts {
-    my $runner = shift;
-
-    if(!$script) {
-        my $conf = OpenSRF::Utils::SettingsClient->new;
-        my @pfx = ( "apps", "open-ils.circ","app_settings" );
-        my $libs    = $conf->config_value(@pfx, 'script_path');
-        $script = $conf->config_value(@pfx, 'scripts', 'circ_permit_hold');
-        $script_libs = (ref($libs)) ? $libs : [$libs];
-    }
-
-    $runner->add_path($_) for(@$script_libs);
-    $runner->load($script);
-}
-
-
-sub check_age_protect {
-    my( $patron, $copy ) = @_;
-
-    return undef unless $copy and $copy->age_protect and $patron;
-
-    my $hou = (ref $patron->home_ou) ? $patron->home_ou->id : $patron->home_ou;
-
-    my $prox = $U->storagereq(
-        'open-ils.storage.asset.copy.proximity', $copy->id, $hou );
-
-    # If this copy is within the appropriate proximity, 
-    # age protect does not apply
-    return undef if $prox <= $copy->age_protect->prox;
-
-    my $protection_list = $U->storagereq(
-        'open-ils.storage.direct.config.rules.age_hold_protect.search_where.atomic', 
-        { age  => { '>=' => $copy->age_protect->age  },
-          prox => { '>=' => $copy->age_protect->prox },
-        },
-        { order_by => 'age' }
-    );
-
-    # circ_lib may be fleshed
-    my $context_org = ref $copy->circ_lib ? $copy->circ_lib->id : $copy->circ_lib;
-    my $age_protect_date = $copy->create_date;
-    $age_protect_date = $copy->active_date if($U->ou_ancestor_setting_value($context_org, 'circ.holds.age_protect.active_date'));
-
-    my $age = 0;
-    my $age_protect_parsed;
-    if($age_protect_date) {
-        # Now, now many seconds old is this copy
-        $age_protect_parsed = DateTime::Format::ISO8601
-            ->new
-            ->parse_datetime( OpenSRF::Utils::cleanse_ISO8601($age_protect_date) )
-            ->epoch;
-        $age = time - $age_protect_parsed;
-    }
-
-    for my $protection ( @$protection_list ) {
-
-        $logger->info("analyzing age protect ".$protection->name);
-
-        # age protect does not apply if within the proximity
-        last if $prox <= $protection->prox;
-
-        # How many seconds old does the copy have to be to escape age protection
-        my $interval = OpenSRF::Utils::interval_to_seconds($protection->age);
-
-        $logger->info("age_protect interval=$interval, age_protect_date=$age_protect_parsed, age=$age");
-
-        if( $interval > $age ) { 
-            # if age of the item is less than the protection interval, 
-            # the item falls within the age protect range
-            $logger->info("age_protect prevents copy from having a hold placed on it: ".$copy->id);
-            return OpenILS::Event->new('ITEM_AGE_PROTECTED', copy => $copy->id );
-        }
-    }
-        
-    return undef;
+    return indb_hold_permit($params);
 }
 
 my $LEGACY_HOLD_EVENT_MAP = {
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/ScriptRunner.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/ScriptRunner.pm
deleted file mode 100644 (file)
index 80a4459..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-package OpenILS::Utils::ScriptRunner;
-use strict; use warnings;
-use OpenSRF::Utils::Logger qw(:logger);
-use OpenSRF::EX qw(:try);
-use OpenSRF::Utils::JSON;
-use JavaScript::SpiderMonkey;
-use LWP::UserAgent;
-use XML::LibXML;
-use Time::HiRes qw/time/;
-use vars qw/%_paths/;
-
-sub DESTROY {
-    my $self = shift;
-    $logger->info("script_runner: destroying self: $self");
-}
-
-sub cleanup {
-    my $runner = shift;
-    $logger->info("script_runner: destroying context...");
-    $runner->context->destroy;
-    delete($$runner{$_}) for (keys %$runner);
-}
-
-sub new {
-    my $class = shift;
-    my %params = @_;
-    $class = ref($class) || $class;
-    $params{paths} ||= [];
-    $params{reset_count} ||= 0;
-
-    my $self = bless {  file => $params{file},
-                libs => $params{libs},
-                reset_count => $params{reset_count},
-                _runs => 0,
-                _path => {%_paths} } => $class;
-
-    $self->add_path($_) for @{$params{paths}};
-    return $self->init; 
-}
-
-sub context {
-    my( $self, $context ) = @_;
-    $self->{ctx} = $context if $context;
-    return $self->{ctx};
-}
-
-sub init {
-    my $self = shift;
-    $self->context( new JavaScript::SpiderMonkey );
-    $self->context->init();
-
-    $self->{_runs} = 0;
-
-    # eating our own dog food with insert
-    $self->insert(log_stdout    => sub { print "@_\n"; } );
-    $self->insert(log_stderr    => sub { warn "@_\n"; } );
-    $self->insert(log_activity  => sub { $logger->activity("script_runner: @_"); return 1;} );
-    $self->insert(log_error     => sub { $logger->error("script_runner: @_"); return 1;} );
-    $self->insert(log_warn      => sub { $logger->warn("script_runner: @_"); return 1;} );
-    $self->insert(log_info      => sub { $logger->info("script_runner: @_"); return 1;} );
-    $self->insert(log_debug     => sub { $logger->debug("script_runner: @_"); return 1;} );
-    $self->insert(log_internal  => sub { $logger->internal("script_runner: @_"); return 1;} );
-    $self->insert(debug     => sub { $logger->debug("script_runner: @_"); return 1;} );
-    $self->insert(alert     => sub { $logger->warn("script_runner: @_"); return 1;} );
-    $self->insert(load_lib      => sub { $self->load_lib(@_); return 1;});
-
-    # OpenSRF support functions
-    $self->insert(
-        _OILS_FUNC_jsonopensrfrequest_send =>
-            sub { $self->_jsonopensrfrequest_send(@_); }
-    );
-    $self->insert(
-        _OILS_FUNC_jsonopensrfrequest_connect =>
-            sub { $self->_jsonopensrfrequest_connect(@_); }
-    );
-    $self->insert(
-        _OILS_FUNC_jsonopensrfrequest_disconnect =>
-            sub { $self->_jsonopensrfrequest_disconnect(@_); }
-    );
-    $self->insert(
-        _OILS_FUNC_jsonopensrfrequest_finish =>
-            sub { $self->_jsonopensrfrequest_finish(@_); }
-    );
-
-    # XML support functions
-    $self->insert(
-        _OILS_FUNC_xmlhttprequest_send  =>
-            sub { $self->_xmlhttprequest_send(@_); }
-    );
-    $self->insert(
-        _OILS_FUNC_xml_parse_string =>
-            sub { $self->_parse_xml_string(@_); }
-    );
-    
-    while ( my $e = shift @{$self->{_env}} ) {
-        $self->insert( @$e{ qw/key value readonly/ } => 1 );
-    }
-
-    while ( my $e = shift @{$self->{_methods}} ) {
-        $self->insert_method( @$e{ qw/key name meth/ } => 1 );
-    }
-
-    $self->load_lib($_) for @{$self->{libs}};
-
-    return $self;
-}
-
-sub refresh_context {
-    my $self = shift;
-    $logger->debug("Refreshing JavaScript Context...");
-    $self->context->destroy;
-    $logger->debug("Context destroyed");
-    $self->{_loaded} = {};
-    $logger->debug("Loaded scripts removed");
-    $self->init;
-    $logger->debug("New Context initialized");
-    return $self;
-}
-
-sub load {
-    my( $self, $filename ) = @_;
-    $self->{file} = $filename;
-}
-
-sub runs { shift()->{_runs} }
-
-sub reset_count {
-    my $self = shift;
-    my $count = shift;
-
-    $self->{reset_count} = $count if ($count);
-    return $self->{reset_count};
-}
-
-sub run {
-    my $self = shift;
-    my $file = shift();
-
-    my $_real = 0;
-    if(!$file) {
-        $_real = 1;
-        $file = $self->{file};
-    }
-
-    $self->refresh_context
-        if ($self->reset_count && $self->runs > $self->reset_count);
-
-    $self->{_runs}++ if ($_real);
-
-    $file = $self->_find_file($file);
-    $logger->debug("full script file path: $file");
-
-    if( ! open(F, $file) ) {
-        $logger->error("Error opening script file: $file");
-        return 0;
-    }
-
-    my $js = $self->context;
-
-    my $res = '';
-    {   local $/ = undef;
-
-        $self->insert('environment.result' => {});
-
-        my $content = <F>;
-        #print ( "full script is [$content]" );
-
-        my $s = time();
-        if( !$js || !$content || !$js->eval($content) ) {
-            $logger->error("$file Eval failed: $@");  
-            return 0;
-        }
-        $logger->debug("eval of $file took ". sprintf('%0.3f', time - $s) . " seconds");
-
-        if ($_real) {
-            $self->insert('__' => {'OILS_RESULT' => ''});
-            $js->eval("__.OILS_RESULT = js2JSON(environment.result);");
-            $res = $self->retrieve('__.OILS_RESULT');
-        }
-    }
-
-    close(F);
-    $logger->debug( "script result is [$res]" );
-    return OpenSRF::Utils::JSON->JSON2perl( $res );
-}
-
-sub remove_path { 
-    my( $self, $path ) = @_;
-    if (ref($self)) {
-        if ($self->{_path}{$path}) {
-            $self->{_path}{$path} = 0;
-        }
-        return $self->{_path}{$path};
-    } else {
-        if ($_paths{$path}) {
-            $_paths{$path} = 0;
-        }
-        return $_paths{$path};
-    }
-}
-
-sub add_path { 
-    my( $self, $path ) = @_;
-    if (ref($self)) {
-        if (!$self->{_path}{$path}) {
-            $self->{_path}{$path} = 1;
-        }
-    } else {
-        if (!$_paths{$path}) {
-            $_paths{$path} = 1;
-        }
-    }
-    return $self;
-}
-
-sub _find_file {
-    my $self = shift;
-    my $file = shift;
-    for my $p ( keys %{ $self->{_path} } ) {
-        next unless ($self->{_path}{$p});
-        my $full = join('/',$p,$file);
-        return $full if (-e $full);
-    }
-}
-
-sub load_lib { 
-    my( $self, $file ) = @_;
-
-    my @paths = keys %{$self->{_path}};
-    $logger->debug("script_runner: Loading lib file $file : paths=[@paths]");
-
-    push @{ $self->{libs} }, $file
-        if (! grep {$_ eq $file} @{ $self->{libs} });
-
-    if (!$self->{_loaded}{$file}) {
-        $self->run( $file );
-        $self->{_loaded}{$file} = 1;
-    }
-    return $self->{_loaded}{$file};
-}
-
-sub _js_prop_name {
-    my $name = shift;
-    $name =~ s/^.*\.//o;
-    return $name;
-}
-
-sub retrieve {
-    my( $self, $key ) = @_;
-    return $self->context->property_get($key);
-}
-
-sub insert_method {
-    my( $self, $obj_key, $meth_name, $sub, $stop) = @_;
-
-    push @{$self->{_methods}}, { key => $obj_key => name => $meth_name, meth => $sub } unless ($stop);
-    
-    my $obj = $self->context->object_by_path( $obj_key );
-    $self->context->function_set( $meth_name, $sub, $obj ) if $obj;
-}
-
-
-sub insert {
-    my( $self, $key, $val, $RO, $stop ) = @_;
-    return unless defined($key);
-
-    push @{$self->{_env}}, { key => $key => value => $val, readonly => $RO } unless ($stop);
-
-    if (ref($val) =~ /^Fieldmapper/o) {
-        $self->insert_fm($key, $val, $RO);
-    } elsif (ref($val) and $val =~ /ARRAY/o) {
-        $self->insert_array($key, $val, $RO);
-    } elsif (ref($val) and $val =~ /HASH/o) {
-        $self->insert_hash($key, $val, $RO);
-    } elsif (ref($val) and $val =~ /CODE/o) {
-        $self->context->function_set( $key, $val );
-    } elsif (!ref($val)) {
-        if( defined($val) ) {
-            $self->context->property_by_path(
-                $key, $val,
-                ( !$RO ?  (sub { $val }, sub { my( $k, $v ) = @_; $val = $v; }) : () )
-            );
-        } else {
-            $self->context->property_by_path($key, "");
-        }
-
-    } else {
-        return 0;
-    }
-
-    return 1;
-}
-
-sub insert_fm {
-
-    my( $self, $key, $fm, $RO ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $fm);
-    my $o = $ctx->object_by_path($key);
-    
-    for my $f ( $fm->properties ) {
-        my $val = $fm->$f();
-        if (ref $val) {
-            $self->insert("$key.$f", $val);
-        } else {
-            $ctx->property_by_path(
-                "$key.$f",
-                $val,
-                ( !$RO ? 
-                    (sub {
-                        my $k = _js_prop_name(shift());
-                        $fm->$k();
-                    }, 
-                    sub {
-                        my $k = _js_prop_name(shift());
-                        $fm->ischanged(1);
-                        $fm->$k(@_);
-                    }) :
-                    ()
-                )
-            );
-        }
-    }
-}
-
-sub insert_hash {
-
-    my( $self, $key, $hash, $RO ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $hash);
-    $ctx->object_by_path($key);
-    
-    for my $k ( keys %$hash ) {
-        my $v = $hash->{$k};
-        if (ref $v) {
-            $self->insert("$key.$k", $v);
-        } else {
-            $ctx->property_by_path(
-                "$key.$k", $v,
-                ( !$RO ? 
-                    (sub { $hash->{_js_prop_name(shift())} },
-                    sub {
-                        my( $hashkey, $val ) = @_;
-                        $hash->{_js_prop_name($hashkey)} = $val;
-                    }) :
-                    ()
-                )
-            );
-        }
-    }
-}
-
-my $__array_id = 0;
-sub insert_array {
-
-    my( $self, $key, $array ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $array);
-
-    my $a = $ctx->array_by_path($key);
-    
-    my $ind = 0;
-    for my $v ( @$array ) {
-        if (ref $v) {
-            my $tmp_index = $__array_id++;
-            my $elobj = $ctx->object_by_path('__tmp_arr_el'.$tmp_index);
-            $self->insert('__tmp_arr_el'.$tmp_index, $v);
-            $ctx->array_set_element_as_object( $a, $ind, $elobj );
-        } else {
-            $ctx->array_set_element( $a, $ind, $v ) if defined($v);
-        }
-        $ind++;
-    }
-}
-
-sub _xmlhttprequest_send {
-    my $self = shift;
-    my $id = shift;
-    my $method = shift;
-    my $url = shift;
-    my $blocking = shift;
-    my $headerlist = shift;
-    my $data = shift;
-
-    my $ctx = $self->context;
-
-    # just so perl has access to it...
-    $ctx->object_by_path('__xmlhttpreq_hash.id'.$id);
-
-    my $headers = new HTTP::Headers;
-    my @lines = split(/\n/so, $headerlist);
-    for my $line (@lines) {
-        if ($line =~ /^(.+?)|(.+)$/o) {
-            $headers->header($1 => $2);
-        }
-    }
-
-    my $ua = LWP::UserAgent->new;
-    $ua->agent("OpenILS/0.1");
-
-    my $req = HTTP::Request->new($method => $url => $headers => $data);
-    my $res = $ua->request($req);
-
-    if ($res->is_success) {
-        
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.responseText', $res->content);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.readyState', 4);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.statusText', $res->status_line);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.status', $res->code);
-
-    }
-        
-}
-
-our %_jsonopensrfrequest_cache = ();
-
-sub _jsonopensrfrequest_connect {
-    my $self = shift;
-    my $id = shift;
-    my $service = shift;
-
-    my $ctx = $self->context;
-    $ctx->object_by_path('__jsonopensrfreq_hash.id'.$id);
-
-    my $ses = $_jsonopensrfrequest_cache{$id} ||
-            do { $_jsonopensrfrequest_cache{$id} = OpenSRF::AppSession->create($service) };
-
-    if($ses->connect) {
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.connected', 1);
-    } else {
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.connected', 0);
-    }
-}
-
-sub _jsonopensrfrequest_disconnect {
-    my $self = shift;
-    my $id = shift;
-
-    my $ctx = $self->context;
-    $ctx->object_by_path('__jsonopensrfreq_hash.id'.$id);
-
-    my $ses = $_jsonopensrfrequest_cache{$id};
-    return unless $ses;
-
-    $ses->disconnect;
-}
-
-sub _jsonopensrfrequest_finish {
-    my $self = shift;
-    my $id = shift;
-
-    my $ctx = $self->context;
-    $ctx->object_by_path('__jsonopensrfreq_hash.id'.$id);
-
-    my $ses = $_jsonopensrfrequest_cache{$id};
-    return unless $ses;
-
-    $ses->finish;
-    delete $_jsonopensrfrequest_cache{$id};
-}
-
-sub _jsonopensrfrequest_send {
-    my $self = shift;
-    my $id = shift;
-    my $service = shift;
-    my $method = shift;
-    my $blocking = shift;
-    my $params = shift;
-
-    my @p = @{ OpenSRF::Utils::JSON->JSON2perl($params) };
-
-    my $ctx = $self->context;
-
-    # just so perl has access to it...
-    $ctx->object_by_path('__jsonopensrfreq_hash.id'.$id);
-
-    my $ses = $_jsonopensrfrequest_cache{$id} ||
-            do { $_jsonopensrfrequest_cache{$id} = OpenSRF::AppSession->create($service) };
-    my $req = $ses->request($method,@p);
-
-    $req->wait_complete;
-    if (!$req->failed) {
-        my $res = $req->recv->content;
-        
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.responseText', OpenSRF::Utils::JSON->perl2JSON($res));
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.readyState', 4);
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.statusText', 'OK');
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.status', '200');
-
-    } else {
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.responseText', '');
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.readyState', 4);
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.statusText', $req->failed->status );
-        $ctx->property_by_path('__jsonopensrfreq_hash.id'.$id.'.status', $req->failed->statusCode );
-    }
-
-    $req->finish;
-        
-}
-
-sub _parse_xml_string {
-    my $self = shift;
-    my $string = shift;
-    my $key = shift;
-
-
-    my $doc;
-    my $s = 0;
-    try {
-        $doc = XML::LibXML->new->parse_string( $string );
-        $s = 1;
-    } catch Error with {
-        my $e = shift;
-        warn "Could not parse document: $e\n";
-    };
-    return unless ($s);
-
-    _JS_DOM($self->context, $key, $doc);
-}
-
-sub _JS_DOM {
-    my $ctx = shift;
-    my $key = shift;
-    my $node = shift;
-
-    if ($node->nodeType == 9) {
-        $node = $node->documentElement;
-
-        my $n = $node->nodeName;
-        my $ns = $node->namespaceURI;
-        $ns =~ s/'/\'/gso if ($ns);
-        $ns = "'$ns'" if ($ns);
-        $ns = 'null' unless ($ns);
-        $n =~ s/'/\'/gso;
-
-        #warn("$key = DOMImplementation().createDocument($ns,'$n');");
-        $ctx->eval("$key = new DOMImplementation().createDocument($ns,'$n');");
-
-        $key = $key.'.documentElement';
-    }
-
-    for my $a ($node->attributes) {
-        my $n = $a->nodeName;
-        my $v = $a->value;
-        $n =~ s/'/\'/gso;
-        $v =~ s/'/\'/gso;
-        #warn("$key.setAttribute('$n','$v');");
-        $ctx->eval("$key.setAttribute('$n','$v');");
-
-    }
-
-    my $k = 0;
-    for my $c ($node->childNodes) {
-        if ($c->nodeType == 1) {
-            my $n = $c->nodeName;
-            my $ns = $node->namespaceURI;
-
-            $n =~ s/'/\'/gso;
-            $ns =~ s/'/\'/gso if ($ns);
-            $ns = "'$ns'" if ($ns);
-            $ns = 'null' unless ($ns);
-
-            #warn("$key.appendChild($key.ownerDocument.createElementNS($ns,'$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createElementNS($ns,'$n'));");
-            _JS_DOM($ctx, "$key.childNodes.item($k)",$c);
-
-        } elsif ($c->nodeType == 3) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createTextNode('$n'));");
-            #warn("path is $key.item($k);");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createTextNode('$n'));");
-
-        } elsif ($c->nodeType == 4) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createCDATASection('$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createCDATASection('$n'));");
-
-        } elsif ($c->nodeType == 8) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createComment('$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createComment('$n'));");
-
-        } else {
-            warn "ACK! I don't know how to handle node type ".$c->nodeType;
-        }
-        
-
-        $k++;
-    }
-
-    return 1;
-}
-
-
-
-1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/SpiderMonkey.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/SpiderMonkey.pm
deleted file mode 100644 (file)
index 8c0684f..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-package OpenILS::Utils::SpiderMonkey;
-use strict; use warnings;
-use OpenSRF::Utils::Logger qw(:logger);
-use OpenSRF::EX qw(:try);
-use OpenILS::Utils::ScriptRunner;
-use base 'OpenILS::Utils::ScriptRunner';
-use JavaScript::SpiderMonkey;
-use LWP::UserAgent;
-use XML::LibXML;
-use Time::HiRes qw/time/;
-use vars qw/%_paths/;
-
-sub new {
-    my ( $class, %params ) = @_;
-    $class = ref($class) || $class;
-    $params{paths} ||= [];
-
-    my $self = { file => $params{file}, libs => $params{libs}, _path => {%_paths} };
-    bless( $self, $class );
-
-    $self->add_path($_) for @{$params{paths}};
-    return $self;
-}
-
-sub context {
-    my( $self, $context ) = @_;
-    $self->{ctx} = $context if $context;
-    return $self->{ctx};
-}
-
-sub init {
-    my $self = shift;
-    my $js = JavaScript::SpiderMonkey->new();
-    $js->init();
-
-    $js->function_set(perl_print    => sub { print "@_\n"; } );
-    $js->function_set(perl_warn => sub { warn @_; } );
-    $js->function_set(log_activity  => sub { $logger->activity(@_); return 1;} );
-    $js->function_set(log_error => sub { $logger->error(@_); return 1;} );
-    $js->function_set(log_warn  => sub { $logger->warn(@_); return 1;} );
-    $js->function_set(log_info  => sub { $logger->info(@_); return 1;} );
-    $js->function_set(log_debug => sub { $logger->debug(@_); return 1;} );
-    $js->function_set(log_internal  => sub { $logger->internal(@_); return 1;} );
-    $js->function_set(debug     => sub { $logger->debug(@_); return 1;} );
-    $js->function_set(alert     => sub { $logger->warn(@_); return 1;} );
-    
-    $js->function_set(load_lib  => sub { $self->load_lib(@_); });
-
-    # XML support functions
-    $js->function_set(
-        _OILS_FUNC_xmlhttprequest_send  => sub { $self->_xmlhttprequest_send(@_); });
-    $js->function_set(
-        _OILS_FUNC_xml_parse_string => sub { $self->_parse_xml_string(@_); });
-    
-    $self->context($js);
-    $self->load_lib($_) for @{$self->{libs}};
-
-    return $self;
-}
-
-
-sub load {
-    my( $self, $filename ) = @_;
-    $self->{file} = $filename;
-}
-
-sub run {
-    my $self = shift;
-    my $file = shift() || $self->{file};
-    my $js = $self->context;
-
-    $file = $self->_find_file($file);
-
-    if( ! open(F, $file) ) {
-        $logger->error("Error opening script file: $file");
-        return 0;
-    }
-
-    {   local $/ = undef;
-        my $content = <F>;
-        my $s = time();
-        if( !$js || !$content || !$js->eval($content) ) {
-            $logger->error("$file Eval failed: $@");  
-            return 0;
-        }
-        $logger->debug("eval of $file took ". sprintf('%0.3f', time - $s) . " seconds");
-    }
-
-    close(F);
-    return 1;
-}
-
-sub remove_path { 
-    my( $self, $path ) = @_;
-    if (ref($self)) {
-        if ($self->{_path}{$path}) {
-            $self->{_path}{$path} = 0;
-        }
-        return $self->{_path}{$path};
-    } else {
-        if ($_paths{$path}) {
-            $_paths{$path} = 0;
-        }
-        return $_paths{$path};
-    }
-}
-
-sub add_path { 
-    my( $self, $path ) = @_;
-    if (ref($self)) {
-        if (!$self->{_path}{$path}) {
-            $self->{_path}{$path} = 1;
-        }
-    } else {
-        if (!$_paths{$path}) {
-            $_paths{$path} = 1;
-        }
-    }
-    return $self;
-}
-
-sub _find_file {
-    my $self = shift;
-    my $file = shift;
-    for my $p ( keys %{ $self->{_path} } ) {
-        next unless ($self->{_path}{$p});
-        my $full = join('/',$p,$file);
-        return $full if (-e $full);
-    }
-}
-
-sub load_lib { 
-    my( $self, $file ) = @_;
-    if (!$self->{_loaded}{$file} && $self->run( $file )) {
-        $self->{_loaded}{$file} = 1;
-    }
-    return $self->{_loaded}{$file};
-}
-
-sub _js_prop_name {
-    my $name = shift;
-    $name =~ s/^.*\.//o;
-    return $name;
-}
-
-sub retrieve {
-    my( $self, $key ) = @_;
-    return $self->context->property_get($key);
-}
-
-sub insert_method {
-    my( $self, $obj_key, $meth_name, $sub ) = @_;
-    my $obj = $self->context->object_by_path( $obj_key );
-    $self->context->function_set( $meth_name, $sub, $obj ) if $obj;
-}
-
-
-sub insert {
-    my( $self, $key, $val ) = @_;
-    return unless defined($key);
-
-    if (ref($val) =~ /^Fieldmapper/o) {
-        $self->insert_fm($key, $val);
-    } elsif (ref($val) and $val =~ /ARRAY/o) {
-        $self->insert_array($key, $val);
-    } elsif (ref($val) and $val =~ /HASH/o) {
-        $self->insert_hash($key, $val);
-    } elsif (ref($val) and $val =~ /CODE/o) {
-        $self->context->function_set( $key, $val );
-    } elsif (!ref($val)) {
-        if( defined($val) ) {
-            $self->context->property_by_path(
-                $key, $val,
-                sub { $val },
-                sub { my( $k, $v ) = @_; $val = $v; }
-            );
-        } else {
-            $self->context->property_by_path($key);
-        }
-
-    } else {
-        return 0;
-    }
-
-    return 1;
-}
-
-sub insert_fm {
-
-    my( $self, $key, $fm ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $fm);
-    my $o = $ctx->object_by_path($key);
-    
-    for my $f ( $fm->properties ) {
-        my $val = $fm->$f();
-        if (ref $val) {
-            $self->insert("$key.$f", $val);
-        } else {
-            $ctx->property_by_path(
-                "$key.$f",
-                $val,
-                sub {
-                    my $k = _js_prop_name(shift());
-                    $fm->$k();
-                }, 
-
-                sub {
-                    my $k = _js_prop_name(shift());
-                    $fm->ischanged(1);
-                    $fm->$k(@_);
-                }
-            );
-        }
-    }
-}
-
-sub insert_hash {
-
-    my( $self, $key, $hash ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $hash);
-    $ctx->object_by_path($key);
-    
-    for my $k ( keys %$hash ) {
-        my $v = $hash->{$k};
-        if (ref $v) {
-            $self->insert("$key.$k", $v);
-        } else {
-            $ctx->property_by_path(
-                "$key.$k", $v,
-                sub { $hash->{_js_prop_name(shift())} },
-                sub { 
-                    my( $key, $val ) = @_;
-                    $hash->{_js_prop_name($key)} = $val; }
-            );
-        }
-    }
-}
-
-my $__array_id = 0;
-sub insert_array {
-
-    my( $self, $key, $array ) = @_;
-    my $ctx = $self->context;
-    return undef unless ($ctx and $key and $array);
-
-    my $a = $ctx->array_by_path($key);
-    
-    my $ind = 0;
-    for my $v ( @$array ) {
-        if (ref $v) {
-            my $elobj = $ctx->object_by_path('__tmp_arr_el'.$__array_id);
-            $self->insert('__tmp_arr_el'.$__array_id, $v);
-            $ctx->array_set_element_as_object( $a, $ind, $elobj );
-            $__array_id++;
-        } else {
-            $ctx->array_set_element( $a, $ind, $v ) if defined($v);
-        }
-        $ind++;
-    }
-}
-
-sub _xmlhttprequest_send {
-    my $self = shift;
-    my $id = shift;
-    my $method = shift;
-    my $url = shift;
-    my $blocking = shift;
-    my $headerlist = shift;
-    my $data = shift;
-
-    my $ctx = $self->context;
-
-    # just so perl has access to it...
-    $ctx->object_by_path('__xmlhttpreq_hash.id'.$id);
-
-    my $headers = new HTTP::Headers;
-    my @lines = split(/\n/so, $headerlist);
-    for my $line (@lines) {
-        if ($line =~ /^(.+?)|(.+)$/o) {
-            $headers->header($1 => $2);
-        }
-    }
-
-    my $ua = LWP::UserAgent->new;
-    $ua->agent("OpenILS/0.1");
-
-    my $req = HTTP::Request->new($method => $url => $headers => $data);
-    my $res = $ua->request($req);
-
-    if ($res->is_success) {
-        
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.responseText', $res->content);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.readyState', 4);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.statusText', $res->status_line);
-        $ctx->property_by_path('__xmlhttpreq_hash.id'.$id.'.status', $res->code);
-
-    }
-        
-}
-
-sub _parse_xml_string {
-    my $self = shift;
-    my $string = shift;
-    my $key = shift;
-
-
-    my $doc;
-    my $s = 0;
-    try {
-        $doc = XML::LibXML->new->parse_string( $string );
-        $s = 1;
-    } catch Error with {
-        my $e = shift;
-        warn "Could not parse document: $e\n";
-    };
-    return unless ($s);
-
-    _JS_DOM($self->context, $key, $doc);
-}
-
-sub _JS_DOM {
-    my $ctx = shift;
-    my $key = shift;
-    my $node = shift;
-
-    if ($node->nodeType == 9) {
-        $node = $node->documentElement;
-
-        my $n = $node->nodeName;
-        my $ns = $node->namespaceURI;
-        $ns =~ s/'/\'/gso if ($ns);
-        $ns = "'$ns'" if ($ns);
-        $ns = 'null' unless ($ns);
-        $n =~ s/'/\'/gso;
-
-        #warn("$key = DOMImplementation().createDocument($ns,'$n');");
-        $ctx->eval("$key = new DOMImplementation().createDocument($ns,'$n');");
-
-        $key = $key.'.documentElement';
-    }
-
-    for my $a ($node->attributes) {
-        my $n = $a->nodeName;
-        my $v = $a->value;
-        $n =~ s/'/\'/gso;
-        $v =~ s/'/\'/gso;
-        #warn("$key.setAttribute('$n','$v');");
-        $ctx->eval("$key.setAttribute('$n','$v');");
-
-    }
-
-    my $k = 0;
-    for my $c ($node->childNodes) {
-        if ($c->nodeType == 1) {
-            my $n = $c->nodeName;
-            my $ns = $node->namespaceURI;
-
-            $n =~ s/'/\'/gso;
-            $ns =~ s/'/\'/gso if ($ns);
-            $ns = "'$ns'" if ($ns);
-            $ns = 'null' unless ($ns);
-
-            #warn("$key.appendChild($key.ownerDocument.createElementNS($ns,'$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createElementNS($ns,'$n'));");
-            _JS_DOM($ctx, "$key.childNodes.item($k)",$c);
-
-        } elsif ($c->nodeType == 3) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createTextNode('$n'));");
-            #warn("path is $key.item($k);");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createTextNode('$n'));");
-
-        } elsif ($c->nodeType == 4) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createCDATASection('$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createCDATASection('$n'));");
-
-        } elsif ($c->nodeType == 8) {
-            my $n = $c->data;
-            $n =~ s/'/\'/gso;
-            #warn("$key.appendChild($key.ownerDocument.createComment('$n'));");
-            $ctx->eval("$key.appendChild($key.ownerDocument.createComment('$n'));");
-
-        } else {
-            warn "ACK! I don't know how to handle node type ".$c->nodeType;
-        }
-        
-
-        $k++;
-    }
-
-    return 1;
-}
-
-
-
-1;
index 5f5c1b0..863fa56 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -T
 
-use Test::More tests => 13;
+use Test::More tests => 12;
 
 BEGIN {
        use_ok( 'OpenILS::Application::Circ' );
@@ -14,7 +14,6 @@ use_ok( 'OpenILS::Application::Circ::HoldNotify' );
 use_ok( 'OpenILS::Application::Circ::Holds' );
 use_ok( 'OpenILS::Application::Circ::Money' );
 use_ok( 'OpenILS::Application::Circ::NonCat' );
-use_ok( 'OpenILS::Application::Circ::ScriptBuilder' );
 use_ok( 'OpenILS::Application::Circ::StatCat' );
 use_ok( 'OpenILS::Application::Circ::Survey' );
 use_ok( 'OpenILS::Application::Circ::Transit' );
index e02a8e2..180686f 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -T
 
-use Test::More tests => 31;
+use Test::More tests => 29;
 use Test::Warn;
 use utf8;
 
@@ -18,8 +18,6 @@ use_ok( 'OpenILS::Utils::OfflineStore' );
 use_ok( 'OpenILS::Utils::Penalty' );
 use_ok( 'OpenILS::Utils::PermitHold' );
 use_ok( 'OpenILS::Utils::RemoteAccount' );
-use_ok( 'OpenILS::Utils::ScriptRunner' );
-use_ok( 'OpenILS::Utils::SpiderMonkey' );
 use_ok( 'OpenILS::Utils::ZClient' );
 use_ok( 'OpenILS::Utils::EDIReader' );
 
index 6bb59f3..3d995f3 100755 (executable)
@@ -452,7 +452,6 @@ DateTime::Format::ISO8601
 DateTime::Format::Mail
 Unix::Syslog
 GD::Graph3d
-JavaScript::SpiderMonkey
 Log::Log4perl
 Email::Send
 Text::CSV
diff --git a/Open-ILS/src/support-scripts/test-scripts/circ_rules.pl b/Open-ILS/src/support-scripts/test-scripts/circ_rules.pl
deleted file mode 100755 (executable)
index 398d0e8..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-#/usr/bin/perl
-use strict; use warnings;
-use lib q|../../../perlmods/lib/|;
-use Time::HiRes qw/time/;
-use OpenILS::Application::Circ::ScriptBuilder;
-require '../oils_header.pl';
-use vars qw/ $user $authtoken $apputils /;
-
-# ---------------------------------------------------------------------
-# SCRIPT VARS
-# ----------------------------------------------------------------------
-#my $patronid                                  = 3;
-my $patronid                                   = 1000502;
-my $copyid                                             = 8000107;
-my $patron_items_out                   = 11;
-my $patron_overdue_count       = 11;
-my $patron_fines                               = 20;
-
-# these are not currently tested in the scripts
-my $is_renewal                                 = 0;
-my $is_non_cat                                 = 0;
-my $is_hold                                            = 0;
-my $non_cat_type                               = 1;
-# ---------------------------------------------------------------------
-
-
-
-my $bsconfig = shift;
-my $script = shift;
-
-die "$0: <bootstrap> <absolute_script_path>\n" unless $script;
-
-my $path;
-
-($path, $script) = ($script =~ m#(/.*/)(.*)#);
-osrf_connect($bsconfig);
-
-my $s = time;
-my $runner = OpenILS::Application::Circ::ScriptBuilder->build(
-       {
-               copy_id                                         => $copyid,
-               patron_id                                       => $patronid,
-               fetch_patron_circ_info  => 1,
-               flesh_age_protect                       => 1,
-               _direct                                         => {
-                       isNonCat                => $is_non_cat,
-                       isRenewal       => $is_renewal,
-                       nonCatType      => $non_cat_type,
-               }
-       }
-);
-
-
-# ---------------------------------------------------------------------
-# Override the default log functions for convenience
-# ---------------------------------------------------------------------
-$runner->insert(log_activity   => sub { print "@_\n"; return 1;} );
-$runner->insert(log_error              => sub { print "@_\n"; return 1;} );
-$runner->insert(log_warn               => sub { print "@_\n"; return 1;} );
-$runner->insert(log_info               => sub { print "@_\n"; return 1;} );
-$runner->insert(log_debug              => sub { print "@_\n"; return 1;} );
-$runner->insert(log_internal   => sub { print "@_\n"; return 1;} );
-
-
-#$runner->add_path('/openils/var/web/opac/common/js');
-$runner->add_path($path);
-$runner->add_path("$path/../");
-#$runner->add_path("$path/../catalog/");
-
-
-# ---------------------------------------------------------------------
-# Run the script
-# ---------------------------------------------------------------------
-print "\nLoading script: $script\n";
-print "\n" . '-'x70 . "\n";
-
-$runner->load($script);
-my $result = $runner->run or die "Script died: $@";
-
-my $end = time - $s;
-
-
-# ---------------------------------------------------------------------
-# Print out any events that occurred
-# ---------------------------------------------------------------------
-print "\n" . '-'x70 . "\n";
-
-my $events = $result->{events};
-my $ievents = $result->{infoEvents};
-my $fevents = $result->{fatalEvents};
-
-print "events = @$events\n";
-print "info events = @$ievents\n";
-print "fatal events = @$fevents\n";
-
-print "\ntime = $end\n";
-
-sub show_events {
-       my $t = shift;
-       my $e = shift;
-       my @e;
-
-       if($e and @e = split(/,/, $e)) {
-               print "$t : $_\n" for @e;
-
-       } else {
-               print "No $t occurred\n";
-       } 
-}
-
-print "\n";
-
-
-
-