Sam Tregar

NAME

XML::Filter::ExceptionLocator - filter to add line/col numbers to SAX errors

SYNOPSIS

  use XML::Filter::ExceptionLocator;
  use XML::SAX::ParserFactory;

  # parse some.xml adding line/col numbers to any errors that get
  # thrown from $whatever
  my $filter = XML::Filter::ExceptionLocator->new(Handler => $whatever);
  my $parser = XML::SAX::ParserFactory->parser(Handler => $filter);
  eval { $parser->parse_uri('some.xml'); }

  # the error object will have LineNumber and ColumnNumber now
  if ($@ and ref $@ and $@->isa('XML::SAX::Exception')) {
     print "Your error is at line $@->{LineNumber}, col $@->{ColumnNumber}\n";
  }

  # if you print the error the line and column are included
  print $@;

DESCRIPTION

This module implements a SAX filter which adds line-numbers and column-numbers to errors generated by SAX handlers futher down the pipeline. I wrote this module so that XML::Validator::Schema could blame the correct line of XML for validation failures.

NOTE: This module requires a SAX parser which correctly supports the set_document_locator() call. At present there is just one, XML::SAX::ExpatXS. If you've got a number of XML::SAX parsers installed and you want to make sure XML::SAX::ExpatXS is used, do this:

   $XML::SAX::ParserPackage = 'XML::SAX::ExpatXS';

BUGS

Please use rt.cpan.org to report bugs in this module:

  http://rt.cpan.org

SUPPORT

This module is supported on the perl-xml mailing-list. Please join the list if you have questions, suggestions or patches:

  http://listserv.activestate.com/mailman/listinfo/perl-xml

CVS

If you'd like to help develop this module you'll want to check out a copy of the CVS tree:

  http://sourceforge.net/cvs/?group_id=89764

AUTHOR

Sam Tregar <sam@tregar.com>

COPYRIGHT AND LICENSE

Copyright (C) 2004 Sam Tregar

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

SEE ALSO

XML::Validator::Schema