| SGML::Parser::OpenSP::Tools(3pm) | User Contributed Perl Documentation | SGML::Parser::OpenSP::Tools(3pm) |
SGML::Parser::OpenSP::Tools - Tools to process OpenSP output
Routines to post-process OpenSP event data.
sub start_element
{
my $self = shift;
my $elem = shift;
my @spec = grep specified_attribute($_),
values %{$elem->{Attributes}};
# @spec contains all explicitly specified attributes
}
!defined(attribute_value($_)) or
defaulted_attribute($_) or
specified_attribute($_)
since only defaulted and specified attributes can have a value.
It returns a hash reference like
# this is always present
primary_message =>
{
Number => 141, # only if $p->show_error_numbers(1)
Module => 554521624, # only if $p->show_error_numbers(1)
ColumnNumber => 9,
LineNumber => 12,
Severity => 'E',
Text => 'ID "a" already defined'
},
# only some messages have an aux_message
aux_message =>
{
ColumnNumber => 9,
LineNumber => 11,
Text => 'ID "a" first defined here'
},
# iff $p->show_open_elements(1) and there are open elements
open_elements => 'html body[1] (p[1])',
# iff $p->show_open_entities(1) and there are open entities
# other than the document, but the document will be reported
# if the error is in some other entity
open_entities => [
{
ColumnNumber => 55,
FileName => 'example.xhtml',
EntityName => 'html',
LineNumber => 2
}, ... ],
This would typically be used like
sub error
{
my $self = shift;
my $erro = shift;
my $mess = $erro->{Message};
# parser is the SGML::Parser::OpenSP
# object stored in the handler object
my $loca = $self->{parser}->get_location;
my $name = $loca->{FileName};
my $splt = split_message($mess, $name,
$self->{parser}->show_open_entities,
$self->{parser}->show_error_numbers,
$self->{parser}->show_open_elements);
# ...
}
A more convenient way to access this function is provided by the "SGML::Parser::OpenSP" module which you can use like
sub error
{
my $self = shift;
my $erro = shift;
my $mess = $self->{parser}->split_message($erro);
# relevant data is now $mess and $erro->{Severity}
# of which the latter provides more detailed information
# than $mess->{primary_message}->{Severity}, see the
# SGML::Parser::OpenSP documentation for details
}
sub pi
{
my $self = shift;
my $proc = shift;
my ($target, $data) = split_pi($proc->{Data});
# ...
}
Copyright (c) 2006-2008 Bjoern Hoehrmann <bjoern@hoehrmann.de>. This module is licensed under the same terms as Perl itself.
| 2025-01-05 | perl v5.40.0 |