diff --git a/lib/AtteanX/Serializer/SPARQLHTML.pm b/lib/AtteanX/Serializer/SPARQLHTML.pm
index 5fab5942..d5ef9728 100644
--- a/lib/AtteanX/Serializer/SPARQLHTML.pm
+++ b/lib/AtteanX/Serializer/SPARQLHTML.pm
@@ -140,11 +140,26 @@ Serializes the L object as HTML.
s/&/&/g;
s/</g;
}
- my $html = $uri;
+ my $html = qq[$uri];
+
+ if (my $map = $self->namespaces) {
+ my $abr = $map->abbreviate($uri);
+
+ if ($abr) {
+ return qq[$abr];
+ } else {
+ return $html;
+ }
+
+ } else {
+
+ return $html;
+ }
+
+
# if ($link) {
# $html = qq[$html];
# }
- return $html;
} elsif ($node->does('Attean::API::Literal')) {
my $html = $node->value;
for ($html) {
@@ -162,6 +177,7 @@ Serializes the L object as HTML.
}
}
with 'Attean::API::ResultSerializer';
+ with 'Attean::API::AbbreviatingSerializer';
}
1;
diff --git a/t/issue_54.t b/t/issue_54.t
new file mode 100644
index 00000000..cc21f025
--- /dev/null
+++ b/t/issue_54.t
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+use Attean;
+use Attean::IRI;
+
+my $sclass = Attean->get_serializer('SPARQLHTML');
+
+my $map = URI::NamespaceMap->new( {
+ foaf => 'http://xmlns.com/foaf/0.1/'
+ });
+
+my $n1 = Attean::IRI->new('http://xmlns.com/foaf/0.1/Person');
+my $n2 = Attean::IRI->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type');
+
+NAMESPACEMAP:{
+
+ my $s = $sclass->new(namespaces => $map);
+
+ is ($s->node_as_html($n1), 'foaf:Person', 'Return HTML link for IRI with abbrev');
+ is ($s->node_as_html($n2), 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'Return HTML link for IRI - 1');
+
+}
+
+NO_NAMESPACEMAP:{
+
+ my $s = $sclass->new();
+
+ is ($s->node_as_html($n1), 'http://xmlns.com/foaf/0.1/Person', 'Return HTML link for IRI - 2');
+ is ($s->node_as_html($n2), 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'Return HTML link for IRI - 3');
+
+}
+
diff --git a/t/serializer-sparqlhtml.t b/t/serializer-sparqlhtml.t
index 4c0b9a2d..74c49ce7 100644
--- a/t/serializer-sparqlhtml.t
+++ b/t/serializer-sparqlhtml.t
@@ -41,11 +41,11 @@ END
my @rows = ($b =~ /(=', 4, 'at least 1 header row and 3 data rows');
like($b, qr[x | ]);
- like($b, qr[http://example.org/p | ]);
+ like($b, qr[http://example.org/p | ]);
like($b, qr[1 | ]);
like($b, qr[x | ]);
like($b, qr[2 | ]);
- like($b, qr[http://perlrdf.org/ | ]);
+ like($b, qr[http://perlrdf.org/ | ]);
};
subtest 'serialize_iter_to_io' => sub {
@@ -58,11 +58,11 @@ END
my @rows = ($b =~ /(
=', 4, 'at least 1 header row and 3 data rows');
like($b, qr[x | ]);
- like($b, qr[http://example.org/p | ]);
+ like($b, qr[http://example.org/p | ]);
like($b, qr[1 | ]);
like($b, qr[x | ]);
like($b, qr[2 | ]);
- like($b, qr[http://perlrdf.org/ | ]);
+ like($b, qr[http://perlrdf.org/ | ]);
};
}