line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2010-2015 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.01. |
5
|
1
|
|
|
1
|
|
90541
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::eXistDB; |
9
|
1
|
|
|
1
|
|
13
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.14'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
3
|
use base 'XML::Compile::Cache'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Log::Report 'xml-existdb', syntax => 'SHORT'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use XML::eXistDB::Util; |
17
|
|
|
|
|
|
|
use XML::Compile::Util qw/pack_type type_of_node/; |
18
|
|
|
|
|
|
|
use XML::LibXML::Simple qw/XMLin/; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $coll_type = pack_type NS_COLLECTION_XCONF, 'collection'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init($) |
24
|
|
|
|
|
|
|
{ my ($self, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
exists $args->{allow_undeclared} |
27
|
|
|
|
|
|
|
or $args->{allow_undeclared} = 1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$args->{any_element} ||= 'SLOPPY'; # query results are sloppy |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
unshift @{$args->{opts_readers}} |
32
|
|
|
|
|
|
|
, sloppy_integers => 1, sloppy_floats => 1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->SUPER::init($args); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
(my $xsddir = __FILE__) =~ s,\.pm,/xsd-exist,; |
37
|
|
|
|
|
|
|
my @xsds = glob "$xsddir/*.xsd"; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->addPrefixes(exist => NS_EXISTDB); |
40
|
|
|
|
|
|
|
$self->importDefinitions(\@xsds); |
41
|
|
|
|
|
|
|
$self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub createCollectionConfig($%) |
46
|
|
|
|
|
|
|
{ my ($self, $data, %args) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $format = (!exists $args{beautify} || $args{beautify}) ? 1 : 0; |
49
|
|
|
|
|
|
|
my $string; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# create XML via XML::Compile |
52
|
|
|
|
|
|
|
my $writer = $self->{wr_coll_conf} ||= |
53
|
|
|
|
|
|
|
$self->compile |
54
|
|
|
|
|
|
|
( WRITER => $coll_type |
55
|
|
|
|
|
|
|
, include_namespaces => 1, sloppy_integers => 1 |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); |
59
|
|
|
|
|
|
|
my $xml = $writer->($doc, $data); |
60
|
|
|
|
|
|
|
$doc->setDocumentElement($xml); |
61
|
|
|
|
|
|
|
$doc->toString($format); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# perl -MXML::eXistDB -e 'print XML::eXistDB->new->_coll_conf_template' |
65
|
|
|
|
|
|
|
sub _coll_conf_template { shift->template(PERL => $coll_type) } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub decodeXML($) |
69
|
|
|
|
|
|
|
{ my $self = shift; |
70
|
|
|
|
|
|
|
my $xml = $self->dataToXML(shift); |
71
|
|
|
|
|
|
|
my $type = type_of_node $xml; |
72
|
|
|
|
|
|
|
my $known = $self->namespaces->find(element => $type); |
73
|
|
|
|
|
|
|
$known ? $self->reader($type)->($xml) : XMLin $xml; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |