source: main/trunk/greenstone2/perllib/plugouts/GreenstoneXMLPlugout.pm@ 27517

Last change on this file since 27517 was 27517, checked in by jmt12, 11 years ago

Noticed and replaced a couple of -e's (that should have been -d's anyway) with FileUtils::directoryExists()

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1###########################################################################
2#
3# GreenstoneXMLPlugout.pm -- the plugout module for Greenstone Archives
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
26package GreenstoneXMLPlugout;
27
28use strict;
29no strict 'refs';
30no strict 'subs';
31
32eval {require bytes};
33use util;
34use FileUtils;
35use BasePlugout;
36use docprint;
37
38sub BEGIN {
39 @GreenstoneXMLPlugout::ISA = ('BasePlugout');
40}
41
42my $arguments = [];
43
44my $options = { 'name' => "GreenstoneXMLPlugout",
45 'desc' => "{GreenstoneXMLPlugout.desc}",
46 'abstract' => "no",
47 'inherits' => "yes" };
48
49sub new {
50 my ($class) = shift (@_);
51 my ($plugoutlist, $inputargs,$hashArgOptLists) = @_;
52 push(@$plugoutlist, $class);
53
54 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
55 push(@{$hashArgOptLists->{"OptList"}},$options);
56
57 my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
58
59 return bless $self, $class;
60}
61
62sub saveas {
63 my $self = shift (@_);
64 my ($doc_obj,$doc_dir) = @_;
65
66 my $outhandler;
67 if ($self->{'debug'}) {
68 $outhandler = STDOUT;
69 # can we do the xslt and still do debug mode?
70 }
71 else {
72 my $output_dir = $self->get_output_dir();
73 if (!&FileUtils::directoryExists($output_dir))
74 {
75 &FileUtils::makeAllDirectories($output_dir);
76 }
77
78 my $working_dir = &FileUtils::filenameConcatenate($output_dir, $doc_dir);
79 if (!&FileUtils::directoryExists($working_dir))
80 {
81 &FileUtils::makeAllDirectories($working_dir);
82 }
83
84 $self->process_assoc_files ($doc_obj, $doc_dir, '');
85
86 $self->process_metafiles_metadata ($doc_obj);
87
88 my $output_file = &FileUtils::filenameConcatenate($working_dir, "doc.xml");
89
90 $self->open_xslt_pipe($output_file, $self->{'xslt_file'});
91
92 if (defined $self->{'xslt_writer'}){
93 $outhandler = $self->{'xslt_writer'};
94 }
95 else{
96 $outhandler = $self->get_output_handler($output_file);
97 }
98 }
99
100 binmode($outhandler,":utf8");
101
102 $self->output_xml_header($outhandler,"Archive");
103 my $section_output = &docprint::get_section_xml($doc_obj, $doc_obj->get_top_section());
104 print $outhandler $section_output;
105 $self->output_xml_footer($outhandler,"Archive");
106
107 if (!$self->{'debug'}) {
108 if (defined $self->{'xslt_writer'}){
109 $self->close_xslt_pipe();
110 }
111 else {
112 &FileUtils::closeFileHandle($output_file, \$outhandler);
113 }
114
115 $self->{'short_doc_file'} = &FileUtils::filenameConcatenate($doc_dir, "doc.xml");
116
117 $self->store_output_info_reference($doc_obj);
118 }
119}
120
121
122
1231;
124
Note: See TracBrowser for help on using the repository browser.