Thanks, Andy.  Is the answer to this question "no" as well?

    Is there an alternative to model.listNameSpaces() that will also return 
namespaces used in URI's in the object position of triples?  

-----Original Message-----
From: Andy Seaborne [mailto:[email protected]] 
Sent: Thursday, April 28, 2016 11:18 AM
To: [email protected]
Subject: Re: Namespace prefixes in Jena Models
Importance: High

On 28/04/16 15:56, Scoggan, Tom wrote:
> When writing a Model to an RDF string, I currently do something like this:
>
>
> 1.      Use the model.listNameSpaces() method to get the list of namespaces 
> used --- this doesn't include namespaces used in URI's in the object position 
> of triples

Model.listNamespaces list the names set on the model.  Either in the 
data when read in, or set by the application.

>
> 2.      Manually add the missing namespaces for URI's in the object position 
> of triples

Namespaces are not necessary - they are a convenience for presentation 
(and that works better in Turtle than RDF/XML). Choosing the prefix or 
namespace name

[except for properties in RDF/XML which can only be written with qnames]

> 3.      Assign prefixes to each namespace

Something somewhere is going to have to choose nice prefixes.

>
> 4.      Use the model.setNsPrefixes(prefixToNamespaceMap) method to update 
> the Model accordingly
>
> 5.      Write the Model to an RDF string
>
> Is there any way to avoid step 3 by having Jena auto-generate prefixes for 
> namespaces used within the model (including URI's in the object position)?  
> If not, is there an alternative to model.listNameSpaces() that will also 
> return namespaces used in URI's in the object position of triples?

Set them in the input data.

Or keep a Turtle file that is only prefixes and parse it into any model 
your create.  Parsing a file sets the prefixes so if your data is 
N-triples, say, and you want to see it in pretty turtle, just add in 
some extra, domain specific, prefixes.

     Andy

>
> Thanks!

----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.

Reply via email to