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