Jump to: navigation, search

Person-with-address Example Context Ontology

{{#eclipseproject:technology.higgins|eclipse_custom_style.css}} Let's imagine a Context whose domain involved things (or more precisely Digital Subjects) called Persons. Each Person has a surname, firstname and a postal address. And let's say that this postal address is something that could be described in XML schema as:

<xsd:complexType name="postalAddress">
 <xsd:sequence>
  <xsd:element name="streetAddress" type="xsd:string" />
  <xsd:element name="city" type="xsd:string" />
  <xsd:element name="state" type="xsd:string" />
  <xsd:element name="postalCode" type="xsd:integer" minOccurs="0" />
  <xsd:element name="country" type="xsd:string" minOccurs="0" />
 </xsd:sequence>
</xsd:complexType>

Note: For the sake of simplicity, we are going to side-step best practice and not model what in IdAS is called the "source" of these attributes. As far as we are concerned these attributes came out of thin air.

For this example we've created: http://www.eclipse.org/higgins/ontologies/2006/person-with-address.owl The first part of the file is the ontology, the last part is the instance data.

Context Providers need to do is declare the ontology that will provide the language in which to describe instances of Persons along with their associated simple attributes (surname and first name) and compound attributes (postal address). In this case the provider a person-with-address.owl ontology.

You'll notice that like all Context ontologies, it includes near the top an "import" statement that imports the required base higgins.owl ontology.

Context Instance Data

Context Providers are also responsible for being able to export the Contexts they manage. Here is an example of an export to RDF of a Context that contains one Person (Mary) and conforms to the person-with-address ontology.

<pwa:PostalAddress rdf:about="urn:address">
  <pwa:city>Provo</pwa:city>
  <pwa:country>USA</pwa:country>
  <pwa:postalCode>12345</pwa:postalCode>
  <pwa:state>Utah</pwa:state>
  <pwa:streetAddress>123 Main St.</pwa:streetAddress>
</pwa:PostalAddress>
 
<pwa:Person rdf:about="urn:mary">
  <pwa:postalAdress rdf:resource="urn:address"/>
  <pwa:firstname rdf:resource="urn:mary-firstname"/>
  <pwa:surname rdf:resource="urn:mary-surname"/>
</pwa:Person>

<higgins:NormalizedStringSimpleAttribute rdf:about="urn:mary-firstname">
  <higgins:normalizedStringSimpleValue
    rdf:datatype="&xsd;normalizedString">Mary
      </higgins:normalizedStringSimpleValue>
</higgins:NormalizedStringSimpleAttribute>

<higgins:NormalizedStringSimpleAttribute rdf:about="urn:mary-surname">
  <higgins:normalizedStringSimpleValue
    rdf:datatype="&xsd;normalizedString">Ruddy
      </higgins:normalizedStringSimpleValue>
</higgins:NormalizedStringSimpleAttribute>

Here is a graphical view of the instance data: Person-with-address-instance v2.jpg

Relationship to IdAS API

Let's look at Mary and her first name from the point of view (POV) of both the ontology/schema and IdAS API:

Mary and her first name

urn:mary

  • schema POV: is a resource of type pwa:Person (a subclass of higgins:DigitalSubject)
  • IdAS POV: is an IDigitalSubject, obtained like (assume myContext was already opened):
IDigitalSubject dsMary = myContext.getSubject("urn:mary");

pwa:firstname

  • schema POV: is an RDF property (pwa:firstname) whose range is urn:mary-firstname
  • IdAS POV: is an IAttribute, obtained from the IDigitalSubject retreived above by calling either getAttribute() or getAttributes() e.g.:
IAttribute attrFirstName = dsMary.getAttribute(new URI("pwa:firstname"));
// next line returns the URI containing "pwa:firstname"
URI uriFirstNameAttr = attrFirstName.getType();

urn:mary-firstname

  • schema POV: is a resource of type higgins:NormalizedStringSimpleAttribute
  • IdAS POV: is an IPropertyValue sub-interface. Given the IAttribute instance found above, we could call getValue() or getValues() this would return an IPropertyValue instance(s):
IPropertyValue valueFirstName = attrFirstName.getValue();
// next line returns true, indicating this is an ISimpleValue
boolean b = valueFirstName.isSimple();
// next line returns the URI containing "xsd:string"
URI uriFirstNameVal = valueFirstName.getType();
// next line returns the Java String object containing "Mary" (see table at ISimpleValue)
String sFirstNameVal = (String)valueFirstName.getData();

Mary and her address

pwa:address

  • schema POV: is an RDF property (pwa:address) whose range is urn:address
  • IdAS POV: is an IAttribute, obtained from the IDigitalSubject retreived (way) above by calling either getAttribute() or getAttributes() e.g.:
IAttribute attrAddress = dsMary.getAttribute(new URI("pwa:postalAddress"));
// next line returns the URI containing "pwa:postalAddress"
URI uriAddressAttr = attrAddress.getType();

urn-address

  • schema POV: is a resource of type pwa:PostalAddress
  • IdAS POV: is an IPropertyValue sub-interface. Given the IAttribute instance found above, we could call getValue() or getValues() this would return an IPropertyValue instance(s):
IPropertyValue valueAddress = attrAddress.getValue();
// next line returns the URI containing "pwa:PostalAddress"
URI uriAddressVal = valueAddress.getType();
// next line returns false, indicating this is an IComplexValue
boolean b = valueAddress.isSimple();

pwa:city

  • schema POV: is an RDF property (pwa:city) whose range is an xsd:string
  • IdAS POV: is an IProperty obtained by calling getProperty() or getProperties() on the IComplexValue above. It may then be used to produce the pwa:city value (e.g.):
IProperty propCity = valueAddress.getProperty(new URI("pwa:city"));
IPropertyValue valueCity = propCity.getValue();
// next line returns true, indicating valueCity is an ISimpleValue
boolean b = valueCity.isSimple();
// next line returns the URI containing "xsd:string"
URI uriCityVal = valueCity.getType();
// next line returns the Java String object containing "Provo" (see table at ISimpleValue)
String sCityVal = (String)valueCity.getData();

See Also