| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Net::MarkLogic::XDBC::Result; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::MarkLogic::XDBC::Result- A sequence of XQUERY values returned from the execution of an XQUERY statement. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Net::MarkLogic::XDBC::Result |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $result = $xdbc->query($xquery); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
print $result->content; |
|
16
|
|
|
|
|
|
|
print $result->as_xml; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@items = $result->items; |
|
19
|
|
|
|
|
|
|
print $item->content; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Alpha. API will change. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The XDBC server returns results as a multipart message. If your xquery |
|
26
|
|
|
|
|
|
|
statement returns a series of XML nodes instead of one XML node with subnodes, |
|
27
|
|
|
|
|
|
|
expect lots of items. Otherwise, you can probably get away with calling |
|
28
|
|
|
|
|
|
|
content(). |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
If you want to deal with your results piece by piece, call items(). |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
35
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
36
|
1
|
|
|
1
|
|
5
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
37
|
1
|
|
|
1
|
|
829
|
use Net::MarkLogic::XDBC::Result::Item; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
8
|
|
|
38
|
1
|
|
|
1
|
|
40
|
use Class::Accessor; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
39
|
1
|
|
|
1
|
|
22
|
use Class::Fields; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
134
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our @BASIC_FIELDS = qw(response); |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
5
|
use base qw(Class::Accessor Class::Fields); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
116
|
|
|
44
|
1
|
|
|
1
|
|
6
|
use fields @BASIC_FIELDS, qw(items); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
45
|
|
|
|
|
|
|
Net::MarkLogic::XDBC::Result->mk_accessors( @BASIC_FIELDS ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new() |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$resp = Net::MarkLogic::XDBC::ResultSet->new( response => $http_resp ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Result objects are normally created for you after calls to XDBC->query. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
die "No HTTP::Response argument" unless $args{response}; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
0
|
|
|
|
my $self = bless ({}, ref ($class) || $class); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->response($args{response}); |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if (!$self->response->is_success) |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
# TODO - error handling |
|
71
|
0
|
|
|
|
|
|
$self->{items} = (); |
|
72
|
0
|
|
|
|
|
|
return $self; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$self->{items} = $self->_parse_multipart_header; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $self; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _parse_multipart_header { |
|
81
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my @items = (); |
|
84
|
0
|
|
|
|
|
|
my $ctype = $self->response->header('Content-Type'); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $boundary; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
0
|
|
|
|
if ($ctype && ($ctype =~ m/boundary=(\w+)/)) |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
0
|
|
|
|
|
|
$boundary = "--" . $1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
foreach my $part (split("$boundary", $self->response->content()) ) |
|
93
|
|
|
|
|
|
|
{ |
|
94
|
0
|
0
|
|
|
|
|
if ( $part =~ m/Content-Type: \s (\S*) \s* |
|
95
|
|
|
|
|
|
|
X-Primitive: \s (\S*) \s* |
|
96
|
|
|
|
|
|
|
(.*)/xs ) |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
0
|
|
|
|
|
|
push (@items, Net::MarkLogic::XDBC::Result::Item->new( |
|
99
|
|
|
|
|
|
|
content_type => $1, |
|
100
|
|
|
|
|
|
|
type => $2, |
|
101
|
|
|
|
|
|
|
content => $3, |
|
102
|
|
|
|
|
|
|
)); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return \@items; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 content() |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
print $result->content(); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
The content of the response, usually XML. Doesn't contain any info about the |
|
115
|
|
|
|
|
|
|
content's data type. If the response contains multiple parts, the content of |
|
116
|
|
|
|
|
|
|
each part is concatenated. The results are returned inside of a |
|
117
|
|
|
|
|
|
|
tag to ensure a complete XML document. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub content |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $content; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$content = qq{\n}; |
|
128
|
0
|
|
|
|
|
|
foreach my $item ($self->items) |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
0
|
|
|
|
|
|
$content .= $item->content; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
0
|
|
|
|
|
|
$content .= "\n"; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return $content; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 as_xml() |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
print $result->as_xml |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns an XML representation of the result including content type and xml |
|
142
|
|
|
|
|
|
|
type. The document has a root node of result and each part of the response |
|
143
|
|
|
|
|
|
|
is inside an entry node. The entry node contains two attributes, content_type |
|
144
|
|
|
|
|
|
|
and x_type. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub as_xml |
|
149
|
|
|
|
|
|
|
{ |
|
150
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $xml = qq{\n}; |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
foreach my $item ($self->items) |
|
155
|
|
|
|
|
|
|
{ |
|
156
|
0
|
|
|
|
|
|
$xml .= $item->as_xml; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
0
|
|
|
|
|
|
$xml .= "\n"; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return $xml; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 items() |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
@items= $result->items(); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Return Net::MarkLogic::CIS::Result::Item objects for each part of the |
|
169
|
|
|
|
|
|
|
response. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub items |
|
174
|
|
|
|
|
|
|
{ |
|
175
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
return @{$self->{items}}; |
|
|
0
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 response() |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $http_resp = $result->response; |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns the HTTP::Response object used to create this object. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 BUGS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Big time. Watch out for changing APIs. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 AUTHOR |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Tony Stubblebine |
|
195
|
|
|
|
|
|
|
tonys@oreilly.com |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Copyright 2004 Tony Stubblebine |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
|
202
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
|
203
|
|
|
|
|
|
|
You may obtain a copy of the License at |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
|
208
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
|
209
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
210
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
|
211
|
|
|
|
|
|
|
limitations under the License. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
MarkLogic CIS documentation: |
|
216
|
|
|
|
|
|
|
http://xqzone.marklogic.com |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1; |
|
221
|
|
|
|
|
|
|
__END__ |