line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2006-2017 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
|
1
|
|
|
1
|
|
7798
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::Compile::Util; |
9
|
1
|
|
|
1
|
|
3
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.58'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
128
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @constants = qw/XMLNS SCHEMA1999 SCHEMA2000 SCHEMA2001 SCHEMA2001i/; |
15
|
|
|
|
|
|
|
our @EXPORT = qw/pack_type unpack_type/; |
16
|
|
|
|
|
|
|
our @EXPORT_OK = |
17
|
|
|
|
|
|
|
( qw/pack_id unpack_id odd_elements even_elements type_of_node |
18
|
|
|
|
|
|
|
escape duration2secs add_duration/ |
19
|
|
|
|
|
|
|
, @constants |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our %EXPORT_TAGS = (constants => \@constants); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use constant |
24
|
1
|
|
|
|
|
90
|
{ XMLNS => 'http://www.w3.org/XML/1998/namespace' |
25
|
|
|
|
|
|
|
, SCHEMA1999 => 'http://www.w3.org/1999/XMLSchema' |
26
|
|
|
|
|
|
|
, SCHEMA2000 => 'http://www.w3.org/2000/10/XMLSchema' |
27
|
|
|
|
|
|
|
, SCHEMA2001 => 'http://www.w3.org/2001/XMLSchema' |
28
|
|
|
|
|
|
|
, SCHEMA2001i => 'http://www.w3.org/2001/XMLSchema-instance' |
29
|
1
|
|
|
1
|
|
6
|
}; |
|
1
|
|
|
|
|
1
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
345
|
use Log::Report 'xml-compile'; |
|
1
|
|
|
|
|
79213
|
|
|
1
|
|
|
|
|
6
|
|
32
|
1
|
|
|
1
|
|
259
|
use POSIX qw/mktime/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub pack_type($;$) |
36
|
0
|
0
|
0
|
0
|
1
|
0
|
{ @_==1 ? $_[0] |
|
|
0
|
|
|
|
|
|
37
|
|
|
|
|
|
|
: !defined $_[0] || !length $_[0] ? $_[1] |
38
|
|
|
|
|
|
|
: "{$_[0]}$_[1]" |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
0
|
1
|
0
|
sub unpack_type($) { $_[0] =~ m/^\{(.*?)\}(.*)$/ ? ($1, $2) : ('', $_[0]) } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
0
|
sub pack_id($$) { "$_[0]#$_[1]" } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
1
|
0
|
sub unpack_id($) { split /\#/, $_[0], 2 } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
0
|
1
|
0
|
sub odd_elements(@) { my $i = 0; map {$i++ % 2 ? $_ : ()} @_ } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
52
|
0
|
0
|
|
0
|
1
|
0
|
sub even_elements(@) { my $i = 0; map {$i++ % 2 ? () : $_} @_ } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub type_of_node($) |
56
|
0
|
0
|
|
0
|
1
|
0
|
{ my $node = shift or return (); |
57
|
0
|
|
|
|
|
0
|
pack_type $node->namespaceURI, $node->localName; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
|
276
|
use constant SECOND => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
62
|
1
|
|
|
1
|
|
6
|
use constant MINUTE => 60 * SECOND; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
43
|
|
63
|
1
|
|
|
1
|
|
8
|
use constant HOUR => 60 * MINUTE; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
64
|
1
|
|
|
1
|
|
5
|
use constant DAY => 24 * HOUR; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
65
|
1
|
|
|
1
|
|
5
|
use constant MONTH => 30.4 * DAY; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
66
|
1
|
|
|
1
|
|
5
|
use constant YEAR => 365.256 * DAY; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
271
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $duration = qr/ |
69
|
|
|
|
|
|
|
^ (\-?) P (?:([0-9]+)Y)? (?:([0-9]+)M)? (?:([0-9]+)D)? |
70
|
|
|
|
|
|
|
(?:T (?:([0-9]+)H)? (?:([0-9]+)M)? (?:([0-9]+(?:\.[0-9]+)?)S)? |
71
|
|
|
|
|
|
|
)?$/x; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub duration2secs($) |
74
|
8
|
50
|
|
8
|
1
|
478
|
{ my $stamp = shift or return undef; |
75
|
|
|
|
|
|
|
|
76
|
8
|
50
|
|
|
|
73
|
$stamp =~ $duration |
77
|
|
|
|
|
|
|
or error __x"illegal duration format: {d}", d => $stamp; |
78
|
|
|
|
|
|
|
|
79
|
8
|
100
|
100
|
|
|
171
|
($1 eq '-' ? -1 : 1) |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
80
|
|
|
|
|
|
|
* ( ($2 // 0) * YEAR |
81
|
|
|
|
|
|
|
+ ($3 // 0) * MONTH |
82
|
|
|
|
|
|
|
+ ($4 // 0) * DAY |
83
|
|
|
|
|
|
|
+ ($5 // 0) * HOUR |
84
|
|
|
|
|
|
|
+ ($6 // 0) * MINUTE |
85
|
|
|
|
|
|
|
+ ($7 // 0) * SECOND |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub add_duration($;$) |
91
|
8
|
50
|
|
8
|
1
|
3552
|
{ my $stamp = shift or return; |
92
|
8
|
|
33
|
|
|
39
|
my ($secs, $min, $hour, $mday, $mon, $year) = gmtime(shift // time); |
93
|
|
|
|
|
|
|
|
94
|
8
|
50
|
|
|
|
76
|
$stamp =~ $duration |
95
|
|
|
|
|
|
|
or error __x"illegal duration format: {d}", d => $stamp; |
96
|
|
|
|
|
|
|
|
97
|
8
|
100
|
|
|
|
27
|
my $sign = $1 eq '-' ? -1 : 1; |
98
|
8
|
|
100
|
|
|
202
|
mktime |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
99
|
|
|
|
|
|
|
$secs + $sign*($7//0) |
100
|
|
|
|
|
|
|
, $min + $sign*($6//0) |
101
|
|
|
|
|
|
|
, $hour + $sign*($5//0) |
102
|
|
|
|
|
|
|
, $mday + $sign*($4//0) |
103
|
|
|
|
|
|
|
, $mon + $sign*($3//0) |
104
|
|
|
|
|
|
|
, $year + $sign*($2//0) |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
1; |