| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# AtteanX::Parser::SPARQLXML |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
AtteanX::Parser::SPARQLXML - SPARQL XML Parser |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes AtteanX::Parser::SPARQLXML version 0.032 |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Attean; |
|
15
|
|
|
|
|
|
|
my $parser = Attean->get_parser('SPARQLXML')->new(); |
|
16
|
|
|
|
|
|
|
$parser->parse_cb_from_io( $fh ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
... |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
9869
|
use v5.14; |
|
|
4
|
|
|
|
|
14
|
|
|
29
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
164
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use XML::SAX::ParserFactory; |
|
32
|
4
|
|
|
4
|
|
452
|
use Attean; |
|
|
4
|
|
|
|
|
3804
|
|
|
|
4
|
|
|
|
|
158
|
|
|
33
|
4
|
|
|
4
|
|
26
|
use Moo; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
27
|
|
|
34
|
4
|
|
|
4
|
|
23
|
use Encode qw(encode); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
23
|
|
|
35
|
4
|
|
|
4
|
|
1267
|
use PerlIO::Layers qw(query_handle); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
193
|
|
|
36
|
4
|
|
|
4
|
|
1816
|
use AtteanX::Parser::SPARQLXML::SAXHandler; |
|
|
4
|
|
|
|
|
6755
|
|
|
|
4
|
|
|
|
|
224
|
|
|
37
|
4
|
|
|
4
|
|
1909
|
|
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
1001
|
|
|
38
|
|
|
|
|
|
|
=item C<< canonical_media_type >> |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns the canonical media type for SPARQL XML: application/sparql-results+xml. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
1
|
770
|
=item C<< media_types >> |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns a list of media types that may be parsed with the SPARQL XML parser: |
|
48
|
|
|
|
|
|
|
application/sparql-results+xml. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return [qw(application/sparql-results+xml)]; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
4
|
|
|
4
|
1
|
21
|
=item C<< file_extensions >> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns a list of file extensions that may be parsed with the parser. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
with 'Attean::API::ResultOrTermParser'; |
|
63
|
|
|
|
|
|
|
with 'Attean::API::PushParser'; |
|
64
|
3
|
|
|
3
|
1
|
13
|
|
|
65
|
|
|
|
|
|
|
=item C<< parse_cb_from_io( $fh ) >> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Calls the C<< $parser->handler >> function once for each |
|
68
|
|
|
|
|
|
|
L<Attean::API::Binding> object that result from parsing |
|
69
|
|
|
|
|
|
|
the data read from the L<IO::Handle> object C<< $fh >>. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
my $fh = shift; |
|
75
|
|
|
|
|
|
|
my $handler = AtteanX::Parser::SPARQLXML::SAXHandler->new($self->handler); |
|
76
|
|
|
|
|
|
|
my $p = XML::SAX::ParserFactory->parser(Handler => $handler); |
|
77
|
|
|
|
|
|
|
if (query_handle($fh, 'utf8')) { |
|
78
|
1
|
|
|
1
|
1
|
4
|
# the filehandle already has utf-8 decoding applied, but the XML |
|
79
|
1
|
|
|
|
|
2
|
# parser is expecting utf-8 *encoded* bytes, so we need to |
|
80
|
1
|
|
|
|
|
16
|
# re-encode the data before parsing. |
|
81
|
1
|
|
|
|
|
10
|
my $string = do { local($/); <$fh> }; |
|
82
|
1
|
50
|
|
|
|
479
|
my $data = encode('UTF-8', $string, Encode::FB_CROAK); |
|
83
|
|
|
|
|
|
|
$p->parse_string($data); |
|
84
|
|
|
|
|
|
|
} else { |
|
85
|
|
|
|
|
|
|
$p->parse_file( $fh ); |
|
86
|
0
|
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
87
|
0
|
|
|
|
|
0
|
} |
|
88
|
0
|
|
|
|
|
0
|
|
|
89
|
|
|
|
|
|
|
=item C<< parse_cb_from_bytes( $data ) >> |
|
90
|
1
|
|
|
|
|
44
|
|
|
91
|
|
|
|
|
|
|
Calls the C<< $parser->handler >> function once for each |
|
92
|
|
|
|
|
|
|
L<Attean::API::Binding> object that result from parsing |
|
93
|
|
|
|
|
|
|
the data read from the UTF-8 encoded byte string C<< $data >>. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $self = shift; |
|
98
|
|
|
|
|
|
|
my $data = shift; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $handler = AtteanX::Parser::SPARQLXML::SAXHandler->new($self->handler); |
|
101
|
|
|
|
|
|
|
my $p = XML::SAX::ParserFactory->parser(Handler => $handler); |
|
102
|
|
|
|
|
|
|
$p->parse_string( $data ); |
|
103
|
2
|
|
|
2
|
1
|
83
|
} |
|
104
|
2
|
|
|
|
|
3
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
36
|
|
|
107
|
2
|
|
|
|
|
19
|
1; |
|
108
|
2
|
|
|
|
|
66251
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 BUGS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
|
115
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. This |
|
124
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
|
125
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |