line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Licensed Materials - Property of IBM |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Copyright IBM Corporation 2006 All Rights Reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# $Id: RDFAttributes.pm,v 1.10 2009-11-25 17:54:26 ubuntu Exp $ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package ODO::Parser::XML::RDF::Attributes; |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
27
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
209
|
|
12
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
128
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
26
|
use base qw/ODO/; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
518
|
|
15
|
4
|
|
|
4
|
|
23
|
use vars qw /$VERSION/; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
433
|
|
16
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /: (\d+)\.(\d+)/; |
17
|
4
|
|
|
4
|
|
24
|
use ODO::Exception; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
193
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use XML::Namespace |
20
|
4
|
|
|
|
|
43
|
rdf=> 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' |
21
|
4
|
|
|
4
|
|
21
|
; |
|
4
|
|
|
|
|
10
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 RDF ATTRIBUTES |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item Attributes requiring a RDF URI prefix |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $REQUIRED_PREFIX = { |
40
|
|
|
|
|
|
|
'about'=> 1, |
41
|
|
|
|
|
|
|
'ID'=> 1, |
42
|
|
|
|
|
|
|
'type'=> 1, |
43
|
|
|
|
|
|
|
'resource'=> 1, |
44
|
|
|
|
|
|
|
'parseType'=> 1, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item Prohibited attributes |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
our $PROHIBITED_ATTRIBUTES = { |
52
|
|
|
|
|
|
|
'li'=> 1, |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item Withdrawn attributes |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
our $WITHDRAWN_ATTRIBUTES = { |
61
|
|
|
|
|
|
|
'bagID'=> 1, |
62
|
|
|
|
|
|
|
'aboutEach'=> 1, |
63
|
|
|
|
|
|
|
'aboutEachPrefix'=> 1, |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=back |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item is_withdrawn( $attribute ) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub is_withdrawn { |
77
|
0
|
|
|
0
|
|
|
shift; |
78
|
0
|
|
|
|
|
|
return exists($WITHDRAWN_ATTRIBUTES->{ $_[0] }); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item needs_namespace( $attribute ) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub needs_namespace { |
87
|
0
|
|
|
0
|
|
|
shift; |
88
|
0
|
|
|
|
|
|
return exists($REQUIRED_PREFIX->{ $_[0] }); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item is_prohibited( $attribute ) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub is_prohibited { |
97
|
0
|
|
|
0
|
|
|
shift; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
0
|
|
|
|
return 1 |
100
|
|
|
|
|
|
|
if($_[0] eq rdf->uri() && |
101
|
|
|
|
|
|
|
exists($PROHIBITED_ATTRIBUTES->{ $_[1] })); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return 0; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item to_string( ) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub to_string { |
111
|
0
|
|
|
0
|
|
|
shift; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $attributes = shift; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $string = ''; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each(%{ $attributes }) ) { |
|
0
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$string .= "$k=\"$v\" "; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
return $string; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub init { |
125
|
0
|
|
|
0
|
|
|
my ($self, $config) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $attributes = {}; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each(%{ $config }) ) { |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
throw XML::SAX::Exception::Parse(Message=> 'RDF attribute "' . $v->{'LocalName'} . '" has been withdrawn.') |
132
|
|
|
|
|
|
|
if($self->is_withdrawn( $v->{'LocalName'} )); |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
0
|
|
|
|
throw XML::SAX::Exception::Parse(Message=> 'RDF attribute "' . $v->{'LocalName'} . '" must have rdf: prefix.') |
135
|
|
|
|
|
|
|
if($self->needs_namespace( $v->{'LocalName'}) && !$v->{'NamespaceURI'}); |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
throw XML::SAX::Exception::Parse(Message=> 'RDF attribute "' . $v->{'LocalName'} . '" is prohibited from attributes.') |
138
|
|
|
|
|
|
|
if($self->is_prohibited( $v->{'NamespaceURI'}, $v->{'LocalName'})); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Make sure our LocalName and NamespaceURI have the proper separator |
141
|
0
|
0
|
0
|
|
|
|
$v->{'NamespaceURI'} .= '#' |
142
|
|
|
|
|
|
|
if(! ($v->{'NamespaceURI'} =~ m|/$| || $v->{'NamespaceURI'} =~ m|#$|) ); |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$attributes->{ $v->{'NamespaceURI'} . $v->{'LocalName'} } = $v->{'Value'}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return $attributes; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (c) 2006 IBM Corporation. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials |
157
|
|
|
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0 |
158
|
|
|
|
|
|
|
which accompanies this distribution, and is available at |
159
|
|
|
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |