Jakob Voß

NAME

PICA::XMLParser - Parse PICA+ XML

SYNOPSIS

  my $rcount = 1;
  my $parser = PICA::XMLParser->new( 
      Field => \&field_handler,
      Record => \&record_handler
  );
  $parser->parsefile($filename);

  # equivalent:
  PICA::Parser->parsefile($filename,
      Field => \&field_handler,
      Record => \&record_handler,
      Format => 'xml'  
  );

  sub field_handler {
      my $field = shift;
      print $field->to_string();
      # no need to save the field so do not return it
  }

  sub record_handler {
      print "$rcount\n"; $rcount++;
  }

DESCRIPTION

This module contains a parser to parse PICA+ XML. Up to now PICA+ XML is not fully standarized yet so this parser may slightly change in the future.

PUBLIC METHODS

new

Creates a new Parser. See PICA::Parser for a description of parameters to define handlers (Field and Record).

parsedata

Parses data from a string, array reference or function. Data from arrays and functions will be read and buffered before parsing. Do not directly call this method without a PICA::XMLParser object that was created with new().

parsefile (data)

Parses data from a file or filehandle.

counter

Get the number of read records so far.

empty_counter

Get the number of empty records that have been read so far. By default empty records are not passed to the record handler but counted.

PRIVATE HANDLERS

Do not directly call this methods.

init_handler

Called at the beginning.

final_handler

Called at the end. Does nothing so far.

start_handler

Called for each start tag.

end_handler

Called for each end tag.

char_handler

Called for character data.

_getHandlers

Get the handlers (init_handler, final_handler, start_handler, end_handler, char_handler).

_getPosition

Get the current position (file name and line number).

TODO

XML namespaces are not supported yet. When XML errors occur, there should be better error messages that point to a give file and line. Return values of collections are not supported yet.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2007 by Verbundzentrale Göttingen (VZG) and Jakob Voss

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

Please note that these module s not product of or supported by the employers of the various contributors to the code nor by OCLC PICA.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 367:

Non-ASCII character seen before =encoding in 'Göttingen'. Assuming UTF-8