Create objecttype library within Coins

Uit COINS2
Ga naar: navigatie, zoeken

This page describes the creation of an objecttype library within Coins.

Therefore, the OWL editor TopBraid Composer will be used, see Tools.

It is recommended first to read the section OWL and Coins sample. There, the basic concepts of OWL and Coins are explained.

Create my Bridge class

In the OWL and Coins sample the myLibrary.rdf file has been created, already. In the library we want to define a Bridge as a subclass. This Bridge will have a (float) property hasBridgeLength. We will define this Bridge as a Coins-object and as a CataloguePart.

TBC Activate myLibrary and go to CataloguePart
  • make sure that the myLibrary file is active. You have to see a little arrow pointing to the right
  • in the Classes panel open the tree structure and select CataloguePart
TBC Activate myLibrary and go to CataloguePart
  • use your right mouse button and
  • activate Create subclass
TBC Create subclass Bridge
  • change CataloguePart1 to Bridge
  • press the OK button
TBC Create subclass Bridge
  • now, the Bridge is defined as a subclass of CataloguePart
  • however, it is a subclass of an Object also
TBC Multitype subclass Bridge Add existing
  • in the Class Form go to rdfs:subClassOf and
  • select the arrow pointing down
  • activate the command "Add existing..."
TBC Multitype subclass Bridge Select object class
  • open the tree structure
  • and select cbim-2.0:Object
TBC Multitype subclass Bridge Result
  • now, the Bridge is subclassed as a cbim-2.0:object and a cataloguepart

Making an instance of a Bridge

TBC Find the Bridge
  • make sure that the mySample file is active. You have to see a little arrow pointing to the right
  • in the Classes panel open the tree structure and select CataloguePart or Object
  • here you will find the myLibrary:Bridge
TBC Instantiate the Bridge
  • use the right mouse button and
  • activate the command Create instance...
TBC Instantiate the Bridge set resource
  • set the Name of new resource, eg. Bridge_1
  • press the OK button
TBC Instantiate the Bridge result
  • this results in a rdf:type that refers to myLibrary:Bridge

Create my hasBridgeLength property

In this sample a property is introduced that is special for a Bridge, in this case hasBridgeLength. In Coins we have the hasProperties relation in which has been defined that an object can have attributes. This hasProperties relation can be found in TBC in the Properties panel. In this way we can define that hasBridgeLength is a subPropertyOf of the hasProperties relation. However, this property must be used by a Bridge only. Therefore, we determain the Domain of this hasBridgeLength to be used by a Bridge only. Besides, we want to be sure that this property is used once. Therefore, a restriction will be made. Also, we define that a floatProperty can be used only for this property. This is set by using the rdfs:range.

TBC Find the Bridge
  • make sure that the myLibrary file is active. You have to see a little arrow pointing to the right
  • in the Classes panel open the tree structure and select myBridge
TBC Find the Bridge
  • open the Properties panel and select hasProperties
  • use the right mouse button and activate Create subProperty...
TBC Find the Bridge
  • set the name of the new relation, eg hasBridgeLength
  • press the OK button
TBC Find the Bridge
  • the Object Property Form shows the name of this relation, hasBridgeLength
  • next, you see that this hasBridgeLength is a subPropertyOf hasProperties
TBC Find the Bridge
  • select the arrow pointing down next to rdfs:domain
  • activate the command Add existing...
TBC Find the Bridge
  • open the tree structure and go to c-bim-2.0:Object
  • select Bridge
  • press the OK button
TBC Find the Bridge
  • select the arrow pointing down next to rdfs:range
  • activate the command Add existing...
TBC Find the Bridge
  • open the tree structure
  • select c-bim-2.0:FloatProperty
  • press the OK button
TBC Find the Bridge
  • double click on the Bridge in the Class panel. In this way you make this class active. It is shown by a small arrow pointing to right
  • go to rdfs:subClassOf and use the arrow pointing down for opening the pulldown menu
  • select Create restriction...
TBC Find the Bridge
  • select under hasProperties your new property hasBridgeLength
  • set the Restriction Type to Cardinality (exactly)
  • set Filler to 1
  • Press the OK button
