| 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 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 5 | $VERSION = '0.99_1'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Log::Report 'xml-existdb'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use XML::eXistDB::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use XML::Compile::Util qw/pack_type type_of_node/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use XML::Compile::Cache (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use XML::LibXML::Simple qw/XMLin/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 5 | my $coll_type = pack_type NS_COLLECTION_XCONF, 'collection'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) } | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub init($) | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $schemas = $self->{XE_schemas} ||= XML::Compile::Cache->new; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"XE_schemas"} ||= "XML::Compile::Cache"->new
MC/DC0%0/2
$self->{"XE_schemas"} ||= "XML::Compile::Cache"->new
$self->{"XE_schemas"}
"XML::Compile::Cache"->new
Truth table0%0/3
A ||= B
A= $self->{"XE_schemas"}B= "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 | ▶ | my $sv = $args->{server_version} || $ENV{XML_SERVER_VERSION} || '3.0'; | ||||||||||||||||||||||||||
|
Condition0%0/5
$args->{'server_version'} || $ENV{'XML_SERVER_VERSION'} || '3.0'
$args->{"server_version"} or $ENV{"XML_SERVER_VERSION"}
MC/DC0%0/2
$args->{'server_version'} || $ENV{'XML_SERVER_VERSION'} || '3.0'
$args->{"server_version"}
$ENV{"XML_SERVER_VERSION"}
Truth table0%0/3
A or B
A= $args->{"server_version"}B= $ENV{"XML_SERVER_VERSION"}
| |||||||||||||||||||||||||||||
| 40 | 0 | $self->{XE_version} = $sv; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | (my $xsddir = __FILE__) =~ s,\.pm,/xsd-exist,; | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | my @xsds = glob "$xsddir/*.xsd"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 44 | 0 | $schemas->importDefinitions(\@xsds); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | $self; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | #----------------- | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub schemas() {shift->{XE_schemas}} | ||||||||||||||||||||||||||
|
Subroutine
schemas: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub serverVersion() {shift->{XE_version}} | ||||||||||||||||||||||||||
|
Subroutine
serverVersion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | #----------------- | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | sub createCollectionConfig($%) | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | { my ($self, $data, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
createCollectionConfig: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $format = (!exists $args{beautify} || $args{beautify}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $args{"beautify"} or $args{"beautify"}
MC/DC0%0/2
not exists $args{"beautify"} or $args{"beautify"}
not exists $args{"beautify"}
$args{"beautify"}
Truth table0%0/3
not(A) or B
A= not exists $args{"beautify"}B= $args{"beautify"}
| |||||||||||||||||||||||||||||
| 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 | ▶ | sub _coll_conf_template { shift->schemas->template(PERL => $coll_type) } | ||||||||||||||||||||||||||
|
Subroutine
_coll_conf_template: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub decodeXML($) | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
decodeXML: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | ▶ | $known ? $schemas->reader($type)->($xml) : XMLin $xml; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 5 | 1; | |||||||||||||||||||||||||||