Changeset 7902 for trunk/gsdl/perllib/docsave.pm
- Timestamp:
- 2004-08-06T16:34:02+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/docsave.pm
r3834 r7902 96 96 my $OID = $doc_obj->get_OID(); 97 97 $OID = "NULL" unless defined $OID; 98 98 99 99 100 # get document's directory 100 101 my $doc_dir = $self->get_doc_dir ($OID); 101 102 103 102 104 # copy all the associated files, add this information as metadata 103 105 # to the document … … 106 108 my $doc_file 107 109 = &util::filename_cat ($self->{'archive_dir'}, $doc_dir, "doc.xml"); 108 my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml"); 109 110 111 #***define doctxt.xml file 112 my $doc_txt_file 113 = &util::filename_cat ($self->{'archive_dir'}, $doc_dir,"doctxt.xml"); 114 my $working_dir 115 =&util::filename_cat ($self->{'archive_dir'}, $doc_dir); 116 117 #***define docmets.xmlfile 118 my $doc_mets_file 119 = &util::filename_cat ($self->{'archive_dir'},$doc_dir, "docmets.xml"); 120 121 my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml"); 122 #my $short_txt_doc_file=&util::filename_cat ($doc_dir, "doctxt.xml"); 123 my $short_mets_doc_file=&util::filename_cat ($doc_dir, "docmets.xml"); 124 125 110 126 if (!open (OUTDOC, ">$doc_file")) { 111 print $outhandle "docsave::process could not write to file $doc_file\n";127 print $outhandle "docsave::process could not write to file $doc_file\n"; 112 128 return; 113 129 } … … 117 133 $doc_obj->output_section('docsave::OUTDOC', $doc_obj->get_top_section()); 118 134 $self->output_xml_footer('docsave::OUTDOC'); 119 close OUTDOC; 135 136 #***save the document without metadata:doctxt.xml: Chi-Yu Huang 137 138 if (!open(OUTDOC_TXT, ">$doc_txt_file")){ 139 print $outhandle "docsave::process could not write to file $doc_mets_file\n"; 140 return; 141 } 142 143 $self->output_txt_xml_header('docsave::OUTDOC_TXT'); 144 $doc_obj->output_txt_section('docsave::OUTDOC_TXT', $doc_obj->get_top_section()); 145 #$self->output_txt_xml_footer('docsave::OUTDOC_TXT'); 146 147 #***Convert doctxt.xml file to docmets.xml: Chi-Yu Huang 148 if (!open(OUTDOC_METS,">$doc_mets_file")){ 149 print $outhandle "docsave::process could not write to file $doc_mets_file\n"; 150 return; 151 } 152 153 $self->output_mets_xml_header('docsave::OUTDOC_METS', $OID); 154 $doc_obj->output_mets_section('docsave::OUTDOC_METS',$doc_obj->get_top_section(), $working_dir); 155 $self->output_mets_xml_footer('docsave::OUTDOC_METS'); 156 157 close OUTDOC; 158 close OUTDOC_TXT; 159 close OUTDOC_METS; 120 160 121 161 if ($self->{'gzip'}) { … … 131 171 132 172 # do the sortmeta thing 133 my ($metadata); 134 if (defined ($self->{'sortmeta'})) { 173 my ($metadata); if (defined ($self->{'sortmeta'})) { 135 174 $metadata = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'sortmeta'}); 136 175 } 137 176 138 177 # store reference in the archive_info 139 $self->{'archive_info'}->add_info($OID, $short_doc_file, $metadata); 140 } 141 } 142 178 if ($self->{'saveas'} eq "METS"){ 179 $self->{'archive_info'}->add_info($OID, $short_mets_doc_file, $metadata); 180 } else { 181 $self->{'archive_info'}->add_info($OID, $short_doc_file, $metadata); 182 } 183 } 184 } 185 186 143 187 sub group_process { 144 188 my $self = shift (@_); … … 283 327 284 328 # store reference in the archive_info 285 $self->{'archive_info'}->add_info($OID, $short_doc_file); 286 329 if ($self->{'saveas'} eq "METS"){ 330 $self->{'archive_info'}->add_info($OID, $short_mets_doc_file); 331 } else { 332 $self->{'archive_info'}->add_info($OID, $short_doc_file); 333 } 334 287 335 return 1; 288 336 } … … 292 340 my ($handle) = @_; 293 341 342 print $handle '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n"; 343 344 print $handle '<!DOCTYPE Archive SYSTEM "http://greenstone.org/dtd/Archive/1.0/Archive.dtd">' . "\n"; 345 print $handle "<Archive>\n"; 346 } 347 348 sub output_xml_footer { 349 my $self = shift (@_); 350 my ($handle) = @_; 351 352 print $handle "</Archive>\n"; 353 } 354 355 sub output_txt_xml_header{ 356 my $self = shift (@_); 357 my ($handle) = @_; 294 358 print $handle '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n"; 295 359 print $handle '<!DOCTYPE Archive SYSTEM "http://greenstone.org/dtd/Archive/1.0/Archive.dtd">' . "\n"; 296 print $handle "<Archive>\n"; 297 } 298 299 sub output_xml_footer { 300 my $self = shift (@_); 301 my ($handle) = @_; 302 303 print $handle "</Archive>\n"; 360 } 361 362 sub output_txt_xml_footer{ 363 my $self = shift(@_); 364 my ($handle) = @_; 365 print $handle "<the end of the file>\n"; 366 } 367 368 sub output_mets_xml_header(){ 369 my $self = shift(@_); 370 my ($handle, $OID) = @_; 371 print $handle '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n"; 372 print $handle '<!DOCTYPE Archive SYSTEM "http://greenstone.org/dtd/Archive/1.0/Archive.dtd">' . "\n"; 373 print $handle '<mets:mets OBJID="'. $OID. ':2">' . "\n"; 374 } 375 376 sub output_mets_xml_footer() { 377 my $self = shift(@_); 378 my ($handle) = @_; 379 print $handle '</mets:mets>' . "\n"; 304 380 } 305 381 306 382 1; 383 384 385
Note:
See TracChangeset
for help on using the changeset viewer.