2 use strict; use warnings;
5 my $out_file = 'IDL2js.js';
6 my $idl_file = '../../../../examples/fm_IDL.xml';
7 my $xsl_file = '../../../../xsl/fm_IDL2js.xsl';
9 my $xslt = XML::LibXSLT->new();
10 my $style_doc = XML::LibXML->load_xml(location => $xsl_file, no_cdata=>1);
11 my $stylesheet = $xslt->parse_stylesheet($style_doc);
12 my $idl_string = preprocess_idl_file($idl_file);
13 my $idl_doc = XML::LibXML->load_xml(string => $idl_string);
14 my $results = $stylesheet->transform($idl_doc);
15 my $output = $stylesheet->output_as_bytes($results);
17 open(IDL, ">$out_file") or die "Cannot open IDL2js file $out_file : $!\n";
24 sub preprocess_idl_file {
26 open my $idl_fh, '<', $file or die "Unable to open IDL file $file : $!\n";
30 # These substitutions are taken from OpenILS::WWW::IDL2js
31 $xml =~ s/<!--.*?-->//sg; # filter out XML comments ...
32 $xml =~ s/(?:^|\s+)--.*$//mg; # and SQL comments ...
33 $xml =~ s/^\s+/ /mg; # and extra leading spaces ...
34 $xml =~ s/\R*//g; # and newlines