kasei / attean

A Perl Semantic Web Framework
19 stars 10 forks source link

Improve handling of prefix declarations in SPARQL serializer #108

Open kasei opened 7 years ago

kasei commented 7 years ago

104 reveals that the current SPARQL serializer will always add prefix declarations when calling $a->as_sparql(namespaces => $map), even when $a isn't a top-level query object. The tests included in #104 include examples of serializing bare IRIs, and getting:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
foaf:Person

This needs to be changed so that prefix declarations are only emitted for top-level queries. Special care should be taken to avoid emitting new declarations for sub-queries.

I'm not sure if this fix needs to happen in AtteanX::Serializer::SPARQL, Attean::API::SPARQLSerializable->sparql_tokens, or Attean::API::SPARQLSerializable->as_sparql.