--- /dev/null
+/**
+ * Mock data required by multiple unit tests.
+ */
+
+window._eg_mock_data = {
+
+ // builds a mock org unit tree fleshed with ou_types and
+ // absorbs the tree into egEnv
+ generateOrgTree : function(idlService, orgService) {
+ var type1 = idlService.create('aout');
+ type1.id(1);
+ type1.depth(0);
+
+ var type2 = idlService.create('aout');
+ type2.id(2);
+ type2.depth(1);
+ type2.parent(1);
+
+ var type3 = idlService.create('aout');
+ type3.id(3);
+ type3.depth(2);
+ type3.parent(2);
+
+ var org1 = idlService.create('aou');
+ org1.id(1);
+ org1.ou_type(type1);
+
+ var org2 = idlService.create('aou');
+ org2.id(2);
+ org2.parent_ou(1);
+ org2.ou_type(type2);
+
+ var org3 = idlService.create('aou');
+ org3.id(3);
+ org3.parent_ou(1);
+ org3.ou_type(type2);
+
+ var org4 = idlService.create('aou');
+ org4.id(4);
+ org4.parent_ou(2);
+ org4.ou_type(type3);
+
+ org1.children([org2, org3]);
+ org2.children([org4]);
+ org3.children([]);
+ org4.children([]);
+
+ orgService.orgTree = org1;
+ orgService.absorbTree();
+ }
+}
--- /dev/null
+#!/usr/bin/perl
+use strict; use warnings;
+use XML::LibXML;
+use XML::LibXSLT;
+my $out_file = 'IDL2js.js';
+my $idl_file = '../../../../examples/fm_IDL.xml';
+my $xsl_file = '../../../../xsl/fm_IDL2js.xsl';
+
+my $xslt = XML::LibXSLT->new();
+my $style_doc = XML::LibXML->load_xml(location => $xsl_file, no_cdata=>1);
+my $stylesheet = $xslt->parse_stylesheet($style_doc);
+my $idl_string = preprocess_idl_file($idl_file);
+my $idl_doc = XML::LibXML->load_xml(string => $idl_string);
+my $results = $stylesheet->transform($idl_doc);
+my $output = $stylesheet->output_as_bytes($results);
+
+open(IDL, ">$out_file") or die "Cannot open IDL2js file $out_file : $!\n";
+
+print IDL $output;
+
+close(IDL);
+
+
+sub preprocess_idl_file {
+ my $file = shift;
+ open my $idl_fh, '<', $file or die "Unable to open IDL file $file : $!\n";
+ local $/ = undef;
+ my $xml = <$idl_fh>;
+ close($idl_fh);
+ # These substitutions are taken from OpenILS::WWW::IDL2js
+ $xml =~ s/<!--.*?-->//sg; # filter out XML comments ...
+ $xml =~ s/(?:^|\s+)--.*$//mg; # and SQL comments ...
+ $xml =~ s/^\s+/ /mg; # and extra leading spaces ...
+ $xml =~ s/\R*//g; # and newlines
+ return $xml;
+}