GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SGML::Parser::OpenSP::Tools(3) User Contributed Perl Documentation SGML::Parser::OpenSP::Tools(3)

SGML::Parser::OpenSP::Tools - Tools to process OpenSP output

Routines to post-process OpenSP event data.

specified_attribute($attribute)
specified_attribute returns a true value if the attribute is of type "cdata" or "tokenized" and has its "Defaulted" property set to "specified". For example

  sub start_element
  {
    my $self = shift;
    my $elem = shift;
    my @spec = grep specified_attribute($_),
                    values %{$elem->{Attributes}};

    # @spec contains all explicitly specified attributes
  }
    
defaulted_attribute($attribute)
defaulted_attribute returns a true value if the attribute is of type "cdata" or "tokenized" and has its "Defaulted" property set to something but "specified". For all attributes, the following always holds true,

  !defined(attribute_value($_)) or
  defaulted_attribute($_) or
  specified_attribute($_)
    

since only defaulted and specified attributes can have a value.

value_attribute($attribute)
Returns true if the value can have a value, i.e., it is either specified or defaulted.
attribute_value($attribute)
attribute_value returns a textual representation of the value of an attribute as reported to a "start_element" handler or "undef" if no value is available.
split_message($message, $filename, $open_ent, $error_num, $open_elem)
split_message splits an OpenSP error message into its components, the error or warning message, an optional auxiliary message that provides additional information about the error, like the first occurence of an ID in case of duplicate IDs in a document, each accompanied by line and column numbers relevant to the message, and depending on the parser configuration the open entities for the message, the error number of the message and a list of the current open elements.

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
  }
    
split_pi($data)
split_pi splits the data of a processing instructions at the first white space character into two components where white space character is defined in the $WHITESPACE package variable, qr/[\x20\x09\x0d\x0a]/ by default. It returns "undef" if there is no data to split.

  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.
2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.