Changeset 8504
- Timestamp:
- 2004-11-10T11:14:18+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r8502 r8504 286 286 287 287 288 my $filePath = $doc_Dir . '/doctxt.xml'; 289 288 #my $filePath = $doc_Dir . '/doctxt.xml'; 289 290 my $filePath = 'doctxt.xml'; 291 290 292 #**output the fileSection details 291 293 my $all_text = ' <mets:fileGrp ID="FILEGROUP_PRELUDE' . $section_num . '">'. "\n"; … … 331 333 my $escaped_value = &_escape_text($data->[1]); 332 334 if ($data->[0] eq "gsdlsourcefilename") { 333 ($dirPath) = $escaped_value =~ m/^(.*)[\/\\][^\/\\]*$/; 334 335 ($dirPath) = $escaped_value =~ m/^(.*)[\/\\][^\/\\]*$/; 336 335 337 $all_text .= ' <mets:fileGrp ID="default">'."\n"; 336 338 ++$fileID; 337 339 $all_text .= ' <mets:file MIMETYPE="text/xml" ID="default.'.$fileID.'">'. "\n"; 338 $all_text .= ' <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$data->[1].'" ID="default.'.$fileID.'" />'."\n"; 339 340 341 $all_text .= ' <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$data->[1].'" ID="default.'.$fileID.'" />'."\n"; 342 340 343 $all_text .= " </mets:file>\n"; 341 344 } … … 346 349 my $assfilePath = $dirPath . '/'. $1; 347 350 ++$fileID; 351 348 352 $all_text .= ' <mets:file MIMETYPE="'.$2.'" ID="default.'.$fileID. '">'. "\n"; 349 353 $all_text .= ' <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$assfilePath.'" ID="default.'. $fileID.'" />'."\n"; … … 366 370 $section="" unless defined $section; 367 371 368 372 369 373 my $section_ptr=$self->_lookup_section($section); 370 374 return "" unless defined $section_ptr; 371 375 372 #**output fileSection by sections 373 my $section_num ="1". $section; 374 376 377 #***output fileSection by Sections 378 my $section_num ="1". $section; 379 my $dmd_num = $section_num; 380 381 #**output the dmdSection details 382 if ($section_num eq "1") { 383 $dmd_num = "0"; 384 } 385 375 386 #**output the StruMap details 376 387 377 388 my $all_text = ' <mets:div ID="DS'. $section_num .'" TYPE="Section" ORDER="'.$$order_numref++.'" ORDERLABEL="'. $section_num .'" LABEL="'; 378 $all_text .= $section_num . '" DMDID="DM'.$section_num.'">'. "\n"; 389 390 $all_text .= $section_num . '" DMDID="DM'.$dmd_num.'">'. "\n"; 379 391 380 392 $all_text .= ' <mets:fptr FILEID="FILEGROUP_PRELUDE'.$section_num.'" />'. "\n"; … … 442 454 #***convert section number 443 455 my $section_num ="1". $section; 444 456 my $dmd_num = $section_num; 457 445 458 #**output the dmdSection details 446 my $all_text = '<mets:dmdSec ID="DM'.$section_num.'" GROUPID="'.$section_num.'">'. "\n"; 447 $all_text .= ' <mets:mdWrap MDType="gsdl" ID="'.$section_num.'">'."\n"; 459 if ($section_num eq "1") { 460 $dmd_num = "0"; 461 } 462 my $all_text = '<mets:dmdSec ID="DM'.$dmd_num.'" GROUPID="'.$section_num.'">'. "\n"; 463 $all_text .= ' <mets:mdWrap MDType="gsdl3" ID="'.$section_num.'">'."\n"; 448 464 $all_text .= " <mets:xmlData>\n"; 449 465 foreach my $data (@{$section_ptr->{'metadata'}}){ 450 466 my $escaped_value = &_escape_text($data->[1]); 451 $all_text .= ' <gsdl:Metadata name="'. $data->[0].'">'. $escaped_value. "</gsdl:Metadata>\n"; 452 } 467 $all_text .= ' <gsdl3:Metadata name="'. $data->[0].'">'. $escaped_value. "</gsdl3:Metadata>\n"; 468 if ($data->[0] eq "dc.Title") { 469 $all_text .= ' <gsdl3:Metadata name="Title">'. $escaped_value."</gsdl3:Metadata>\n"; 470 } 471 } 472 453 473 $all_text .= " </mets:xmlData>\n"; 454 474 $all_text .= " </mets:mdWrap>\n"; … … 471 491 } 472 492 493 #*** print out DSpace dublin_core metadata section 494 sub output_dspace_section { 495 my $self = shift (@_); 496 my ($handle, $section) = @_; 497 498 my $section_ptr = $self->_lookup_section ($section); 499 return "" unless defined $section_ptr; 500 501 my $all_text = "<Section>\n"; 502 $all_text .= " <Description>\n"; 503 504 # output metadata 505 foreach my $data (@{$section_ptr->{'metadata'}}) { 506 my $escaped_value = &_escape_text($data->[1]); 507 $all_text .= ' <Metadata name="' . $data->[0] . '">' . $escaped_value . "</Metadata>\n"; 508 } 509 510 $all_text .= " </Description>\n"; 511 $all_text .= "</Section>\n"; 512 513 # make sure no nasty control characters have snuck through 514 # (XML::Parser will barf on anything it doesn't consider to be 515 # valid UTF-8 text, including things like \c@, \cC etc.) 516 $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g; 517 518 return $all_text; 519 } 473 520 474 521 #*** print out doctxt.xml file … … 491 538 print $handle "<mets:fileSec>\n"; 492 539 print $handle $self->buffer_mets_fileSection_section_xml($section,$doc_Dir); 540 493 541 #***print out the whole fileSection 494 542 print $handle $self->buffer_mets_fileWhole_section_xml($section); … … 504 552 } 505 553 554 #*** print out dublin_core.xml file 555 sub output_dc_section { 556 my $self = shift(@_); 557 my ($handle, $section, $doc_Dir) = @_; 558 559 #***print out the dublin_core 560 $section="" unless defined $section; 561 562 my $section_ptr=$self->_lookup_section($section); 563 return "" unless defined $section_ptr; 564 my $all_text=""; 565 foreach my $data (@{$section_ptr->{'metadata'}}){ 566 my $escaped_value = &_escape_text($data->[1]); 567 if ($data->[0]=~ /^dc/) { 568 #$all_text .= ' <dcvalue element="'. $data->[0].'" qualifier="#####">'. $escaped_value. "</dcvalue>\n"; 569 $all_text .= ' <dcvalue element="'. $data->[0].'">'. $escaped_value. "</dcvalue>\n"; 570 } 571 } 572 if ($all_text eq "") { 573 $all_text .= " There is no Dublin Core metatdata in this document\n"; 574 } 575 $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g; 576 577 print $handle $all_text; 578 } 506 579 507 580 # look up the reference to the a particular section … … 537 610 my $hashfile_exe = &util::filename_cat($ENV{'GSDLHOME'},"bin", 538 611 $ENV{'GSDLOS'},"hashfile$osexe"); 612 539 613 my $result = "NULL"; 540 614 … … 547 621 print STDERR "doc::_calc_OID $hashfile_exe could not be found\n"; 548 622 } 549 550 623 return "HASH$result"; 551 624 } … … 557 630 my $self = shift (@_); 558 631 my ($OID) = @_; 559 632 560 633 # if an OID wasn't provided claculate one 561 634 if (!defined $OID) { … … 572 645 # cos its quicker 573 646 my $filename = $self->get_filename_for_hashing(); 647 574 648 if (defined($filename) && -e $filename) { 575 649 $OID = $self->_calc_OID ($filename); … … 583 657 close (OUTFILE); 584 658 } 585 586 659 $OID = $self->_calc_OID ($filename); 587 660 &util::rm ($filename); … … 1188 1261 # remove all associated files with the same name 1189 1262 $self->delete_assoc_file ($assoc_filename); 1190 1263 1191 1264 push (@{$self->{'associated_files'}}, 1192 1265 [$real_filename, $assoc_filename, $mime_type, $section]);
Note:
See TracChangeset
for help on using the changeset viewer.