line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2010-2021 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution XML-ExistsDB. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package XML::eXistDB; |
10
|
5
|
|
|
5
|
|
304469
|
use vars '$VERSION'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
250
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.99_1'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
136
|
|
15
|
5
|
|
|
5
|
|
26
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
107
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
2281
|
use Log::Report 'xml-existdb'; |
|
5
|
|
|
|
|
502734
|
|
|
5
|
|
|
|
|
43
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
4544
|
use XML::eXistDB::Util; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
321
|
|
20
|
5
|
|
|
5
|
|
2280
|
use XML::Compile::Util qw/pack_type type_of_node/; |
|
5
|
|
|
|
|
7755
|
|
|
5
|
|
|
|
|
336
|
|
21
|
5
|
|
|
5
|
|
2568
|
use XML::Compile::Cache (); |
|
5
|
|
|
|
|
769496
|
|
|
5
|
|
|
|
|
206
|
|
22
|
5
|
|
|
5
|
|
63
|
use XML::LibXML::Simple qw/XMLin/; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
2715
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $coll_type = pack_type NS_COLLECTION_XCONF, 'collection'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) } |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub init($) |
30
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
my $schemas = $self->{XE_schemas} ||= XML::Compile::Cache->new; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$schemas->allowUndeclared(1); |
35
|
0
|
|
|
|
|
|
$schemas->anyElement('SLOPPY'); # query results are sloppy |
36
|
0
|
|
|
|
|
|
$schemas->addCompileOptions('RW', sloppy_integers => 1, sloppy_floats => 1); |
37
|
0
|
|
|
|
|
|
$schemas->addPrefixes(exist => NS_EXISTDB); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
0
|
|
|
|
my $sv = $args->{server_version} || $ENV{XML_SERVER_VERSION} || '3.0'; |
40
|
0
|
|
|
|
|
|
$self->{XE_version} = $sv; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
(my $xsddir = __FILE__) =~ s,\.pm,/xsd-exist,; |
43
|
0
|
|
|
|
|
|
my @xsds = glob "$xsddir/*.xsd"; |
44
|
0
|
|
|
|
|
|
$schemas->importDefinitions(\@xsds); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#----------------- |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
sub schemas() {shift->{XE_schemas}} |
52
|
0
|
|
|
0
|
1
|
|
sub serverVersion() {shift->{XE_version}} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#----------------- |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub createCollectionConfig($%) |
57
|
0
|
|
|
0
|
1
|
|
{ my ($self, $data, %args) = @_; |
58
|
0
|
0
|
0
|
|
|
|
my $format = (!exists $args{beautify} || $args{beautify}) ? 1 : 0; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# create XML via XML::Compile |
61
|
0
|
|
|
|
|
|
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); |
62
|
0
|
|
|
|
|
|
my $xml = $self->schemas->writer($coll_type)->($doc, $data); |
63
|
0
|
|
|
|
|
|
$doc->setDocumentElement($xml); |
64
|
0
|
|
|
|
|
|
$doc->toString($format); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# perl -MXML::eXistDB -e 'print XML::eXistDB->new->_coll_conf_template' |
68
|
0
|
|
|
0
|
|
|
sub _coll_conf_template { shift->schemas->template(PERL => $coll_type) } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub decodeXML($) |
72
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
73
|
0
|
|
|
|
|
|
my $schemas = $self->schemas; |
74
|
0
|
|
|
|
|
|
my $xml = $schemas->dataToXML(shift); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $type = type_of_node $xml; |
77
|
0
|
|
|
|
|
|
my $known = $schemas->namespaces->find(element => $type); |
78
|
0
|
0
|
|
|
|
|
$known ? $schemas->reader($type)->($xml) : XMLin $xml; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |