This file is indexed.

/usr/share/doc/libxml-grove-perl/examples/my-html.pl is in libxml-grove-perl 0.46alpha-12.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#
# Copyright (C) 1997, 1998 Ken MacLeod
# See the file COPYING for distribution terms.
#
# $Id: my-html.pl,v 1.5 1999/05/06 23:13:02 kmacleod Exp $
#

# `my-html.pl' uses `accept_name' methods to generate calls back using
# an element's name instead of the generic `visit_element'.  Because
# we don't want to handle every single possible element name, Perl's
# AUTOLOAD feature is used to pass through any elements we don't
# handle.

use XML::Parser::PerlSAX;
use XML::Grove;
use XML::Grove::Builder;
use XML::Grove::AsString;
use Data::Grove::Visitor;

($prog = $0) =~ s|.*/||g;

die "usage: $prog HTML-DOC\n"
    if ($#ARGV != 0);

my $builder = XML::Grove::Builder->new;
my $parser = XML::Parser::PerlSAX->new(Handler => $builder);
my $grove = $parser->parse (Source => { SystemId => @ARGV[0] });

$grove->accept_name (MyHTML->new);

exit (0);

######################################################################
#
# A Visitor package.
#

package MyHTML;

use strict;
use vars qw{$AUTOLOAD};

sub new {
    my $class = shift;

    return bless {}, $class;
}

sub visit_document {
    my $self = shift;
    my $grove = shift;

    $grove->children_accept_name ($self, @_);
}

sub visit_element {
    my $self = shift;
    my $element = shift;
    print "<$element->{Name}>";
    $element->children_accept_name ($self, @_);
    print "</$element->{Name}>";
}

sub visit_entity {
    my $self = shift;
    my $entity = shift;

    warn "is entity?\n";
    print "&" . $entity->{Name} . ";";
}

sub visit_characters {
    my $self = shift;
    my $characters = shift;
    my $data = $characters->{Data};

    # FIXME do we need to translate special chars here?
    $data =~ tr/\r/\n/;
    print $data;
}

######################################################################
#
# My special HTML tags
#

sub visit_name_DATE {
    my $time = localtime;

    # use only non-breaking spaces
    $time =~ s/ /\&nbsp;/g;

    print $time;
}

sub visit_name_PERL {
    my $self = shift;
    my $element = shift;

    # doesn't grok entities, be sure to use CDATA marked sections
    my $perl = $element->as_string;
    $perl =~ tr/\r//d;
    no strict;
    eval $perl;
    use strict;
    warn $@ if $@;
}

1;