- Timestamp:
- 2013-11-28T15:28:43+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugouts/MARCXMLPlugout.pm
r28562 r28706 28 28 use strict; 29 29 no strict 'refs'; 30 no strict 'subs'; # allow barewords (eg STDERR) as function arguments 30 31 31 32 eval {require bytes}; … … 44 45 'desc' => "{MARCXMLPlugout.group}", 45 46 'type' => "flag", 46 'deft' => "0",47 47 'reqd' => "no", 48 48 'hiddengli' => "no"}, … … 51 51 'type' => "string", 52 52 'deft' => "dc2marc-mapping.xml", 53 'reqd' => " yes",53 'reqd' => "no", 54 54 'hiddengli' => "no"}, 55 55 { 'name' => "xslt_file", … … 81 81 $self->{'buffered_output'} =""; 82 82 83 # xslt_file is checked in BasePlugout 84 # check the mapping file here 83 85 my $full_path_to_mapping_file = &util::locate_config_file($self->{'mapping_file'}); 84 86 if (! defined $full_path_to_mapping_file) { 85 print STDERR "Can not find $self->{'mapping_file'}, please make sure you have supplied the correct file path\n";87 print STDERR "Can not find mapping file $self->{'mapping_file'}, please make sure you have supplied the correct file path or put the file into the collection's etc or greenstone's etc folder\n"; 86 88 die "\n"; 87 89 } 88 90 $self->{'mapping_file'} = $full_path_to_mapping_file; 89 91 90 return bless $self, $class;92 return bless $self, $class; 91 93 } 92 94 93 sub saveas { 95 sub begin { 96 97 my $self= shift (@_); 98 if ($self->{'group'}) { 99 # all output goes into this file 100 my $output_dir = $self->get_output_dir(); 101 &FileUtils::makeAllDirectories ($output_dir) unless -e $output_dir; 102 103 $self->{'short_doc_file'} = "marc.xml"; 104 } 105 } 106 # override BasePlugout process 107 sub process { 94 108 my $self = shift (@_); 95 my ($doc_obj ,$doc_dir) = @_;109 my ($doc_obj) = @_; 96 110 97 111 my $output_info = $self->{'output_info'}; 112 return if (!defined $output_info); 113 114 $self->process_metafiles_metadata ($doc_obj); 115 98 116 if ($self->{'group'}){ 99 117 $self->{buffered_output} .= $self->get_top_metadata_list($doc_obj)."\n"; 100 return;101 118 } 102 103 $self->process_metafiles_metadata ($doc_obj); 119 else { 120 # find out which directory to save to 121 my $doc_dir = $self->get_doc_dir($doc_obj); 122 my $output_file = &FileUtils::filenameConcatenate ($self->get_output_dir(), $doc_dir, "marc.xml"); 123 $self->open_xslt_pipe($output_file,$self->{'xslt_file'}); 124 125 my $outhandler = $self->{'xslt_writer'}; 126 $self->output_xml_header($outhandler, "MARCXML", 1); 127 print $outhandler $self->get_top_metadata_list($doc_obj); 128 $self->output_xml_footer($outhandler,"MARCXML"); 129 $self->close_xslt_pipe(); 130 $self->{'short_doc_file'} = &FileUtils::filenameConcatenate ($doc_dir, "marc.xml"); 131 } 104 132 105 my $output_dir = $self->get_output_dir();106 &FileUtils::makeAllDirectories ($output_dir) unless -e $output_dir;107 108 my $working_dir = &FileUtils::filenameConcatenate ($output_dir, $doc_dir);109 &FileUtils::makeAllDirectories ($working_dir) unless -e $working_dir;110 133 111 my $output_file = &FileUtils::filenameConcatenate ($working_dir, "marc.xml"); 112 113 $self->open_xslt_pipe($output_file,$self->{'xslt_file'}); 134 # write out data to archiveinf-doc.db 135 if ($self->{'generate_databases'}) { 136 $self->store_output_info_reference($doc_obj); 137 $self->archiveinf_db($doc_obj); 138 } 139 if ($self->{'group'}){ 140 $self->{'gs_count'}++; 141 $self->{'group_position'}++; 142 } 143 } 114 144 115 my $outhandler = $self->{'xslt_writer'};116 117 $self->output_xml_header($outhandler, "MARCXML", 1);118 print $outhandler $self->get_top_metadata_list($doc_obj);119 $self->output_xml_footer($outhandler,"MARCXML");120 $self->close_xslt_pipe();121 122 $self->{'short_doc_file'} = &FileUtils::filenameConcatenate ($doc_dir, "marc.xml");123 124 $self->store_output_info_reference($doc_obj);125 }126 145 127 146 # returns a xml element of the form <MetadataList><Metadata name="metadata-name">metadata_value</Metadata>...</MetadataList> … … 154 173 return unless $self->{'group'} and $self->{buffered_output}; 155 174 156 my $output_dir = $self->get_output_dir(); 157 &FileUtils::makeAllDirectories ($output_dir) unless -e $output_dir; 175 my $output_file = &FileUtils::filenameConcatenate($self->get_output_dir(), $self->{'short_doc_file'}); 158 176 159 my $output_file = &FileUtils::filenameConcatenate($output_dir, "marc.xml");160 161 177 $self->open_xslt_pipe($output_file,$self->{'xslt_file'}); 162 178 … … 175 191 } 176 192 193 177 194 1;
Note:
See TracChangeset
for help on using the changeset viewer.