[protege-owl] Problem with protegex.owl.model API methods: getDomains and getRanges.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[protege-owl] Problem with protegex.owl.model API methods: getDomains and getRanges.

Frank D.-2
Hi,

I'm using the API's that come with Protege 3.2 Beta, build 324. I've used
getDomain and getRange methods successfully. Now I have a *.owl file with
multiple classes in the range and domain of properties. I'm using the getRanges
and getDoamins methods to retrieve all of the range and domain values. These
methods do not seem to be returning valid results. Perhaps I'm interpreting the
results incorrectly. The *.owl file was created with Protege. Here is a code
snippet. Any thoughts?

import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protege.model.KnowledgeBase;
import edu.stanford.smi.protegex.owl.model.*;
import java.util.Collection;
import java.util.Iterator;

...

    RDFProperty property;
    Collection col;

    property = jokb.getOWLProperty("MyPropertyName");
    System.out.println("Property: " + propertyName);
    col = property.getRanges(false);

    if (col.isEmpty())
      System.out.println(" No range values found");
    else
      System.out.println("  Found " + col.size() + " range values");

    Iterator iter = col.iterator();
    int i = 0;
    // This loop never executes more then once despite the number of
    // classes in a properties range/domain.
    while (iter.hasNext()) {
      iter.next();
      if (col instanceof RDFResource) {
        ranges = (RDFResource) col;
        System.out.println("  Range: " + ranges.getLocalName());
      }
      i++;
    }


Output:

This is the output if the property has one class in its range.
The property and range values are correct.

Property: MyProperty
  Found 1 range values
  Range: MyRangeValue
 
This is the output if the property has more then one class in its range.
Note that "Found 1" is output despite the actual number of classes in the
property range. The iterator goes through the while loop just once so this is
also 1. The <garbage> is a (perhaps hex) number like "A43".

Property: MyProperty
  Found 1 range values
  Range: <garbage>


-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html