[12330] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
[17743] | 3 | # GreenstoneXMLPlugout.pm -- the plugout module for Greenstone Archives
|
---|
[12330] | 4 | # A component of the Greenstone digital library software
|
---|
| 5 | # from the New Zealand Digital Library Project at the
|
---|
| 6 | # University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 2006 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, write to the Free Software
|
---|
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###########################################################################
|
---|
| 25 |
|
---|
[17743] | 26 | package GreenstoneXMLPlugout;
|
---|
[12330] | 27 |
|
---|
| 28 | use strict;
|
---|
| 29 | no strict 'refs';
|
---|
[13172] | 30 | no strict 'subs';
|
---|
[12330] | 31 |
|
---|
| 32 | eval {require bytes};
|
---|
| 33 | use util;
|
---|
[17203] | 34 | use BasePlugout;
|
---|
[13172] | 35 | use docprint;
|
---|
[12330] | 36 |
|
---|
| 37 | sub BEGIN {
|
---|
[17743] | 38 | @GreenstoneXMLPlugout::ISA = ('BasePlugout');
|
---|
[12330] | 39 | }
|
---|
| 40 |
|
---|
| 41 | my $arguments = [];
|
---|
| 42 |
|
---|
[17743] | 43 | my $options = { 'name' => "GreenstoneXMLPlugout",
|
---|
| 44 | 'desc' => "{GreenstoneXMLPlugout.desc}",
|
---|
[12330] | 45 | 'abstract' => "no",
|
---|
| 46 | 'inherits' => "yes" };
|
---|
| 47 |
|
---|
| 48 | sub new {
|
---|
| 49 | my ($class) = shift (@_);
|
---|
| 50 | my ($plugoutlist, $inputargs,$hashArgOptLists) = @_;
|
---|
| 51 | push(@$plugoutlist, $class);
|
---|
| 52 |
|
---|
[17203] | 53 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 54 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[12330] | 55 |
|
---|
[17203] | 56 | my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
|
---|
[12330] | 57 |
|
---|
[17203] | 58 | return bless $self, $class;
|
---|
[12330] | 59 | }
|
---|
| 60 |
|
---|
| 61 | sub saveas {
|
---|
| 62 | my $self = shift (@_);
|
---|
| 63 | my ($doc_obj,$doc_dir) = @_;
|
---|
| 64 |
|
---|
[13172] | 65 | my $outhandler;
|
---|
| 66 | if ($self->{'debug'}) {
|
---|
| 67 | $outhandler = STDOUT;
|
---|
| 68 | # can we do the xslt and still do debug mode?
|
---|
| 69 | }
|
---|
| 70 | else {
|
---|
| 71 | my $output_dir = $self->get_output_dir();
|
---|
| 72 | &util::mk_all_dir ($output_dir) unless -e $output_dir;
|
---|
| 73 |
|
---|
| 74 | my $working_dir = &util::filename_cat ($output_dir, $doc_dir);
|
---|
| 75 | &util::mk_all_dir ($working_dir) unless -e $working_dir;
|
---|
| 76 |
|
---|
| 77 | $self->process_assoc_files ($doc_obj, $doc_dir, '');
|
---|
| 78 |
|
---|
[19494] | 79 | $self->process_metafiles_metadata ($doc_obj);
|
---|
| 80 |
|
---|
[13172] | 81 | my $output_file = util::filename_cat ($working_dir, "doc.xml");
|
---|
| 82 |
|
---|
| 83 | $self->open_xslt_pipe($output_file, $self->{'xslt_file'});
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | if (defined $self->{'xslt_writer'}){
|
---|
| 87 | $outhandler = $self->{'xslt_writer'};
|
---|
| 88 | }
|
---|
| 89 | else{
|
---|
| 90 | $outhandler = $self->get_output_handler($output_file);
|
---|
| 91 | }
|
---|
[12330] | 92 | }
|
---|
[13172] | 93 |
|
---|
[12330] | 94 | $self->output_xml_header($outhandler,"Archive");
|
---|
[13172] | 95 | my $section_output = &docprint::get_section_xml($doc_obj, $doc_obj->get_top_section());
|
---|
| 96 | print $outhandler $section_output;
|
---|
[12330] | 97 | $self->output_xml_footer($outhandler,"Archive");
|
---|
| 98 |
|
---|
[13172] | 99 | if (!$self->{'debug'}) {
|
---|
| 100 | if (defined $self->{'xslt_writer'}){
|
---|
| 101 | $self->close_xslt_pipe();
|
---|
| 102 | }
|
---|
| 103 | else {
|
---|
| 104 | close($outhandler);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | $self->{'short_doc_file'} = util::filename_cat ($doc_dir, "doc.xml");
|
---|
| 108 |
|
---|
| 109 | $self->store_output_info_reference($doc_obj);
|
---|
[12330] | 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[13172] | 113 |
|
---|
| 114 |
|
---|
[12330] | 115 | 1;
|
---|
| 116 |
|
---|