Namespace not added in the database using java api to import ontology

0 views
Skip to first unread message

samch...@gmail.com

unread,
Apr 1, 2014, 10:23:40 AM4/1/14
to sta...@clarkparsia.com
Hi,
    We have imported a rdfxml file using the java api(com.complexible.stardog.api.connection.add.io.format(format).file(file)) but it has not added name spaces to the database which is causing problem during queries as we are not getting matches. However if we import the file using command line, we get the name spaces in database. I have attached an owl file which we are importing as RDFXML format 

Regards,
Developer,
Sameer Garg
Which?  
Feed1396361954329.owl

Mike Grove

unread,
Apr 1, 2014, 10:27:34 AM4/1/14
to stardog
On Tue, Apr 1, 2014 at 10:23 AM, <samch...@gmail.com> wrote:
Hi,
    We have imported a rdfxml file using the java api(com.complexible.stardog.api.connection.add.io.format(format).file(file)) but it has not added name spaces to the database which is causing problem during queries as we are not getting matches. However if we import the file using command line, we get the name spaces in database. I have attached an owl file which we are importing as RDFXML format 

How are you importing it via the command line?

Cheers,

Mike
 

Regards,
Developer,
Sameer Garg
Which?  

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Evren Sirin

unread,
Apr 1, 2014, 10:46:09 AM4/1/14
to Stardog
Namespaces are added to the database automatically only at database
creation time (db create command in CLI). Files added later (using
data add CLI command or the API call you mention) will not change the
stored namespaces. The API call that corresponds to db create command
so:

// create an admin connection
AdminConnection aAdminConnection = ...
// create a disk db with given file(s) whose namespaces will be stored
aAdminConnection.disk("dbName").create(file1, file2, ...);

You also have the option of adding the namespaces manually using the
API after db creation. It would look something like this:

// import com.complexible.common.rdf.rio.RDFStreams;
// Create Stardog connection as usual
Connection conn = ...
// Get namespaces object
final Namespaces ns = aConn.namespaces();
// Parse the file contents and add the namespace declaration to the database
RDFStreams.forFile(new File("filePath")).parse(new RDFHandlerBase() {
@Override
public void handleNamespace(String prefix, String uri) throws
RDFHandlerException {
try {
ns.add(prefix, uri);
}
catch (NamespacesException e) {
// do error handling
}
}
});

Best,
Evren
Reply all
Reply to author
Forward
0 new messages