| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lido::XML; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
16586
|
use Moo; |
|
|
1
|
|
|
|
|
9771
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
1337
|
use Lido::XML::LIDO_1_0; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
7
|
1
|
|
|
1
|
|
397
|
use XML::Compile; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::Compile::Schema; |
|
9
|
|
|
|
|
|
|
use XML::Compile::Util 'pack_type'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'namespace' => (is => 'ro' , default => sub {'http://www.lido-schema.org'}); |
|
12
|
|
|
|
|
|
|
has 'root' => (is => 'ro' , default => sub {'lido'}); |
|
13
|
|
|
|
|
|
|
has 'prefixes' => (is => 'ro' , default => sub { |
|
14
|
|
|
|
|
|
|
[ |
|
15
|
|
|
|
|
|
|
'lido' => 'http://www.lido-schema.org', |
|
16
|
|
|
|
|
|
|
'doc' => 'http://www.mda.org.uk/spectrumXML/Documentation', |
|
17
|
|
|
|
|
|
|
'gml' => 'http://www.opengis.net/gml', |
|
18
|
|
|
|
|
|
|
'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
19
|
|
|
|
|
|
|
'xml' => 'http://www.w3.org/XML/1998/namespace' |
|
20
|
|
|
|
|
|
|
] |
|
21
|
|
|
|
|
|
|
}); |
|
22
|
|
|
|
|
|
|
has 'schema' => (is => 'lazy'); |
|
23
|
|
|
|
|
|
|
has 'reader' => (is => 'lazy'); |
|
24
|
|
|
|
|
|
|
has 'writer' => (is => 'lazy'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _build_schema { |
|
27
|
|
|
|
|
|
|
my $self = shift; |
|
28
|
|
|
|
|
|
|
my $schema = XML::Compile::Schema->new(); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @schemes = Lido::XML::LIDO_1_0->new->content; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
for my $s (@schemes) { |
|
33
|
|
|
|
|
|
|
$schema->importDefinitions($s); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$schema; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _build_reader { |
|
40
|
|
|
|
|
|
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
my $type = pack_type $self->namespace, $self->root; |
|
42
|
|
|
|
|
|
|
$self->schema->compile(READER => $type); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _build_writer { |
|
46
|
|
|
|
|
|
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
my $type = pack_type $self->namespace, $self->root; |
|
48
|
|
|
|
|
|
|
$self->schema->compile(WRITER => $type, ( prefixes => $self->prefixes ) ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub parse { |
|
52
|
|
|
|
|
|
|
my ($self,$input) = @_; |
|
53
|
|
|
|
|
|
|
$self->reader->($input); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub to_xml { |
|
57
|
|
|
|
|
|
|
my ($self,$data) = @_; |
|
58
|
|
|
|
|
|
|
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); |
|
59
|
|
|
|
|
|
|
my $xml = $self->writer->($doc, $data); |
|
60
|
|
|
|
|
|
|
$doc->setDocumentElement($xml); |
|
61
|
|
|
|
|
|
|
$doc->toString(1); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |