Alvis-Convert

 view release on metacpan or  search on metacpan

bin/alvisXSL  view on Meta::CPAN

	s/<\/$GROUPELEMENT>.*//;
	close(XIN);
	$reading = 0;
      }
    }
  }
  # print STDERR "Starting: $_";
  return $_;
}

sub endofline() {
  if ( eof(XIN) ) {
    return 1;
  }
}

#################################################################
#
#  XSLT routine
#
#  This is kind of stupid,, couldn't find an XSLT + Sax + Perl

lib/Alvis/Buffer.pm  view on Meta::CPAN


#############################################
#  run time variables
our $docs = 0;
our $size = 0;
our $verbose = 0;

############################################
#
#  add XML chunk
sub add() {
  my $xml = shift();
  my $xc = $xml;
  my $count = $xc =~ s/<\/documentRecord>//g;
  #  now save
  print ABUF $xml,"\n";
  if ( $verbose ) {
    my $tt = Time::Simple->new;
    print STDERR "Docs of $count of size " . length($xml) . " added at time "
      . $tt->format . "\n";
  }
  $docs += $count;
  $size += length($xml);
}

sub close() {
  CORE::close(ABUF);
}

############################################
#
#  make sure the output XML buffer file is in OK state
#  and open it for append, as filehandle ABUF
#  and set $docs, $size
#  return 0 on fatal error, after printing error message
sub fix() {
  $docs = 0;
  $size = 0;
  if ( ! -f $BUFFER ) {
    #  start new one
    if ( ! open(ABUF,">>$BUFFER") ) {
      print STDERR "Cannot open $BUFFER: $!\n";
      return 0;
    }
    select((select(ABUF), $| = 1)[0]);
    print ABUF $HEADER;

lib/Alvis/Buffer.pm  view on Meta::CPAN

    select((select(ABUF), $| = 1)[0]);
  }
  1;
}

############################################
#
#  rename output XML buffer file to xml-add/N.xml for some N
#  and create a new output XML buffer file, name is returned;
#  return undef on fatal error, after printing error message
sub save() {
  print ABUF $TRAILER; 
  CORE::close(ABUF);
  #  determine next available name
  if ( ! opendir(XA,"xml-add") ) {
    print STDERR "Cannot opendir xml-add/: $!\n";
    return undef;
  }
  my $latest = 0;
  while ( ($_=readdir(XA)) ) {
    if ( /^([0-9]+).xml$/ ) {



( run in 0.903 second using v1.01-cache-2.11-cpan-65fba6d93b7 )