--- messaging/manakai/bin/daf.pl 2006/05/20 05:11:37 1.15 +++ messaging/manakai/bin/daf.pl 2006/12/31 09:11:52 1.23 @@ -1,24 +1,25 @@ #!/usr/bin/perl -w use strict; use Message::Util::QName::Filter { - c => q, - DIS => q, dis => q, dp => q, - fe => q, ManakaiDOM => q, - pc => q, swcfg21 => q, - Util => q, }; -our$VERSION=do{my @r=(q$Revision: 1.15 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; +our$VERSION=do{my @r=(q$Revision: 1.23 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; use Cwd; use Getopt::Long; use Pod::Usage; our %Opt = (create_module => []); my @target_modules; GetOptions ( + 'create-dtd-driver=s' => sub { + shift; + my $i = [split /\s+/, shift, 3]; + $i->[3] = 'dtd-driver'; + push @{$Opt{create_module}}, $i; + }, 'create-dtd-modules=s' => sub { shift; my $i = [split /\s+/, shift, 3]; @@ -30,25 +31,26 @@ my $i = [split /\s+/, shift, 3]; $i->[3] = 'perl-pm'; push @{$Opt{create_module}}, $i; - push @target_modules, [$i->[0], $i->[2]]; + push @target_modules, $i->[0]; }, 'create-perl-test=s' => sub { shift; my $i = [split /\s+/, shift, 3]; $i->[3] = 'perl-t'; push @{$Opt{create_module}}, $i; - push @target_modules, [$i->[0], $i->[2]]; + push @target_modules, $i->[0]; }, 'debug' => \$Opt{debug}, 'dis-file-suffix=s' => \$Opt{dis_suffix}, 'daem-file-suffix=s' => \$Opt{daem_suffix}, 'dafs-file-suffix=s' => \$Opt{dafs_suffix}, 'dafx-file-suffix=s' => \$Opt{dafx_suffix}, + 'dtd-file-suffix=s' => \$Opt{dtd_suffix}, 'help' => \$Opt{help}, 'load-module=s' => sub { shift; my $i = [split /\s+/, shift, 2]; - push @target_modules, [$i->[0], $i->[1]]; + push @target_modules, $i->[0]; }, 'mod-file-suffix=s' => \$Opt{mod_suffix}, 'search-path|I=s' => sub { @@ -98,8 +100,8 @@ $Opt{daem_suffix} = '.dafm' unless defined $Opt{daem_suffix}; $Opt{dafx_suffix} = '.dafx' unless defined $Opt{dafx_suffix}; $Opt{dafs_suffix} = '.dafs' unless defined $Opt{dafs_suffix}; +$Opt{dtd_suffix} = '.dtd' unless defined $Opt{dtd_suffix}; $Opt{mod_suffix} = '.mod' unless defined $Opt{mod_suffix}; -$Message::DOM::DOMFeature::DEBUG = 1 if $Opt{debug}; require Error; $Error::Debug = 1 if $Opt{debug}; $Message::Util::Error::VERBOSE = 1 if $Opt{verbose}; @@ -126,40 +128,36 @@ print STDERR $s if $Opt{verbose}; } +sub daf_open_source_dis_document ($); +sub daf_open_current_module_index ($$); +sub daf_convert_dis_document_to_dnl_document (); +sub daf_get_referring_module_uri_list ($); +sub dac_search_file_path_stem ($$$); +sub daf_get_module_index_file_name ($); +sub daf_check_undefined (); + ## ---- The MAIN Program my $start_time; BEGIN { $start_time = time } -use Message::Util::DIS::DNLite; - -my %feature; +use Message::DOM::DOMCore; for (@{$Opt{create_module}}) { my (undef, undef, undef, $out_type) = @$_; if ($out_type eq 'perl-pm') { require 'manakai/daf-perl-pm.pl'; - $feature{'+' . ExpandedURI q} = '1.0'; } elsif ($out_type eq 'perl-t') { require 'manakai/daf-perl-t.pl'; - $feature{ExpandedURI q} = '3.0'; - $feature{'+' . ExpandedURI q} = '1.0'; - $feature{'+' . ExpandedURI q} = '1.0'; } elsif ($out_type eq 'dtd-modules') { require 'manakai/daf-dtd-modules.pl'; - $feature{ExpandedURI q} = '3.0'; - $feature{'+' . ExpandedURI q} = '3.0'; + } elsif ($out_type eq 'dtd-driver') { + require 'manakai/daf-dtd-modules.pl'; } } -our $limpl = $Message::DOM::ImplementationRegistry->get_implementation - ({ExpandedURI q => '3.0', - '+' . ExpandedURI q => '1.0', - '+' . ExpandedURI q => '1.0', - %feature, - }); -our $impl = $limpl->get_feature (ExpandedURI q => '1.0'); +our $impl = $Message::DOM::ImplementationRegistry->get_dom_implementation; ## --- Loading and Updating the Database @@ -169,7 +167,6 @@ $db->dom_config->set_parameter ('error-handler' => \&daf_on_error); my $parser = $impl->create_dis_parser; -my $DNi = $impl->get_feature (ExpandedURI q => '1.0'); my %ModuleSourceDISDocument; my %ModuleSourceDNLDocument; my %ModuleNameNamespaceBinding = ( @@ -183,7 +180,7 @@ $db->pl_update_module (\@target_modules, get_module_index_file_name => sub { shift; # $db - daf_get_module_index_file_name (@_); + daf_get_module_index_file_name (shift); }, get_module_source_document_from_uri => sub { my ($db, $module_uri, $module_for) = @_; @@ -199,10 +196,10 @@ } return $ModuleSourceDNLDocument{$module_uri}; }, -get_module_source_document_from_resource => sub ($$$$$$) { - my ($self, $db, $uri, $ns, $ln, $for) = @_; +get_module_source_document_from_resource => sub ($$$$$) { + my ($self, $db, $uri, $ns, $ln) = @_; status_msg ''; - status_msg qq...>; + status_msg qq; $ResourceCount = 0; my $module_uri = $ns.$ln; @@ -262,7 +259,7 @@ status_msg_ " " if ($ResourceCount % (10 * 10)) == 0; status_msg '' if ($ResourceCount % (10 * 50)) == 0; } -}); +}, implementation => $impl); status_msg ''; status_msg "done"; @@ -296,21 +293,22 @@ daf_check_undefined (); -undef $DNi; undef %ModuleSourceDNLDocument; exit $HasError if $HasError; ## --- Creating Files for (@{$Opt{create_module}}) { - my ($mod_uri, $out_file_path, $mod_for, $out_type) = @$_; + my ($mod_uri, $out_file_path, undef, $out_type) = @$_; if ($out_type eq 'perl-pm') { - daf_perl_pm ($mod_uri, $out_file_path, $mod_for); + daf_perl_pm ($mod_uri, $out_file_path); } elsif ($out_type eq 'perl-t') { - daf_perl_t ($mod_uri, $out_file_path, $mod_for); + daf_perl_t ($mod_uri, $out_file_path); } elsif ($out_type eq 'dtd-modules') { - daf_dtd_modules ($mod_uri, $out_file_path, $mod_for); + daf_dtd_modules ($mod_uri, $out_file_path); + } elsif ($out_type eq 'dtd-driver') { + daf_dtd_driver ($mod_uri, $out_file_path); } } @@ -323,7 +321,6 @@ undef $db; status_msg "done"; -undef $limpl; undef $impl; { @@ -416,7 +413,7 @@ my $dis_doc = $ModuleSourceDISDocument{$module_uri}; next M unless $dis_doc; verbose_msg_ qq...>; - my $dnl_doc = $DNi->convert_dis_document_to_dnl_document + my $dnl_doc = $impl->convert_dis_document_to_dnl_document ($dis_doc, database_arg => $db, base_namespace_binding => {(map {$_->local_name => $_->target_namespace_uri} @@ -475,7 +472,7 @@ return undef; } # dac_search_file_path_stem; -sub daf_get_module_index_file_name ($$) { +sub daf_get_module_index_file_name ($) { my ($module_uri) = @_; my $ns = $module_uri; $ns =~ s/(\w+)\z//;