On Friday, April 12, 2013 01:17:17 PM Evan Patton wrote:

> Is there any way to access the prefixes from loaded documents via the Model
> interface? 

Yes, a Model is a PrefixMapping, and the usual parsers will load
prefixes from the documents they read into the Model.

> For example, I create a new model and read in a number of
> ontologies (e.g. DBpedia, FOAF) via the Model.read(InputStream, String)
> method. If I then call the getNsURIPrefix(String) with a URI (e.g.
> http://xmlns.com/foaf/0.1/Person) I would expect that it should return
> "foaf" as that prefix was bound when I loaded the FOAF ontology, but
> instead it just returns null. 

The FOAF namespace is http://xmlns.com/foaf/0.1/, not 
http://xmlns.com/foaf/0.1/Person .

The javadoc for getNsURIPrefix(String uri) says

    Answer the prefix for the given URI, or null if there isn't one

It's not as clear as it could be that it means "the name bound as
a prefix to this URI", not "the name bound to a prefix of this URI",
which I think is what you're expecting.

Chris

Reply via email to