Re: SPARQL expand prefix

2017-11-23 Thread Andy Seaborne

Create teh query and clear its prefix map:

Query query = ... ;
query.getPrologue().getPrefixMapping().clearNsPrefixMap();
System.out.println(query);



On 23/11/17 13:14, Mohammad Noorani Bakerally wrote:

Suppose I have a query like:

PREFIX  : 
PREFIX  data: 
PREFIX  dcat: \n\nCONSTRUCT \n  { \n<
https://bistrotdepays.opendatasoft.com/api/v2/catalog/datasets/animations_bistrots_de_pays>
?p ?o .\n  }\nWHERE\n  { <
https://bistrotdepays.opendatasoft.com/api/v2/catalog/datasets/animations_bistrots_de_pays>\n
  ?p  ?o\nFILTER ( ?p NOT IN (dcat:distribution) )\n  }


Is it possible to obtain a query where all prefixes have been expanded ? is
it not possible to load the query, expand it and serialize it ?

  I have tried the following which isn't working:

Query gq = QueryFactory.create(Global.prefixes + graphQuery);
gq.setPrefixMapping(Global.prefixMap);
Global.prefixMap.getNsPrefixMap().entrySet().stream().forEach(prefixEntry->{
 gq.expandPrefixedName(prefixEntry.getKey());
});


‌



SPARQL expand prefix

2017-11-23 Thread Mohammad Noorani Bakerally
Suppose I have a query like:

PREFIX  : 
PREFIX  data: 
PREFIX  dcat: \n\nCONSTRUCT \n  { \n<
https://bistrotdepays.opendatasoft.com/api/v2/catalog/datasets/animations_bistrots_de_pays>
?p ?o .\n  }\nWHERE\n  { <
https://bistrotdepays.opendatasoft.com/api/v2/catalog/datasets/animations_bistrots_de_pays>\n
 ?p  ?o\nFILTER ( ?p NOT IN (dcat:distribution) )\n  }


Is it possible to obtain a query where all prefixes have been expanded ? is
it not possible to load the query, expand it and serialize it ?

 I have tried the following which isn't working:

Query gq = QueryFactory.create(Global.prefixes + graphQuery);
gq.setPrefixMapping(Global.prefixMap);
Global.prefixMap.getNsPrefixMap().entrySet().stream().forEach(prefixEntry->{
gq.expandPrefixedName(prefixEntry.getKey());
});


‌