line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Trine::Namespace |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
RDF::Trine::Namespace - Abbreviated syntax for constructing RDF node objects |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This document describes RDF::Trine::Namespace version 1.018 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use RDF::Trine::Namespace qw(rdf); |
16
|
|
|
|
|
|
|
my $foaf = RDF::Trine::Namespace->new( 'http://xmlns.com/foaf/0.1/' ); |
17
|
|
|
|
|
|
|
my $pred = $foaf->name; |
18
|
|
|
|
|
|
|
my $type = $rdf->type; |
19
|
|
|
|
|
|
|
print $pred->as_string; # '[http://xmlns.com/foaf/0.1/name]' |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module provides an abbreviated syntax for creating RDF::Trine::Node objects |
24
|
|
|
|
|
|
|
for URIs sharing common namespaces. The module provides a constructor for creating |
25
|
|
|
|
|
|
|
namespace objects which may be used for constructing Node objects. Calling any |
26
|
|
|
|
|
|
|
method (other than 'import', 'new', 'uri' or 'AUTOLOAD') on the namespace object |
27
|
|
|
|
|
|
|
will return a RDF::Trine::Node object representing the URI of the method name |
28
|
|
|
|
|
|
|
appended to the namespace. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 4 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package RDF::Trine::Namespace; |
37
|
|
|
|
|
|
|
|
38
|
68
|
|
|
68
|
|
671
|
use strict; |
|
68
|
|
|
|
|
445
|
|
|
68
|
|
|
|
|
1560
|
|
39
|
68
|
|
|
68
|
|
305
|
use warnings; |
|
68
|
|
|
|
|
126
|
|
|
68
|
|
|
|
|
1450
|
|
40
|
68
|
|
|
68
|
|
336
|
no warnings 'redefine'; |
|
68
|
|
|
|
|
142
|
|
|
68
|
|
|
|
|
2102
|
|
41
|
68
|
|
|
68
|
|
330
|
use base qw(XML::Namespace); |
|
68
|
|
|
|
|
138
|
|
|
68
|
|
|
|
|
28497
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
###################################################################### |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our ($VERSION); |
46
|
|
|
|
|
|
|
BEGIN { |
47
|
68
|
|
|
68
|
|
38800
|
$VERSION = '1.018'; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
###################################################################### |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
68
|
|
|
68
|
|
413
|
use Carp; |
|
68
|
|
|
|
|
137
|
|
|
68
|
|
|
|
|
3161
|
|
54
|
68
|
|
|
68
|
|
392
|
use RDF::Trine::Node::Resource; |
|
68
|
|
|
|
|
4580
|
|
|
68
|
|
|
|
|
2813
|
|
55
|
68
|
|
|
68
|
|
25240
|
use XML::CommonNS 0.04 (); |
|
68
|
|
|
|
|
97242
|
|
|
68
|
|
|
|
|
7015
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub import { |
58
|
300
|
|
|
300
|
|
3149
|
my $class = shift; |
59
|
300
|
100
|
|
|
|
12260
|
if (@_) { |
60
|
156
|
|
|
|
|
3929
|
$class->_install_namespaces( 1, @_ ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _install_namespaces { |
65
|
156
|
|
|
156
|
|
421
|
my $class = shift; |
66
|
156
|
|
|
|
|
318
|
my $level = shift; |
67
|
156
|
|
|
|
|
501
|
my $pkg = caller( $level ); |
68
|
156
|
|
|
|
|
1948
|
foreach my $name (@_) { |
69
|
166
|
100
|
|
|
|
1547
|
my $uri = (uc($name) eq 'XSD') |
70
|
|
|
|
|
|
|
? XML::NamespaceFactory->new('http://www.w3.org/2001/XMLSchema#') |
71
|
|
|
|
|
|
|
: XML::CommonNS->uri( uc($name) ); |
72
|
166
|
|
|
|
|
5293
|
my $ns = $class->new( "$uri" ); |
73
|
68
|
|
|
68
|
|
472
|
no strict 'refs'; ## no critic (ProhibitNoStrict) |
|
68
|
|
|
|
|
148
|
|
|
68
|
|
|
|
|
7889
|
|
74
|
166
|
|
|
|
|
2521
|
*{ "${pkg}::${name}" } = \$ns; |
|
166
|
|
|
|
|
18097
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C<uri> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns the URI node object for the namespace, with an optional path argument |
81
|
|
|
|
|
|
|
added to the end of it. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub uri { |
86
|
8600
|
|
|
8600
|
1
|
221542
|
my $self = shift; |
87
|
8600
|
|
|
|
|
15742
|
my $local = shift; |
88
|
8600
|
100
|
|
|
|
22270
|
unless (defined($local)) { |
89
|
31
|
|
|
|
|
56
|
$local = ''; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# we should just call $self->SUPER::uri($local) here, but there's a bug in |
93
|
|
|
|
|
|
|
# XML::Namespace 0.2 that assumes $local eq '' if $local is defined but false (e.g. '0') |
94
|
8600
|
|
|
|
|
25984
|
my $uri = $self->SUPER::uri() . $local; |
95
|
8600
|
|
|
|
|
82712
|
return RDF::Trine::Node::Resource->new( $uri ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C<< uri_value >> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns the URI/IRI value of this namespace. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub uri_value { |
105
|
9
|
|
|
9
|
1
|
372
|
my $self = shift; |
106
|
9
|
|
|
|
|
21
|
return $self->uri(); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
110
|
|
|
|
|
|
|
__END__ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L<XML::Namespace> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 BUGS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
121
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (c) 2006-2012 Gregory Todd Williams. This |
130
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
131
|
|
|
|
|
|
|
the same terms as Perl itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |