Skip to content

Commit 3475f95

Browse files
committed
an attempt at setting all needed namespaces in the builder
1 parent f41f05c commit 3475f95

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/RDF/LinkedData.pm

+8-10
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ has last_etag => ( is => 'rw', isa => Str, predicate => 'has_last_etag');
243243
=item namespaces ( $namespace_map )
244244
245245
Gets or sets the namespaces that some serializers use for
246-
pretty-printing. Should be handed a L<URI::NamespaceMap> object.
246+
pretty-printing. Should be handed a L<URI::NamespaceMap> object. RDF,
247+
VoID, Hydra, DC Terms and XML Schema are added by the module and do
248+
not need to be declared.
247249
248250
=cut
249251

@@ -258,13 +260,11 @@ has 'namespaces' => (is => 'rw',
258260

259261

260262
sub _build_namespaces {
261-
my ($self, $ns_hash) = @_;
262-
my $map = URI::NamespaceMap->new(['rdf', 'void', 'dct']);
263-
while (my ($name, $uri) = each %{$ns_hash}) {
264-
$map->add_mapping($name => $uri);
265-
}
266-
warn Data::Dumper::Dumper($map)
267-
return $map;
263+
my $self = shift;
264+
my $nsmap = shift || URI::NamespaceMap->new();
265+
$nsmap->guess_and_add('rdf', 'void', 'dct', 'xsd');
266+
$nsmap->add_mapping(hydra => 'http://www.w3.org/ns/hydra/core#');
267+
return $nsmap;
268268
}
269269

270270
# Just a temporary compatibility hack
@@ -351,9 +351,7 @@ sub response {
351351
# TODO: Paging goes here
352352
$output_model->add_statement($st);
353353
}
354-
$self->add_namespace_mapping(hydra => 'http://www.w3.org/ns/hydra/core#');
355354
my $cl = literal($counter, undef, 'http://www.w3.org/2001/XMLSchema#integer');
356-
warn Data::Dumper::Dumper($self->list_namespaces);
357355
my $void = $self->namespaces->void;
358356
$output_model->add_statement(statement(iri($uri),
359357
iri($void->triples),

0 commit comments

Comments
 (0)