== ontoMDE-core stand-alone usage basic usage of ontoMDE implies the following steps: * create or use an existing ontology (a RDF model) * create methods an ruby classes to do whatever you want (generate Java/C++ code, transform your model, whatever). * load the ontology model into Ruby * load an ontology instance (data) into ruby == RDFS class loading When invoking loadMetaModelFromFile, ontoMDE does the following things: * Create a class for every RDFS class prefixed by C (ex: RDFS class with uri uml:DataType produces a ruby class Cuml_DataType) * Create a module for every RDFS class prefixed by M (ex: RDFS class with uri uml:DataType produces a ruby module Muml_DataType) * Map RDFS generalization into module imports (ex: ruby class Cuml_DataType includes module Muml_DataType and Muml_NamedElement because RDFS class with uri uml:DataType inherits from uml:NamedElement) * Creates Ruby property in module class for every RDF property (ex: Muml_NamedElement has a uml_name property) Note:examples are taken from UML MetaModel included in ontomde-uml library == Property accessors ontoMDE offers several accessor methods for accessing a property. Accessors name derive from property name. If a property name is for example, uml_name, accessors will be uml_name, uml_name_one, uml_name_one0, ... === returns a list of elements. example: uml_name, uml_ownedElement === _one returns first element. Fails if list does not contain exactly one element. example: uml_name_one === _one0 returns first element or nil if list is empty Fails if uml_name list contains more than one element. example: uml_name_one0 === ? returns true or false Because RDF stores string literal "true" or "false" this method must be used instead of _one if a boolean value is expected. example: uml_isOrdered? , uml_isAbstract? === _inv returns elements important note: _inv is *not* ordered. example: uml_ownedElement_inv? === _inv_one returns first and only element in _inv. Throws an exception if _inv does not contain exactly one element. example: === _inv_one0 returns first and only element in _inv, null if empty. Throws an exception if _inv contains more than one element. example: ==Code generator facilities ontoMDE-core provides facilities for writing into a file without carrying around file descriptors. A write method is defined on every ontoMDE-core model object that can be used anywhere in code, as long as it is called from inside a writeSession. mtk_writeSession("yourFileName.java") { write("Package\n) (...) } File generated by ontoMDE-core are in fact separated into blocks. Certain blocks can be preserved on subsequent generation. This is usefull if a file is meant to be customized, by for example, providing an implementation for a java method. Generated code will be in a protected block if it is inside a mtk_protected clause. mtk_writeSession("yourFileName.java") { write("Package\n) (...) mtk_protected { write ("this is inside protected zone") } write ("this is *not* inside protected zone") } ==Context handling facilities