This file is indexed.

/usr/share/doc/libparse-recdescent-perl/examples/demo_simpleXML.pl is in libparse-recdescent-perl 1.967009+dfsg-1.

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
#!/usr/bin/perl -w

package XML2DS;
use Parse::RecDescent;
@ISA = qw( Parse::RecDescent );

sub allow_nested
{
	my ($parser, $tag, @nestedtags) = @_;
	my $nestedtags = join '|', map { '^'.$_.'$' } @nestedtags;
	$parser->{allow}{$tag} = qr/$nestedtags/;
}

sub new
{
	bless Parse::RecDescent->new(<<'EOGRAMMAR'), XML2DS;

	xml:  unitag(?)
	   |  tag content[$item[1]](s) endtag[$item[1]]
					{ bless $item[2], $item[1]}

	unitag:
		m{<([a-zA-Z]+)/>}	{ bless [], $1 }

	tag:
		m{<([a-zA-Z]+)>}	{ $return = $1 }

	endtag:
		m{</$arg[0]>}
	      |	m{(\S+)} <error: was expecting </$arg[0]> but found $1 instead>

	content: <rulevar: local $error>
	content: rawtext <commit> check[$arg[0], $item[1]]
	       | xml   <commit> check[$arg[0], $item[1]]
	       | <error?: $error>  <error: error in <$arg[0]> block>

	rawtext: m{[^<]+}		{ bless \$item[1], 'rawtext' }

	check: { my ($outertag, $innertag) = ($arg[0], ref $arg[1]);
		 $return = $arg[1] if !$thisparser->{allow}{$outertag}
				   || $innertag =~ $thisparser->{allow}{$outertag};
		 $error = ($innertag eq 'rawtext')
			? "Raw text not valid in <$outertag> block"
			: "<$innertag> tag not valid in <$outertag> block";
		 undef;
		}
EOGRAMMAR
}


package main;
use Data::Dumper;

my $parser = XML2DS->new();

$parser->allow_nested( Test    => qw(Example)	      );
$parser->allow_nested( Example => qw(Data    rawtext) );
$parser->allow_nested( Data    => qw(SubData rawtext) );
$parser->allow_nested( SubData => qw(Example rawtext) );

my $xml = join '', <DATA>;

if (my $tree = $parser->xml($xml))
{
	print Data::Dumper->Dump([$tree]);
}


__DATA__

<Test>
	<Example/>
	<Example>
		<Data>
			raw data
			<SubData>
				raw subdata
			</SubData>
			more raw data
		</Data>
		<Data>
			still more raw data
			<SubData>
				<Example>
					<Data>
						nested example data
					</Data>
				</Example>
			</SubData>
		</Data>
		last rawtext
	</Example>
</Test>