line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::SN; |
2
|
6
|
|
|
6
|
|
76
|
use v5.10; |
|
6
|
|
|
|
|
27
|
|
3
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
166
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
275
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '20230619'; |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
56
|
use RDF::NS; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
174
|
|
9
|
6
|
|
|
6
|
|
51
|
use Scalar::Util qw(blessed); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
3439
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
22
|
|
|
22
|
1
|
76
|
my ($class, $ns) = @_; |
13
|
|
|
|
|
|
|
|
14
|
22
|
100
|
|
|
|
129
|
unless (blessed $ns) { |
15
|
1
|
50
|
|
|
|
9
|
$ns = $ns ? RDF::NS->new($ns) : RDF::NS->new; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
22
|
|
|
|
|
167
|
my $self = bless { }, $class; |
19
|
|
|
|
|
|
|
|
20
|
22
|
|
|
|
|
129
|
while ( my ($prefix, $namespace) = each %$ns ) { |
21
|
35447
|
|
|
|
|
48115
|
my $has = $self->{$namespace}; |
22
|
35447
|
100
|
100
|
|
|
61996
|
if (!$has || (length($has) > length($prefix)) |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
23
|
|
|
|
|
|
|
|| (length($has) == length($prefix) and $has ge $prefix) |
24
|
|
|
|
|
|
|
) { |
25
|
33983
|
|
|
|
|
100200
|
$self->{$namespace} = $prefix; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
22
|
|
|
|
|
1008
|
$self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub qname { |
33
|
21
|
|
|
21
|
1
|
46
|
my ($self, $uri) = @_; |
34
|
|
|
|
|
|
|
|
35
|
21
|
100
|
|
|
|
52
|
if ($self->{$uri}) { |
36
|
16
|
100
|
|
|
|
152
|
return wantarray ? ($self->{$uri}, '') : $self->{$uri}.':'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# regexpes copied from RDF::Trine::Node::Resource |
40
|
5
|
|
66
|
|
|
39
|
our $r_PN_CHARS_BASE ||= qr/([A-Z]|[a-z]|[\x{00C0}-\x{00D6}]|[\x{00D8}-\x{00F6}]|[\x{00F8}-\x{02FF}]|[\x{0370}-\x{037D}]|[\x{037F}-\x{1FFF}]|[\x{200C}-\x{200D}]|[\x{2070}-\x{218F}]|[\x{2C00}-\x{2FEF}]|[\x{3001}-\x{D7FF}]|[\x{F900}-\x{FDCF}]|[\x{FDF0}-\x{FFFD}]|[\x{10000}-\x{EFFFF}])/; |
41
|
5
|
|
66
|
|
|
249
|
our $r_PN_CHARS_U ||= qr/(_|${r_PN_CHARS_BASE})/; |
42
|
5
|
|
66
|
|
|
172
|
our $r_PN_CHARS ||= qr/${r_PN_CHARS_U}|-|[0-9]|\x{00B7}|[\x{0300}-\x{036F}]|[\x{203F}-\x{2040}]/; |
43
|
5
|
|
66
|
|
|
399
|
our $r_PN_LOCAL ||= qr/((${r_PN_CHARS_U})((${r_PN_CHARS}|[.])*${r_PN_CHARS})?)/; |
44
|
|
|
|
|
|
|
|
45
|
5
|
100
|
|
|
|
1294
|
if ($uri =~ m/${r_PN_LOCAL}$/) { |
46
|
3
|
|
|
|
|
14
|
my $ln = $1; |
47
|
3
|
|
|
|
|
13
|
my $ns = substr($uri, 0, length($uri)-length($ln)); |
48
|
3
|
50
|
|
|
|
11
|
if ($self->{$ns}) { |
49
|
3
|
100
|
|
|
|
44
|
return(wantarray ? ($self->{$ns},$ln) : $self->{$ns}.':'.$ln); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
19
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub qname_ { |
57
|
2
|
100
|
|
2
|
0
|
13
|
if(wantarray) { |
58
|
1
|
|
|
|
|
4
|
return $_[0]->qname($_[1]); |
59
|
|
|
|
|
|
|
} else { |
60
|
1
|
|
|
|
|
3
|
return join '_', $_[0]->qname($_[1]); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |