Ignore:
Timestamp:
2001-10-31T19:37:58+13:00 (23 years ago)
Author:
sjboddie
Message:

Created GAPlug (and XMLPlug base class) to replace the old GMLPlug.
Greenstone archives will now be stored as proper XML documents (with .xml
file extension) instead of the old .gml files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/docsave.pm

    r2267 r2810  
    2525
    2626# This document processor saves a document in the
    27 # archives directory of a collection
     27# archives directory of a collection (as xml)
    2828
    2929
     
    5353    $self->{'groupsize'} = $groupsize;
    5454    $self->{'gs_count'} = 0;
    55 
    56     # keep an associate array of all metavalues used by collection to
    57     # help generate the XML DTD
    58     $self->{'dtd_metadata'} = {};
    5955
    6056    $self->{'outhandle'} = STDERR;
     
    9389   
    9490    } else {
    95     # groupsize is 1 (i.e. one document per GML file) so sortmeta
     91    # groupsize is 1 (i.e. one document per XML file) so sortmeta
    9692    # may be used
    9793   
     
    107103   
    108104    my $doc_file
    109         = &util::filename_cat ($self->{'archive_dir'}, $doc_dir, "doc.gml");
    110     my $short_doc_file = &util::filename_cat ($doc_dir, "doc.gml");
     105        = &util::filename_cat ($self->{'archive_dir'}, $doc_dir, "doc.xml");
     106    my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml");
    111107   
    112108    if (!open (OUTDOC, ">$doc_file")) {
     
    116112
    117113    # save this document
    118     $doc_obj->output_section('docsave::OUTDOC',
    119                  $doc_obj->get_top_section(),
    120                  $self->{'collection'},
    121                  $self->{'dtd_metadata'},0);
    122 
     114    $self->output_xml_header('docsave::OUTDOC');
     115    $doc_obj->output_section('docsave::OUTDOC', $doc_obj->get_top_section());
     116    $self->output_xml_footer('docsave::OUTDOC');
    123117    close OUTDOC;
    124118
     
    172166        # only if opening new file
    173167        my $doc_file
    174         = &util::filename_cat ($self->{'archive_dir'}, $doc_dir, "doc.gml");
    175         my $short_doc_file = &util::filename_cat ($doc_dir, "doc.gml");
     168        = &util::filename_cat ($self->{'archive_dir'}, $doc_dir, "doc.xml");
     169        my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml");
    176170       
    177171        if ($gs_count>0)
     
    187181        $self->{'gs_short_filename'} = $short_doc_file;
    188182        $self->{'gs_OID'} = $OID;
     183
     184        $self->output_xml_header('docsave::OUTDOC');
    189185    }
    190186    }
    191187
    192188    # save this document
    193     $doc_obj->output_section('docsave::OUTDOC',
    194                  $doc_obj->get_top_section(),
    195                  $self->{'collection'},
    196                  $self->{'dtd_metadata'},0);
     189    $doc_obj->output_section('docsave::OUTDOC', $doc_obj->get_top_section());
    197190
    198191    $self->{'gs_count'}++;
     
    210203    # same one.
    211204    $doc_dir = $doc_info->[0];
    212     $doc_dir =~ s/\/?doc\.gml(\.gz)?$//;
     205    $doc_dir =~ s/\/?doc\.xml(\.gz)?$//;
    213206    } else {
    214207    # have to get a new document directory
     
    264257{
    265258    my ($self) = @_;
    266    
     259
     260    $self->output_xml_footer('docsave::OUTDOC');   
    267261    close OUTDOC;
    268262
     
    288282}
    289283
     284sub output_xml_header {
     285    my $self = shift (@_);
     286    my ($handle) = @_;
     287
     288    print $handle '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
     289    print $handle '<!DOCTYPE GreenstoneArchive SYSTEM ' .
     290    '"http://greenstone.org/dtd/GreenstoneArchive/1.0/GreenstoneArchive.dtd">' . "\n";
     291    print $handle '<GreenstoneArchive>' . "\n";
     292}
     293
     294sub output_xml_footer {
     295    my $self = shift (@_);
     296    my ($handle) = @_;
     297
     298    print $handle '</GreenstoneArchive>' . "\n";
     299}
     300
    2903011;
Note: See TracChangeset for help on using the changeset viewer.