TBC Find the Bridge
  • notice that under subClassOf you find a restriction for hasBridgeLength

Making an instance of a BridgeLength property

TBC Find the Bridge
  • make sure that the mySample file is active. You have to see a little arrow pointing to the right
  • in the Classes panel open the tree structure and select myLibrary:Bridge (double click)
  • go to the Instances tab and double click on Bridge_1
TBC Find the Bridge
  • notice that in the Resource Form a property myLibrary:hasBridgeLength has been added
TBC Find the Bridge
  • go to myLibrary:hasBridgeLength and select the arrow pointing down
  • activate the command Create and add..
TBC Find the Bridge
  • set the Name of new resource to: BridgeLength12m
  • press the OK button
TBC Find the Bridge
  • go to the Class panel and open the tree structure
  • select FloatProperty (double click)
  • in the instances tab you find the BridgeLength12m, double click it to make it active
TBC Find the Bridge
  • go to datatypeValue and select Add empty row
TBC Find the Bridge
  • set the value to 12. TBC will see this as a Float according to the icon with a F
  • go to unit and choose Add existing...
TBC Find the Bridge
  • choose in the right panel for unit:Meter

In this way we first defined a Bridge with a hasBridgeLengthProperty in myLibrary. Next, this Bridge is instantiated to Bridge_1 with a BridgeLength12m.

Results in RDF/XML

All the above settings results in 2 files: myLibrary.rdf and mySample.rdf

These are the contents of the myLibrary.rdf

<?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://coins.strukton.com/myLibrary#"
   xmlns:units-2.0="http://www.coinsweb.nl/units-2.0.rdf#"
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xml:base="http://coins.strukton.com/myLibrary">
 <owl:Ontology rdf:about="">
   <owl:imports rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf"/>
   <owl:imports rdf:resource="http://www.coinsweb.nl/units-2.0.rdf"/>
 </owl:Ontology>
 <owl:Class rdf:ID="Bridge">
   <rdfs:subClassOf>
     <owl:Restriction>
       <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:cardinality>
       <owl:onProperty>
         <owl:ObjectProperty rdf:ID="hasBridgeLength"/>
       </owl:onProperty>
     </owl:Restriction>
   </rdfs:subClassOf>
   <rdfs:subClassOf rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf#Object"/>
   <rdfs:subClassOf rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf#CataloguePart"/>
 </owl:Class>
 <owl:ObjectProperty rdf:about="#hasBridgeLength">
   <rdfs:range rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf#FloatProperty"/>
   <rdfs:domain rdf:resource="#Bridge"/>
   <rdfs:subPropertyOf rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf#hasProperties"/>
 </owl:ObjectProperty>
</rdf:RDF>

The contents of the mySample.rdf is put below:

<?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://coins.strukton.com/mySample#"
   xmlns:myLibrary="http://coins.strukton.com/myLibrary#"
   xmlns:cbim-2.0="http://www.coinsweb.nl/cbim-2.0.rdf#"
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xml:base="http://coins.strukton.com/mySample">
 <owl:Ontology rdf:about="">
   <owl:imports rdf:resource="http://www.coinsweb.nl/units-2.0.rdf"/>
   <owl:imports rdf:resource="http://coins.strukton.com/myLibrary"/>
   <owl:imports rdf:resource="http://www.coinsweb.nl/cbim-2.0.rdf"/>
 </owl:Ontology>
 <myLibrary:Bridge rdf:ID="Bridge_1">
   <myLibrary:hasBridgeLength>
     <cbim-2.0:FloatProperty rdf:ID="BridgeLength12m">
       <cbim-2.0:unit rdf:resource="http://qudt.org/vocab/unit#Meter"/>
       <cbim-2.0:datatypeValue rdf:datatype="http://www.w3.org/2001/XMLSchema#float">12</cbim-2.0:datatypeValue>
     </cbim-2.0:FloatProperty>
   </myLibrary:hasBridgeLength>
 </myLibrary:Bridge>
</rdf:RDF>

See also

OWL and Coins sample