This file is indexed.

/usr/share/perl5/XML/Grove/Path.pm 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#
# Copyright (C) 1998, 1999 Ken MacLeod
# XML::Grove::Path is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
#
# $Id: Path.pm,v 1.2 1999/08/17 15:01:28 kmacleod Exp $
#

package XML::Grove::Path;

use XML::Grove;
use XML::Grove::XPointer;
use UNIVERSAL;

sub at_path {
    my $element = shift;	# or Grove
    my $path = shift;

    $path =~ s|^/*||;

    my @path = split('/', $path);

    return (_at_path ($element, [@path]));
}

sub _at_path {
    my $element = shift;	# or Grove
    my $path = shift;
    my $segment = shift @$path;

    # segment := [ type ] [ '[' index ']' ]
    #
    # strip off the first segment, finding the type and index
    $segment =~ m|^
                ([^\[]+)?     # - look for an optional type
                              #   by matching anything but '['
                (?:           # - don't backreference the literals
                  \[          # - literal '['
                    ([^\]]+)  # - index, any non-']' chars
                  \]          # - literal ']'
                )?            # - the whole index is optional
               |x;
    my ($node_type, $instance, $match) = ($1, $2, $&);
    # issues:
    #   - should assert that no chars come after index and before next
    #     segment or the end of the query string

    $instance = 1 if !defined $instance;

    my $object = $element->xp_child ($instance, $node_type);

    if ($#$path eq -1) {
        return $object;
    } elsif (!$object->isa('XML::Grove::Element')) {
        # FIXME a location would be nice.
        die "\`$match' doesn't exist or is not an element\n";
    } else {
        return (_at_path($object, $path));
    }
}

package XML::Grove::Document;

sub at_path {
    goto &XML::Grove::Path::at_path;
}

package XML::Grove::Element;

sub at_path {
    goto &XML::Grove::Path::at_path;
}

1;

__END__

=head1 NAME

XML::Grove::Path - return the object at a path

=head1 SYNOPSIS

 use XML::Grove::Path;

 # Using at_path method on XML::Grove::Document or XML::Grove::Element:
 $xml_obj = $grove_object->at_path("/some/path");

 # Using an XML::Grove::Path instance:
 $pather = XML::Grove::Path->new();
 $xml_obj = $pather->at_path($grove_object);

=head1 DESCRIPTION

C<XML::Grove::Path> returns XML objects located at paths.  Paths are
strings of element names or XML object types separated by slash ("/")
characters.  Paths must always start at the grove object passed to
`C<at_path()>'.  C<XML::Grove::Path> is B<not> XPath, but it should
become obsolete when an XPath implementation is available.

Paths are like URLs

    /html/body/ul/li[4]
    /html/body/#pi[2]

The path segments can be element names or object types, the objects
types are named using:

    #element
    #pi
    #comment
    #text
    #cdata
    #any

The `C<#any>' object type matches any type of object, it is
essentially an index into the contents of the parent object.

The `C<#text>' object type treats text objects as if they are not
normalized.  Two consecutive text objects are separate text objects.

=head1 AUTHOR

Ken MacLeod, ken@bitsko.slc.ut.us

=head1 SEE ALSO

perl(1), XML::Grove(3)

Extensible Markup Language (XML) <http://www.w3c.org/XML>

=cut