require
5.005_62;
@RDF::Notation3::Triples::ISA
=
qw(RDF::Notation3::Template::TTriples RDF::Notation3)
;
sub
_process_statement {
my
(
$self
,
$subject
,
$properties
) =
@_
;
$subject
=
$self
->_expand_prefix(
$subject
);
foreach
(
@$properties
) {
if
(
$_
->[0] ne
'i'
) {
$_
->[0] =
$self
->_expand_prefix(
$_
->[0]);
for
(
my
$i
= 1;
$i
<
scalar
@$_
;
$i
++ ) {
$_
->[
$i
] =
$self
->_expand_prefix(
$_
->[
$i
]);
push
@{
$self
->{triples}},
[
$subject
,
$_
->[0],
$_
->[
$i
],
$self
->{context}];
}
}
else
{
shift
@$_
;
$_
->[0] =
$self
->_expand_prefix(
$_
->[0]);
for
(
my
$i
= 1;
$i
<
scalar
@$_
;
$i
++ ) {
$_
->[
$i
] =
$self
->_expand_prefix(
$_
->[
$i
]);
push
@{
$self
->{triples}},
[
$_
->[
$i
],
$_
->[0],
$subject
,
$self
->{context}];
}
}
}
}
sub
add_triple {
my
(
$self
,
$s
,
$p
,
$o
) =
@_
;
$self
->{triples} or
$self
->{triples} = [];
$self
->_check_resource(
$s
,
$s
);
$self
->_check_resource(
$s
,
$p
);
$self
->_check_resource(
$s
,
$o
,
'l'
);
$s
=
$self
->_expand_prefix(
$s
);
$p
=
$self
->_expand_prefix(
$p
);
$o
=
$self
->_expand_prefix(
$o
);
push
@{
$self
->{triples}}, [
$s
,
$p
,
$o
,
'<>'
];
return
scalar
@{
$self
->{triples}};
}
sub
_expand_prefix {
my
(
$self
,
$qname
) =
@_
;
foreach
(
keys
%{
$self
->{ns}->{
$self
->{context}}}) {
$qname
=~ s/^
$_
:(.*)$/<
$self
->{ns}->{
$self
->{context}}->{
$_
}$1>/;
}
if
(
$qname
=~ /^([_a-zA-Z]\w*)*:[a-zA-Z]\w*$/) {
$self
->_do_error(106,
$qname
);
}
return
$qname
;
}
1;