[10549] | 1 |
|
---|
[8511] | 2 | ###########################################################################
|
---|
| 3 | #
|
---|
[15872] | 4 | # DSpacePlugin.pm -- plugin for importing a collection from DSpace
|
---|
[8511] | 5 | #
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
[15872] | 10 | # Copyright (C) 2004 New Zealand Digital Library Project
|
---|
[8511] | 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
| 27 |
|
---|
[15872] | 28 |
|
---|
[8511] | 29 | # This plugin takes "contents" and dublin_core.xml file, which contain
|
---|
| 30 | # Metadata and lists of associated files for a particular document
|
---|
| 31 | # and produces a document containing sections, one for each page.
|
---|
| 32 | # The files should be named "contents" and "dublin_core.xml". For each of
|
---|
| 33 | # document in DSpace, it is stored in one directory
|
---|
| 34 | #
|
---|
| 35 | # The format of the "contents" file is as follows:
|
---|
| 36 | #
|
---|
| 37 | # File.type bundle:ORIGINAL
|
---|
| 38 | # license.txt bundle:LICENSE
|
---|
| 39 | # The format of the "dublin_core.xml" file is as follows:
|
---|
| 40 | # The first line contains any metadata for the whole document
|
---|
| 41 | # <dublin_core>
|
---|
| 42 | # eg.
|
---|
| 43 | # <dcvalue element="Title" qualifier="">Snail farming</dcvalue>
|
---|
| 44 | # <dcvalue element="date" qualifier="">2004-10-15</dcvalue>
|
---|
| 45 | #
|
---|
| 46 |
|
---|
[15872] | 47 | package DSpacePlugin;
|
---|
[8511] | 48 |
|
---|
[24951] | 49 | use extrametautil;
|
---|
[19746] | 50 | use ReadTextFile;
|
---|
[8511] | 51 | use plugin;
|
---|
| 52 | use XMLParser;
|
---|
[10254] | 53 | use strict;
|
---|
| 54 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[8511] | 55 |
|
---|
| 56 | sub BEGIN {
|
---|
[19746] | 57 | @DSpacePlugin::ISA = ('ReadTextFile');
|
---|
[8511] | 58 | }
|
---|
| 59 |
|
---|
| 60 | my $arguments =
|
---|
| 61 | [ { 'name' => "process_exp",
|
---|
[15872] | 62 | 'desc' => "{BasePlugin.process_exp}",
|
---|
[8511] | 63 | 'type' => "string",
|
---|
| 64 | 'deft' => &get_default_process_exp(),
|
---|
| 65 | 'reqd' => "no" },
|
---|
| 66 | { 'name' => "only_first_doc",
|
---|
[15872] | 67 | 'desc' => "{DSpacePlugin.only_first_doc}",
|
---|
[8511] | 68 | 'type' => "flag",
|
---|
| 69 | 'reqd' => "no" },
|
---|
[9168] | 70 | { 'name' => "first_inorder_ext",
|
---|
[15872] | 71 | 'desc' => "{DSpacePlugin.first_inorder_ext}",
|
---|
[8891] | 72 | 'type' => "string",
|
---|
[8511] | 73 | 'reqd' => "no" },
|
---|
| 74 | { 'name' => "first_inorder_mime",
|
---|
[15872] | 75 | 'desc' => "{DSpacePlugin.first_inorder_mime}",
|
---|
[8511] | 76 | 'type' => "flag",
|
---|
| 77 | 'reqd' => "no" },
|
---|
| 78 | { 'name' => "block_exp",
|
---|
[15872] | 79 | 'desc' => "{BasePlugin.block_exp}",
|
---|
[8891] | 80 | 'type' => "regexp",
|
---|
[8511] | 81 | 'deft' => &get_default_block_exp(),
|
---|
| 82 | 'reqd' => "no" }];
|
---|
| 83 |
|
---|
| 84 |
|
---|
[15872] | 85 | my $options = { 'name' => "DSpacePlugin",
|
---|
| 86 | 'desc' => "{DSpacePlugin.desc}",
|
---|
[8511] | 87 | 'inherits' => "yes",
|
---|
[11676] | 88 | 'abstract' => "no",
|
---|
[8511] | 89 | 'args' => $arguments };
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | my $primary_doc_lookup = { 'text/html' => '(?i)\.(gif|jpe?g|jpe|jpg|png|css)$' };
|
---|
| 93 |
|
---|
[8913] | 94 | # Important variation to regular plugin structure. Need to declare
|
---|
| 95 | # $self as global variable to file so XMLParser callback routines
|
---|
| 96 | # can access the content of the object.
|
---|
| 97 | my ($self);
|
---|
| 98 |
|
---|
[8511] | 99 | sub new {
|
---|
[10218] | 100 | my ($class) = shift (@_);
|
---|
| 101 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 102 | push(@$pluginlist, $class);
|
---|
[8511] | 103 |
|
---|
[15872] | 104 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 105 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[8511] | 106 |
|
---|
[19746] | 107 | $self = new ReadTextFile($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[8511] | 108 |
|
---|
[15872] | 109 | if ($self->{'info_only'}) {
|
---|
| 110 | # don't worry about creating the XML parser as all we want is the
|
---|
| 111 | # list of plugin options
|
---|
| 112 | return bless $self, $class;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[8511] | 115 | #create XML::Parser object for parsing dublin_core.xml files
|
---|
| 116 | my $parser = new XML::Parser('Style' => 'Stream',
|
---|
| 117 | 'Handlers' => {'Char' => \&Char,
|
---|
| 118 | 'Doctype' => \&Doctype
|
---|
| 119 | });
|
---|
| 120 | $self->{'parser'} = $parser;
|
---|
| 121 | $self->{'extra_blocks'} = {};
|
---|
| 122 |
|
---|
| 123 | return bless $self, $class;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | sub get_default_process_exp {
|
---|
| 127 | my $self = shift (@_);
|
---|
| 128 |
|
---|
[19746] | 129 | return q^(?i)(contents)$^;
|
---|
[8511] | 130 | }
|
---|
| 131 |
|
---|
| 132 | # want to block all files except the "contents"
|
---|
| 133 | sub get_default_block_exp {
|
---|
| 134 | my $self = shift (@_);
|
---|
| 135 |
|
---|
[19746] | 136 | # Block handle and txt files if present. Specifically don't block dublin_core xml
|
---|
| 137 | return q^(?i)(handle|\.tx?t)$^;
|
---|
[8511] | 138 | }
|
---|
| 139 |
|
---|
[19746] | 140 | sub store_block_files_BACKUP
|
---|
| 141 | {
|
---|
| 142 | # Option of making blocking sensitive to files that are in directory
|
---|
| 143 | # This subroutine is not currently used! (relies on default block expression stopping all handle and .txt files)
|
---|
| 144 |
|
---|
| 145 | my $self =shift (@_);
|
---|
| 146 | my ($filename_full_path, $block_hash) = @_;
|
---|
| 147 |
|
---|
| 148 | my ($tailname, $contents_basedir, $suffix) = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$");
|
---|
| 149 | my $handle_filename = &util::filename_cat($contents_basedir,"handle");
|
---|
| 150 |
|
---|
[23419] | 151 | if (&util::fd_exists($handle_filename)) {
|
---|
[23561] | 152 | &util::block_filename($block_hash,$handle_filename);
|
---|
[23419] | 153 | }
|
---|
[19746] | 154 | }
|
---|
| 155 |
|
---|
[8511] | 156 | sub read_content
|
---|
| 157 | {
|
---|
| 158 | my $self = shift (@_);
|
---|
| 159 | my ($dir, $only_first_doc, $first_inorder_ext, $first_inorder_mime, $mimetype_list) = @_;
|
---|
| 160 | my $outhandle = $self->{'outhandle'};
|
---|
| 161 |
|
---|
| 162 | my @fnamemime_list = ();
|
---|
| 163 | my @assocmime_list = ();
|
---|
| 164 |
|
---|
| 165 | my $content_fname = &util::filename_cat($dir,"contents");
|
---|
| 166 |
|
---|
| 167 | open(CIN,"<$content_fname")
|
---|
| 168 | || die "Unable to open $content_fname: $!\n";
|
---|
| 169 |
|
---|
| 170 | my $line;
|
---|
| 171 | my $pos = 0;
|
---|
| 172 |
|
---|
| 173 | while (defined ($line = <CIN>)) {
|
---|
| 174 | if ($line =~ m/^(.*)\s+bundle:ORIGINAL\s*$/) {
|
---|
| 175 | my $fname = $1;
|
---|
| 176 | my $mtype = $mimetype_list->[$pos];
|
---|
| 177 | my $fm_rec = { 'file' => $fname, 'mimetype' => $mtype};
|
---|
| 178 | push(@fnamemime_list,$fm_rec);
|
---|
| 179 | $pos++;
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 | close CIN;
|
---|
| 183 |
|
---|
| 184 | if ($only_first_doc){
|
---|
| 185 | my ($first_fname, @rest_fnames) = @fnamemime_list;
|
---|
| 186 | @fnamemime_list = ($first_fname);
|
---|
| 187 | @assocmime_list = @rest_fnames;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | # allow user to specify the types of files (inorder)they would like to assign as
|
---|
| 191 | # a primary bitstream
|
---|
| 192 | if ($first_inorder_ext) {
|
---|
| 193 | # parse user-define file extension names
|
---|
| 194 | my @extfiles_list = split /,/, $first_inorder_ext;
|
---|
| 195 | my (@rest_fnames) = @fnamemime_list;
|
---|
| 196 | my @matched_list = ();
|
---|
| 197 | foreach my $file_ext (@extfiles_list) {
|
---|
| 198 | $pos = 0;
|
---|
| 199 | foreach my $allfiles (@fnamemime_list){
|
---|
| 200 | $allfiles->{'file'} =~ /^(.*)\.(.*?)$/;
|
---|
| 201 | my $allfiles_ext = $2;
|
---|
| 202 |
|
---|
| 203 | if ($allfiles_ext =~ /$file_ext/) {
|
---|
| 204 | print $outhandle "Existing file:$allfiles->{'file'} match the user-define File Extension:$file_ext\n";
|
---|
| 205 | push (@matched_list, $allfiles);
|
---|
| 206 |
|
---|
| 207 | # delete the matched extension file from the array
|
---|
| 208 | splice(@rest_fnames,$pos,1);
|
---|
| 209 |
|
---|
| 210 | return (\@matched_list, \@rest_fnames);
|
---|
| 211 |
|
---|
| 212 | }
|
---|
| 213 | $pos++;
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | if ($first_inorder_mime) {
|
---|
| 219 | # parse user-define file mimetype
|
---|
| 220 | my @file_mime_list = split /,/, $first_inorder_mime;
|
---|
| 221 | my (@rest_fnames) = @fnamemime_list;
|
---|
| 222 | my @matched_list = ();
|
---|
| 223 | foreach my $file_mime (@file_mime_list) {
|
---|
| 224 | $pos = 0;
|
---|
| 225 | foreach my $allfiles (@fnamemime_list){
|
---|
| 226 | my $allfiles_mime = $allfiles->{'mimetype'};
|
---|
| 227 |
|
---|
| 228 | if ($allfiles_mime =~ /$file_mime/) {
|
---|
| 229 | print $outhandle "Existing file:$allfiles->{'file'} match the user-defined File MimeType:$file_mime\n";
|
---|
| 230 | push (@matched_list, $allfiles);
|
---|
| 231 |
|
---|
| 232 | # delete the matched MIMEType file from the array
|
---|
| 233 | splice(@rest_fnames,$pos,1);
|
---|
| 234 | return (\@matched_list, \@rest_fnames);
|
---|
| 235 | }
|
---|
| 236 | $pos++;
|
---|
| 237 | }
|
---|
| 238 | }
|
---|
| 239 | }
|
---|
| 240 | return (\@fnamemime_list, \@assocmime_list);
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 |
|
---|
| 244 | sub filemime_list_to_re
|
---|
| 245 | {
|
---|
| 246 | my $self = shift (@_);
|
---|
| 247 | my ($fnamemime_list) = @_;
|
---|
| 248 |
|
---|
| 249 | my @fname_list = map { "(".$_->{'file'}.")" } @$fnamemime_list;
|
---|
| 250 | my $fname_re = join("|",@fname_list);
|
---|
| 251 | $fname_re =~ s/\./\\\./g;
|
---|
| 252 |
|
---|
| 253 | return $fname_re;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | # Read dublin_core metadata from DSpace collection
|
---|
| 257 | sub metadata_read {
|
---|
| 258 | my $self = shift (@_);
|
---|
[19493] | 259 | my ($pluginfo, $base_dir, $file, $block_hash,
|
---|
| 260 | $extrametakeys, $extrametadata, $extrametafile,
|
---|
[23212] | 261 | $processor, $gli, $aux) = @_;
|
---|
[8511] | 262 |
|
---|
| 263 | my $only_first_doc = $self->{'only_first_doc'};
|
---|
| 264 | my $first_inorder_ext = $self->{'first_inorder_ext'};
|
---|
| 265 | my $first_inorder_mime = $self->{'first_inorder_mime'};
|
---|
| 266 |
|
---|
| 267 | my $outhandle = $self->{'outhandle'};
|
---|
| 268 |
|
---|
| 269 | my $filename = &util::filename_cat($base_dir, $file);
|
---|
| 270 | # return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/;
|
---|
| 271 |
|
---|
| 272 | if ($filename !~ /dublin_core\.xml$/ || !-f $filename) {
|
---|
| 273 | return undef;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[15872] | 276 | print $outhandle "DSpacePlugin: extracting metadata from $file\n"
|
---|
[8511] | 277 | if $self->{'verbosity'} > 1;
|
---|
| 278 |
|
---|
| 279 | my ($dir) = $filename =~ /^(.*?)[^\/\\]*$/;
|
---|
| 280 |
|
---|
| 281 | eval {
|
---|
| 282 | $self->{'parser'}->parsefile($filename);
|
---|
| 283 | };
|
---|
| 284 |
|
---|
| 285 | if ($@) {
|
---|
[15872] | 286 | die "DSpacePlugin: ERROR $filename is not a well formed dublin_core.xml file ($@)\n";
|
---|
[8511] | 287 | }
|
---|
| 288 |
|
---|
[24306] | 289 | my $mimetype_list = $self->{'saved_metadata'}->{'ex.dc.Format^mimetype'};
|
---|
[8511] | 290 | my ($doc_file_mimes, $assoc_file_mimes) = $self->read_content($dir, $only_first_doc, $first_inorder_ext,
|
---|
| 291 | $first_inorder_mime, $mimetype_list);
|
---|
[8913] | 292 |
|
---|
[8511] | 293 | my $file_re = $self->filemime_list_to_re($doc_file_mimes);
|
---|
| 294 |
|
---|
| 295 | if ($only_first_doc || $first_inorder_ext || $first_inorder_mime) {
|
---|
| 296 | foreach my $afm ( @$assoc_file_mimes ) {
|
---|
| 297 | my $full_af = &util::filename_cat($dir,$afm->{'file'});
|
---|
| 298 | $self->{'extra_blocks'}->{$full_af} = 1;
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
[24951] | 301 | &extrametautil::addmetakey($extrametakeys, $file_re);
|
---|
[8511] | 302 |
|
---|
[24355] | 303 | # See Format's Extent section in http://dublincore.org/documents/usageguide/qualifiers.shtml
|
---|
| 304 | # it could specify duration, size or even dimensions of the resource. It may be a useful piece
|
---|
| 305 | # of metadata to preserve after all.
|
---|
| 306 | #if (defined $self->{'saved_metadata'}->{'ex.dc.Format^extent'}) {
|
---|
| 307 | #delete $self->{'saved_metadata'}->{'ex.dc.Format^extent'};
|
---|
| 308 | #}
|
---|
[8511] | 309 |
|
---|
| 310 | if (defined $mimetype_list) {
|
---|
[24306] | 311 | delete $self->{'saved_metadata'}->{'ex.dc.Format^mimetype'};
|
---|
[8511] | 312 |
|
---|
| 313 | # Temporarily store associate file info in metadata table
|
---|
[15872] | 314 | # This will be removed in 'extra_metadata' in BasePlugin and used
|
---|
[8511] | 315 | # to perform the actual file association (once the doc obj has
|
---|
| 316 | # been formed
|
---|
| 317 |
|
---|
| 318 | my $main_doc = $doc_file_mimes->[0];
|
---|
| 319 | my $md_mimetype = $main_doc->{'mimetype'};
|
---|
| 320 |
|
---|
| 321 | my $pd_lookup = $primary_doc_lookup->{$md_mimetype};
|
---|
| 322 |
|
---|
| 323 | if (defined $pd_lookup) {
|
---|
| 324 | my $filter_re = $pd_lookup;
|
---|
| 325 | @$assoc_file_mimes = grep { $_->{'file'} !~ m/$filter_re/ } @$assoc_file_mimes;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | my @gsdlassocfile_tobe
|
---|
[24219] | 329 | = map { &util::filename_cat($dir,$_->{'file'}) .":".$_->{'mimetype'}.":" } @$assoc_file_mimes if @$assoc_file_mimes;
|
---|
[8511] | 330 | $self->{'saved_metadata'}->{'gsdlassocfile_tobe'} = \@gsdlassocfile_tobe;
|
---|
| 331 |
|
---|
| 332 | }
|
---|
[8913] | 333 |
|
---|
[24951] | 334 | &extrametautil::setmetadata($extrametadata, $file_re, $self->{'saved_metadata'});
|
---|
[8511] | 335 |
|
---|
| 336 | return 1;
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 |
|
---|
[15872] | 340 | # The DSpacePlugin read() function. We are not actually reading any documents
|
---|
| 341 | # here, just blocking ones that have been processed by metadata read.
|
---|
[8511] | 342 | #
|
---|
[15872] | 343 | # Returns 0 for a file its blocking, undef for any other
|
---|
[8511] | 344 | sub read {
|
---|
| 345 | my $self = shift (@_);
|
---|
[16392] | 346 | my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
|
---|
[8511] | 347 | my $outhandle = $self->{'outhandle'};
|
---|
| 348 |
|
---|
| 349 | # Block all files except contents
|
---|
| 350 | my $filename = &util::filename_cat($base_dir, $file);
|
---|
| 351 | return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/;
|
---|
| 352 |
|
---|
| 353 | my $assocfile = $metadata->{'assocfile'};
|
---|
| 354 |
|
---|
| 355 | return 0 if (($filename =~ /dublin_core\.xml$/) || ($filename =~ /contents$/));
|
---|
| 356 | return 0 if (defined $self->{'extra_blocks'}->{$filename});
|
---|
| 357 | return undef;
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 | sub Doctype {
|
---|
| 361 | my ($expat, $name, $sysid, $pubid, $internal) = @_;
|
---|
| 362 |
|
---|
| 363 | die if ($name !~ /^dublin_core$/);
|
---|
| 364 | }
|
---|
| 365 |
|
---|
| 366 | sub StartTag {
|
---|
| 367 | my ($expat, $element) = @_;
|
---|
| 368 | if ($element eq "dublin_core") {
|
---|
| 369 | $self->{'saved_metadata'} = {};
|
---|
[8913] | 370 | } elsif ($element eq "dcvalue") {
|
---|
[8511] | 371 | my $metaname = $_{'element'};
|
---|
[10549] | 372 | my $qualifier = $_{'qualifier'}||"";
|
---|
[21367] | 373 | if ($metaname ne "description" || $qualifier ne "provenance") {
|
---|
[9694] | 374 | $metaname .= "^$qualifier" if ($qualifier ne "none" && $qualifier ne "");
|
---|
[24306] | 375 | $self->{'metaname'} = "ex.dc.\u$metaname";
|
---|
[8511] | 376 | }
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | sub EndTag {
|
---|
| 381 | my ($expat, $element) = @_;
|
---|
| 382 |
|
---|
| 383 | if ($element eq "dcvalue") {
|
---|
| 384 | $self->{'metaname'} = "";
|
---|
| 385 | }
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | sub Text {
|
---|
| 389 | if (defined ($self->{'metaname'}) && $self->{'metaname'} ne "") {
|
---|
| 390 | # $_ == Metadata content
|
---|
| 391 | my $mname = $self->{'metaname'};
|
---|
[21367] | 392 | my $mvalue = prepareMetadataValue($_);
|
---|
[8511] | 393 | if (defined $self->{'saved_metadata'}->{$mname}) {
|
---|
| 394 | # accumulate - add value to existing value(s)
|
---|
| 395 | if (ref ($self->{'saved_metadata'}->{$mname}) eq "ARRAY") {
|
---|
[21367] | 396 | push (@{$self->{'saved_metadata'}->{$mname}}, $mvalue);
|
---|
[8511] | 397 | } else {
|
---|
| 398 | $self->{'saved_metadata'}->{$mname} =
|
---|
[21367] | 399 | [$self->{'saved_metadata'}->{$mname}, $mvalue];
|
---|
[8511] | 400 | }
|
---|
| 401 | } else {
|
---|
| 402 | # accumulate - add value into (currently empty) array
|
---|
[21367] | 403 | $self->{'saved_metadata'}->{$mname} = [$mvalue];
|
---|
[8511] | 404 | }
|
---|
| 405 |
|
---|
| 406 | }
|
---|
| 407 | }
|
---|
| 408 |
|
---|
[21367] | 409 | # Prepare DSpace metadata for using with Greenstone.
|
---|
| 410 | # Some value must be escaped.
|
---|
| 411 | sub prepareMetadataValue {
|
---|
| 412 | my ($value) = @_;
|
---|
| 413 |
|
---|
| 414 | $value =~ s/\[/[/g;
|
---|
| 415 | $value =~ s/\]/]/g;
|
---|
| 416 |
|
---|
| 417 | return $value;
|
---|
| 418 | }
|
---|
[8511] | 419 | # This Char function overrides the one in XML::Parser::Stream to overcome a
|
---|
| 420 | # problem where $expat->{Text} is treated as the return value, slowing
|
---|
| 421 | # things down significantly in some cases.
|
---|
| 422 | sub Char {
|
---|
[9462] | 423 | use bytes; # Necessary to prevent encoding issues with XML::Parser 2.31+
|
---|
| 424 | $_[0]->{'Text'} .= $_[1];
|
---|
| 425 | return undef;
|
---|
[8511] | 426 | }
|
---|
| 427 |
|
---|
| 428 | 1;
|
---|