On 20/01/11 15:56, Reto Bachmann-Gmuer wrote:
Hi

It retreives the map and then asks for the set of entries. So it seems
there's no way to bind it to a service, it wants to know all possible
bindings before it starts.

I created JENA-31 to have a more felxible support here.

Cheers,
reto

Why not override the other methods? - presumable it's calling getNsPrefixMap.

The contract to the writer (and this applies to all writers, not just RDF/XML) is "here's some prefixes, here's some RDF, go write stuff as best you can". Adding calls into the application for decisions still requires application code.

RDF/XML is special because to write properties in RDF/XML requires an XML namespace. Other formats do not need any prefixes to write legal output and would be greatly complicated to have

Prefixes often get set because they are in the input. Carrying them around is convenient and (as we have found) expected by users even if not used.

For the specific use case in Clerezza,

1/ Layer the problem.

Why not look through the model, decide the prefixes you do want, then set the prefix mapping for model and then write it. This gives the application (i.e. Clerezza) a chance to influence the choices.

2/ Set the prefixes when the data is created - this seems to me to be the more natural point to make choices.

        Andy



On Thu, Jan 20, 2011 at 4:33 PM, Chris Dollin
<[email protected]>wrote:

On Thursday, January 20, 2011 03:00:26 pm Reto Bachmann-Gmuer wrote:
Hello

I'm trying to connect the jena serializers to a service that delivers
curie-prefix suggestions for uri-prefixes.

My fisrt attempt doesn't seem to work:

         Model model = ModelFactory.createModelForGraph(graph);
         model.setNsPrefixes(new PrefixMappingImpl() {

             @Override
             protected String get(String prefix) {
                 System.out.println("getting "+prefix);
                 return super.get(prefix);
             }

             @Override
             public String getNsURIPrefix(String uri) {
                 System.out.println("getting prefix for "+uri);
                 if ("http://example.org/".equals(uri)) {
                     return "ex";
                 }
                 return null;
             }

         });
         RDFWriter writer = model.getWriter(jenaFormat);
         writer.write(model, serializedGraph, "");

the overwritten methods seem not be called. The examples I found all deal
with registering individual prefix-mappings, in my case I want to access
a
service that suggests a prefix.

The RDF/XML writer calls getNsPrefixMap() to get the entire prefix mapping
as a map and then fiddles with that, so, you're right: the methods you
wrote are not called.

Chris

--
"We try our best to make it sound nice."               /Hatfield and the
North/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20
6PT
Epimorphics Ltd. is a limited company registered in England (number
7016688)


Reply via email to