Note that there are some explanatory texts on larger screens.

plurals
  1. POI cannot access an object property
    text
    copied!<p>I'm using Java and Jena API. I have a <strong><em>class Marriage</em></strong> which have 3 Object Properties called "<strong>hasHusband</strong>", "<strong>Haswife</strong>" and "<strong>dateOfMarriage</strong>". The first two are associated with a <strong><em>class Person</em></strong> which has the datatypeproperties like <strong>hasFirstName</strong>, <strong>hasLastName</strong>, <strong>dateOfBirth</strong>....</p> <p>I'd like to access the objects properties "Haswife" and "hasHusband" and then the wife's first name and the husband's first name.</p> <p><strong>Here is how that is represented in my rdf file:</strong></p> <p>(...)</p> <pre><code> &lt;j.0:FAMmariage rdf:about=http://www.fam.com/FAM#BrunoCatherine&gt; &lt;j.0:FAMaDateMariage&gt;25/07/2011&lt;/j.0:FAMaDateMariage&gt; &lt;j.0:FAMhasWife&gt; &lt;rdf:Description rdf:about="http://www.fam.com/FAM#Catherine20/03/1982"&gt; &lt;j.0:FAMDateOfBirth&gt;20/03/1980&lt;/j.0:FAMDateOfBirth&gt; &lt;j.0:FAMHasName&gt;Gomez&lt;/j.0:FAMHasName&gt; &lt;j.0:FAMHasFirstName&gt;Catherine&lt;/j.0:FAMHasFirstName&gt; &lt;/rdf:Description&gt; &lt;/j.0:FAMHasWife&gt; &lt;j.0:FAMHusband&gt; &lt;rdf:Description rdf:about="http://www.fam.com/FAM# Bruno15/06/1980 "&gt; &lt;j.0:FAMaDateOfBirth&gt;15/06/1980 &lt;/j.0:FAMDateOfBirth&gt; &lt;j.0:FAMHasName&gt;Jeandet &lt;/j.0:FAMHasName&gt; &lt;j.0:FAMHasFirstName&gt;Bruno&lt;/j.0:FAMHasFirstName&gt; &lt;/rdf:Description&gt; &lt;/j.0:FAMHusband&gt; &lt;/j.0:FAMmariage&gt; (...) </code></pre> <p><strong>I tried like this but it still does not works:</strong></p> <pre><code>StmtIterator iter = onto.model.listStatements(); while (iter.hasNext()) { Statement stmt = iter.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); if (predicate.equals(onto.hasWife)) { System.out.print(" " + object.toString() + " "); } } </code></pre> <p>Can you please tell me what's wrong?</p> <p>Thanks</p> <p><strong>EDITED</strong></p> <p>More useful details:</p> <p>(...)</p> <pre><code>person = model.createClass(uriBase+"person"); person.addSubClass(man); person.addSubClass(woman); marriage = model.createClass(uriBase+"marriage"); </code></pre> <p>(...)</p> <pre><code>hasHusband = model.createObjectProperty(uriBase+"hasHusband"); hasHusband.setDomain(marriage); hasHusband.setRange(man); hasWife = model.createObjectProperty(uriBase+"hasWife"); hasWife.setDomain(marriage); hasWife.setRange(woman); hasFirstName = model.createDatatypeProperty(uriBase+"hasFirstName"); hasFirstName.setDomain(person); hasFirstName.setRange(XSD.xstring); </code></pre> <p>(...)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload