This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Mar 26, 2013 4:54 PM by user571093 RSS

is it possible to query anonymous classes in oracle sem. tech.?

user571093 Newbie
Currently Being Moderated
hi zhe,

is it possible to query anonymous classes in oralce sem. tech? suppose i have a class expression like this:

<owl:Class rdf:about="chronic_anemia">
<owl:equivalentClass><owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<owl:Class rdf:about="anemia"/>
<owl:Restriction>
<owl:onProperty rdf:resource="RoleGroup"/>
<owl:someValuesFrom>
<owl:Restriction>
<owl:onProperty rdf:resource="clinical_course"/>
<owl:someValuesFrom rdf:resource="chronic"/>
</owl:Restriction>
</owl:someValuesFrom>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class></owl:equivalentClass>
</owl:Class>

given the class name "chronic_anemia", i want to find its equivalent class which itself is an anonymous class (restriction class). actully, it is the definition of class "chronic_anemia". i want the result to show something like this:

anemia
clinical_course | chronic

so, is it possible to find the anonymous class in oracle sem. tech. using sparql or jena? i googled a lot but it seems sparql doesn't support this kind of query. in medical domain like snomed ct ontology, there are lots of anoymous classes similar to this, or even more complex. thanks a lot.

hong
  • 1. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Hi Hong,

    Does this give what you need?

    1) I loaded up the data you provided. Note I added namespace definitions.

    % cat tests/hong_1.rdfxml
    <?xml version="1.0"?>
    <rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="http://www.example.org/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xml:base="http://www.example.org/" >

    <owl:Class rdf:about="chronic_anemia">
    <owl:equivalentClass><owl:Class>
    <owl:intersectionOf rdf:parseType="Collection">
    <owl:Class rdf:about="anemia"/>
    <owl:Restriction>
    <owl:onProperty rdf:resource="RoleGroup"/>
    <owl:someValuesFrom>
    <owl:Restriction>
    <owl:onProperty rdf:resource="clinical_course"/>
    <owl:someValuesFrom rdf:resource="chronic"/>
    </owl:Restriction>
    </owl:someValuesFrom>
    </owl:Restriction>
    </owl:intersectionOf>
    </owl:Class></owl:equivalentClass>
    </owl:Class>
    </rdf:RDF>


    2) I executed the following SPARQL query through Jena Adapter.

    prefix owl: <http://www.w3.org/2002/07/owl#>
    prefix ns: <http://www.example.org/>
    prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

    select ?ic1 ?op ?sc
    where {
    ns:chronic_anemia owl:equivalentClass ?c .
    ?c owl:intersectionOf [
    rdf:first ?ic1 ;
    rdf:rest [
    rdf:first [
    owl:someValuesFrom [
    owl:onProperty ?op ;
    owl:someValuesFrom ?sc
    ]
    ]
    ]
    ]
    }


    3) And this is what I got.
    ( ?sc = <http://www.example.org/chronic> ) ( ?op = <http://www.example.org/clinical_course> ) ( ?ic1 = <http://www.example.org/anemia> )

    Note that the following N-TRIPLE format (of the same data in RDF/XML) can help you understand the structure of the above SPARQL query.

    <http://www.example.org/chronic_anemia> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
    _:jA0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
    <http://www.example.org/chronic_anemia> <http://www.w3.org/2002/07/owl#equivalentClass> _:jA0 .
    <http://www.example.org/anemia> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
    _:jA0 <http://www.w3.org/2002/07/owl#intersectionOf> _:jA1 .
    _:jA1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://www.example.org/anemia> .
    _:jA2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
    _:jA1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:jA3 .
    _:jA3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:jA2 .
    _:jA2 <http://www.w3.org/2002/07/owl#onProperty> <http://www.example.org/RoleGroup> .
    _:jA4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
    _:jA2 <http://www.w3.org/2002/07/owl#someValuesFrom> _:jA4 .
    _:jA4 <http://www.w3.org/2002/07/owl#onProperty> <http://www.example.org/clinical_course> .
    _:jA4 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.example.org/chronic> .
    _:jA3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .


    Hope it helps,

    Zhe Wu
  • 2. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    apparantly you got the correct result. however it is not user friently. if the equivalent anonymous class has more property-value pairs nested inside. the result will become very messy. if a user require to find the equivalent class, he/she will not want a big bunch of rdf triples with a lot of blank nodes. any new idea? thanks a lot.

    hong
  • 3. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    i should study the sparql query more carefully and test more complex anonymous classes. reply to you soon. thanks a lot for help.

    hong
  • 4. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Hi Hong,

    Using SPARQL query to find out complex TBox definitions is possible but (as you correctly pointed out) not very user friendly.

    I suspect you are looking for a syntax like OWL 2 Functional Syntax. You can find the following example in http://www.w3.org/TR/owl2-syntax/

    EquivalentClasses( a:Boy ObjectIntersectionOf( a:Child a:Man ) )

    To convert from an RDF/XML format to the functional syntax, you can use OWL APIs (http://owlapi.sourceforge.net/).


    Another possibility is to use Manchester syntax.

    For example, given the following RDF/XML,

    <?xml version="1.0"?>
    <rdf:RDF xmlns="http://www.example.org/"
    xml:base="http://www.example.org/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xml="http://www.w3.org/XML/1998/namespace">


    <owl:Class rdf:about="http://www.example.org/anemia"/>

    <owl:Class rdf:about="http://www.example.org/chronic_anemia">
    <owl:equivalentClass>
    <owl:Class>
    <owl:intersectionOf rdf:parseType="Collection">
    <rdf:Description rdf:about="http://www.example.org/anemia"/>
    <owl:Restriction>
    <owl:onProperty rdf:resource="http://www.example.org/RoleGroup"/>
    <owl:someValuesFrom>
    <owl:Restriction>
    <owl:onProperty rdf:resource="http://www.example.org/clinical_course"/>
    <owl:someValuesFrom rdf:resource="http://www.example.org/chronic"/>
    </owl:Restriction>
    </owl:someValuesFrom>
    </owl:Restriction>
    </owl:intersectionOf>
    </owl:Class>
    </owl:equivalentClass>
    </owl:Class>
    </rdf:RDF>

    we can get the following quite-readable OWL in Manchester syntax.

    Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
    Prefix: owl: <http://www.w3.org/2002/07/owl#>
    Prefix: : <http://www.example.org/>
    Prefix: ns: <http://www.example.org/>
    Prefix: xml: <http://www.w3.org/XML/1998/namespace>
    Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>

    Ontology:

    ObjectProperty: RoleGroup

    ObjectProperty: clinical_course

    Class: chronic_anemia

    EquivalentTo:
    anemia
    and (RoleGroup some (clinical_course some chronic))

    Class: chronic

    Class: anemia


    Thanks,

    Zhe Wu
  • 5. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    I was trying to load more triples into the same table to test more complex anonymous class expressions, but the first time is different than the second time.

    first time with errors:
    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix rdf
    java.sql.SQLException: ORA-00942: table or view does not exist

    Asserted triples count: 115
    Asserted + Infered triples count: 121

    second time without errors but got two more tables (snomed_ns and snomed_tpl):
    Asserted triples count: 100
    Asserted + Infered triples count: 103

    The total number of row in the table is actually 116. Then, I did a simple query in jena but got nothing returned:

    "select ?concept ?class WHERE {?concept <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?class .}"

    Then, I followed the example in the guide to load the Univ-bench ontology. The same thing happened again. I couldn't figure out what's wrong with it. Can you pls give me some hints? Thanks a lot.

    Hong
  • 6. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Hi Hong,

    This is expected. Assume there are 10 BNodes in an RDF serialization (file) and you are loading this RDF file twice.
    Then you will see 20 BNodes. This behavior is standard compliant.

    To avoid this problem, the second time you load the same RDF serialization (file), you can choose a new model.

    Hope it helps,

    Zhe Wu
  • 7. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    this time I created a new table (snomed_owl2) and a new model (snomed2) to load the same rdf triples. as it happened in the last time, I got the same errors saying:

    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix rdf
    java.sql.SQLException: ORA-00942: table or view does not exist

    but the data is loaded but soon I found the two extra tables created in my database: snomed_owl2_ns and snomed_owl2_tpl. I don't understand why I got these two extra tables and what are they used for? and, after I deleted all the loaded triples in table snomed_owl2 and loaded them again. the two tables disappeared but nothing is loaded in the table. this is strange! thanks.

    hong
  • 8. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    as to the query of first anonymous class test you showed me, it sometimes worked fine and I got the result; however, sometimes it didn't work and I got nothing returned. so, i restarted my computer and it worked again. moreover, i did a very simple query to the loaded univ-bench ontology but it returned nothing to me. is there any unknown issues related to sparql query in jena? the two queries listed below. thanks a lot.

    query for the anonymous class: sometimes it works, sometimes it doesn't.
    prefix owl: <http://www.w3.org/2002/07/owl#> " +
    "prefix ns: <http://www.example.org/> " +
    "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
    "select ?ic1 ?op ?sc where { " +
    "ns:chronic_anemia owl:equivalentClass ?c . " +
    "?c owl:intersectionOf [ rdf:first ?ic1 ; " +
    "rdf:rest [ " +
    "rdf:first [ " +
    "owl:someValuesFrom [  " +
         "owl:onProperty ?op ; " +
         "owl:someValuesFrom ?sc ] " +
         "] " +
         "] " +
    "] " +
         "}

    a simple query for univ-bench ontology but it returned nothing:
    select ?s ?o WHERE {?s <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?o . }

    hong
  • 9. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    if i manually insert the rdf triples into a table, it is no problem for the query to return the result. but, if i automatically load the triples into a table, the query won't return the results like the one in the previous post. i don't know why is that. thanks a lot.

    hong
  • 10. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Hi Hong,

    Which API did you use to load the data automatically? Maybe you can try the following code snippet (from the dev guide).
    Please let me know if it helps.

    Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
    Model model = ModelOracleSem.createOracleSemModel(oracle, szModelName);

    // load UNIV ontology incrementally
    InputStream in = FileManager.get().open("./univ-bench.owl" );
    model.read(in, null);

    String queryString =
    " SELECT ?subject ?prop ?object WHERE { ?subject ?prop ?object } ";

    Query query = QueryFactory.create(queryString) ;
    QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

    try {
    int iTriplesCount = 0;
    ResultSet results = qexec.execSelect() ;
    for ( ; results.hasNext() ; ) {
    QuerySolution soln = results.nextSolution() ;
    iTriplesCount++;
    }
    System.out.println("Asserted triples count: " + iTriplesCount);
    }
    finally {
    qexec.close() ;
    }


    Thanks,

    Zhe Wu
  • 11. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Forgot to mention that, when Jena Adapter starts working on a new model, a few tables including <model>tpl and <model>ns will be created. This is expected. The <model>tpl is the application table and <model>ns is the namespace prefix mapping table. If bulk loading APIs are used, then a few other tables will be created to facilitate the loading process.

    Thanks.

    Zhe
  • 12. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    I just tried the code. unfortunately it doesn't work. nothing is loaded into the table. here is the error message:

    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix
    java.sql.SQLException: ORA-00942: table or view does not exist

         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1086)
         at oracle.spatial.rdf.client.jena.Oracle.executeSQL(Oracle.java:539)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNamespacePrefix(OraclePrefixMapping.java:197)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNsPrefix(OraclePrefixMapping.java:217)
         at com.hp.hpl.jena.rdf.arp.JenaHandler.startPrefixMapping(JenaHandler.java:94)
         at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startPrefixMapping(XMLHandler.java:110)
         at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:107)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:158)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:145)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:215)
         at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:188)
         at jena_chap7.LoadUniv2.main(LoadUniv2.java:25)
    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix rdf
    java.sql.SQLException: ORA-00942: table or view does not exist

         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1086)
         at oracle.spatial.rdf.client.jena.Oracle.executeSQL(Oracle.java:539)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNamespacePrefix(OraclePrefixMapping.java:197)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNsPrefix(OraclePrefixMapping.java:217)
         at com.hp.hpl.jena.rdf.arp.JenaHandler.startPrefixMapping(JenaHandler.java:94)
         at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startPrefixMapping(XMLHandler.java:110)
         at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:107)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:158)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:145)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:215)
         at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:188)
         at jena_chap7.LoadUniv2.main(LoadUniv2.java:25)
    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix rdfs
    java.sql.SQLException: ORA-00942: table or view does not exist

         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1086)
         at oracle.spatial.rdf.client.jena.Oracle.executeSQL(Oracle.java:539)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNamespacePrefix(OraclePrefixMapping.java:197)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNsPrefix(OraclePrefixMapping.java:217)
         at com.hp.hpl.jena.rdf.arp.JenaHandler.startPrefixMapping(JenaHandler.java:94)
         at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startPrefixMapping(XMLHandler.java:110)
         at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:107)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:158)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:145)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:215)
         at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:188)
         at jena_chap7.LoadUniv2.main(LoadUniv2.java:25)
    WARN [main] (SimpleLog.java:87) - Could not set namespace prefix owl
    java.sql.SQLException: ORA-00942: table or view does not exist

         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1086)
         at oracle.spatial.rdf.client.jena.Oracle.executeSQL(Oracle.java:539)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNamespacePrefix(OraclePrefixMapping.java:197)
         at oracle.spatial.rdf.client.jena.OraclePrefixMapping.setNsPrefix(OraclePrefixMapping.java:217)
         at com.hp.hpl.jena.rdf.arp.JenaHandler.startPrefixMapping(JenaHandler.java:94)
         at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startPrefixMapping(XMLHandler.java:110)
         at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:107)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:158)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:145)
         at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:215)
         at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:188)
         at jena_chap7.LoadUniv2.main(LoadUniv2.java:25)
    Asserted triples count: 293

    actually the api I used before is from the dev. guide which has more lines than your code.

    the previous one I used can load the triples into the table but cannot return the result for the query. thanks a lot.

    hong
  • 13. Re: is it possible to query anonymous classes in oracle sem. tech.?
    alwu Pro
    Currently Being Moderated
    Hi Hong,

    Strange. This is the test I did against a 11.2.0.3 DB.

    % cat TestForum2512650.java

    import java.io.*;
    import com.hp.hpl.jena.query.*;
    import com.hp.hpl.jena.rdf.model.Model;
    import com.hp.hpl.jena.util.FileManager;
    import oracle.spatial.rdf.client.jena.*;

    public class TestForum2512650
    {
    public static void main(String[] args) throws Exception
    {
    String szJdbcURL = args[0];
    String szUser = args[1];
    String szPasswd = args[2];
    String szModelName = args[3];

    Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
    Model model = ModelOracleSem.createOracleSemModel(oracle, szModelName);

    // load UNIV ontology
    InputStream in = FileManager.get().open("./univ-bench.owl" );
    model.read(in, null);

    String queryString =
    " SELECT ?subject ?prop ?object WHERE { ?subject ?prop ?object } ";

    Query query = QueryFactory.create(queryString) ;
    QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

    try {
    int iTriplesCount = 0;
    ResultSet results = qexec.execSelect() ;
    for ( ; results.hasNext() ; ) {
    QuerySolution soln = results.nextSolution() ;
    iTriplesCount++;
    }
    System.out.println("Asserted triples count: " + iTriplesCount);
    }
    finally {
    qexec.close() ;
    }
    }
    }

    %/jdk16/bin/java -classpath <CP_HERE> TestForum2512650 jdbc:oracle:thin:@localhost:1521:rel11203 scott tiger MODEL91

    Asserted triples count: 293


    -- The RDF/XML starts with
    head -20 univ-bench.owl

    <?xml version="1.0" encoding="UTF-8" ?>
    <rdf:RDF
    xmlns = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"
    xml:base = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl"
    xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    >
    <owl:Ontology rdf:about="">
    <rdfs:comment>An university ontology for benchmark tests</rdfs:comment>
    <rdfs:label>Univ-bench Ontology</rdfs:label>
    <owl:versionInfo>univ-bench-ontology-owl, ver April 1, 2004</owl:versionInfo>
    </owl:Ontology>



    And ends with

    <owl:ObjectProperty rdf:ID="worksFor">
    <rdfs:label>Works For</rdfs:label>
    <rdfs:subPropertyOf rdf:resource="#memberOf" />
    </owl:ObjectProperty>
    </rdf:RDF>


    Hope it helps,

    Zhe Wu
  • 14. Re: is it possible to query anonymous classes in oracle sem. tech.?
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    it's no problem for loading triples into the table by using the code in the dev. guide, but your code in the post not. the problem is I cannot get the query result from the loaded triples, even a very simple query. but for the manually entered triples, it' no problem for querying. I guess maybe something wrong with the loaded triples, but I really don't know. thanks a lot for your help.

    hong
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points