Menu

#38 how to use the import declaration!

open
Grammar (8)
5
2012-12-27
2012-12-23
Aicha
No

Hi,
I want to call a class declaration M (which is created in my principale class) in my current class, but I can not found the link between the declaration of the import in my new class and using this import.
I must every time search this class M and add it to my current model.
I didn't know how can I use the import utilities in my case.

If any body has an idea. Thanks

Discussion

  • Aicha

    Aicha - 2012-12-25
    • summary: use import in other class! --> how to use the import declaration!
     
  • Andrew W Crapo

    Andrew W Crapo - 2012-12-27

    I'm afraid that I do not understand the problem yet. Let me repeat what I think you are saying and then you can correct me.
    It sounds like you have two ontologies, which I will call http://sadl.org/ont1 and http://sadl.org/ont2, and that the second imports the first. It further appears to me that you have defined a class M in the first, i.e., http://sadl.org/ont1#M, and that you wish to refer to it (use it) in the second but it is not appearing as a defined class. Is that correct?
    Please provide some additional information. You are creating these ontologies in the SADL-IDE? What version of the SADL-IDE plugin? I don't know what some of the things you say might mean. For example, "I cannot find the link between the declaration of the import in my new class and using this import. I must every time search this class M and add it to my current model." A simple case of what I think you mean is as follows.

    I create a first model, ont1.sadl, which defines the class M:
    uri "http://sadl.org/Bug3598221/ont1" alias ont1 version "$Revision:$ Last modified on $Date:$".
    M is a class.

    I create a second model, ont2.sadl, which imports the first and uses M:
    uri "http://sadl.org/Bug3598221/ont2" alias ont2 version "$Revision:$ Last modified on $Date:$".
    import "http://sadl.org/Bug3598221/ont1".
    N is a type of M.

    This works fine for me. M is defined in the second model and recognized as a class.

    Andy Crapo

     
  • Andrew W Crapo

    Andrew W Crapo - 2012-12-27
    • assigned_to: nobody --> crapo
     
  • Aicha

    Aicha - 2012-12-27

    Thanks Andy for your response.

    No I am not using the SADL-IDE. I am trying to write my onto1 and 2 with Java (based on SADL v 2.1.7).

    Sorry if my request was not very clear, but you understand what I want to know.

    so my question here (referring to your example) is how I can define the ClassDeclaration "N". I will attach a file with a method which I used to create a class declaration usually.
    In my method I must have class M in my onto2 to create N. My problem is how can I just reference M and not re-create it or added it to onto2??

    I hope that I am more clear than my previous msg.
    Thanks.

     
  • Aicha

    Aicha - 2012-12-27
     
  • Andrew W Crapo

    Andrew W Crapo - 2012-12-28

    From your code snippet I am still not able to get a clear idea of what your code does. For example, you pass in the superclass as an instance of ClassDeclaration. Would that be com.ge.research.sadl.sadl.ClassDeclaration? In which case, why are you doing that? This interface class and its implementation are code auto-generated by the Xtext plug-ins for use when parsing SADL models and converting them to OWL. SADL uses Jena to actually create the ontologies (classes, subclasses, etc.), so if you aren't parsing a SADL file why not just use Jena? And if you are parsing a SADL file, why not let the SADL code do it for you and generate the model? I have a very difficult time understanding why you are using these classes in direct Java calls, when the classes are created for use in calls to SadlModelManager, which calls ModelManager, which uses Jena to actually do the work.

     
  • Nobody/Anonymous

    Yes wa are using the com.ge.research.sadl.sadl.ClassDeclaration.

    I am also lost and I can not understand clearly your message.
    I will try to re-explain our problem.

    our first step is to create a first sadl model.
    the second step is to create another sadl model which use some classes from the first one. So, we are parsing the first model to find the desired class and create for example some instances in the second model (see example below).
    Model A:
    Person is a class.
    Model B:
    import "A.sadl".
    John is a Person.

    so, our problem is that we cannot save the B model as shown above.
    The only way we currently find is to add the referenced class Person in the model contained in the B resource.
    That is we end up with a file like:
    Model B:
    import "A.sadl".
    Person is a class.// to create the instance John we must add this line
    John is a Person.

    As Person is already defined in the A model, we should not define it again in the B model. But we fail to correctly create the second resource when we don't add Person to the B model.

    We are not using the SADL-IDE but we are developping all our models using the java API.

    Thank you.

     
  • Nobody/Anonymous

    Thanks for the additional explanation. I hope this will help us converge.
    com.ge.research.sadl.sadl.ClassDeclaration is an auto-generated class used by the Xtext environment underlying the SADL-IDE. I believe that it is created as a result of the ANTLR parser parsing a sadl model file. In the SADL-IDE, an instance of ClassDeclaration is created by the lexer/parser and sent in an appropriate call to a method in com.ge.research.sadl.builder.SadlModelManager, which in turn calls com.ge.research.sadl.model.ModelManager. ModelManager uses the Jena API to actually create the in-memory OWL model, which can then be saved to a file via the same Jena API.
    If the sadl file for Model B in your example were to be parsed by the SADL language implementation in Xtext, it would result in multiple calls to SadlModelManager using various auto-generated classes like ClassDeclaration. These include:
    1) a call to SadlModelManager.caseModelName(ModelName object), which creates the Jena OntModel and establishes base URI and namesace of the model
    2) a call to SadlModelManager.caseImport(Import object), which would cause the Jena OntModel for this model (Model B) to import Model A. This is what causes the class Person to be defined in Model B. Note that that Model A is imported from the OWL file generated when Model A was saved, not from the SADL version of Model A.
    3) a call to SadlModelManager.caseInstanceDeclaration(InstanceDeclaration object), which creates in the in-memory Jena OntModel for Model B an instance of the class person.
    Note that SadlModelManager.caseClassDeclaration(ClassDeclaration object) is not called at all. It would be called when loading Model A into the editor but not when loading Model B. Class Person is defined in the OntModel of Model B by processing the import statement in Model B.

    I am still missing why you would be trying to do what you are doing. The only reason SADL exists is to provide a controlled-English frontend to OWL, along with rules, tests, etc. If you want to use the SADL language to express models and then load them into memory, then use the Xtext-based DSL to do so. It is possible, as illustrated in the com.ge.research.sadl.tests project. If you don't want to use the Xtext-based processing to generate the in-memory Jena OntModels, then I think it would make much more sense to use Jena directly.

     
  • Nobody/Anonymous

    Thank you very much for your detailed response. It helps us to better understand.

    About your last remark, we want to create ontologies from different resources (some metadata files). These ontologies may be used in various ways then (we think about reasoning...), but we'd like to let the users edit their ontologies with the SADL editor when necessary.
    So we could work with Jena and Owl files as you suggest, but in this case, we would want to be able to edit an ontology with the SADL editor (this requires to be able to convert an OWL into SADL).
    As SADL is based on EMF and Xtext, it should be possible to do that, don't you think?

     
  • Andrew W Crapo

    Andrew W Crapo - 2013-01-04

    It is definitely possible to convert an OWL file to SADL as along as it is OWL 1.0. Such a conversion would not be unique, meaning there would be multiple possible SADL representations, but they would all be equivalent. We have taken this approach of converting data to OWL and then translating to SADL on a limited basis. If you do an OWL to SADL translator, is there any chance it would be made Open Source?

     
  • Nobody/Anonymous

    Hi,

    I create two simple classes to illustrate my problem (how we create the sadl file with the Api Java).
    you will find the class SimpleModel.java which create a first simpleModel and the class NewModel.java to create a new model referencing the other.

    for creating a convert from OWL to sadl, If

     
  • Nobody/Anonymous

    for creating a converter from OWL to sadl, I am doing a thesis in a company and I must get the ok to made it Open Source.

    you will find enclosed the two java files.

    Thank you.

     
  • Aicha

    Aicha - 2013-01-07
     
  • Aicha

    Aicha - 2013-01-07
     
  • Nobody/Anonymous

    Hi Crapo,

    I did the same thing with Jena as you proposed.
    -simpleMJena.owl with two conpets (Person, Custoner)
    -newMJena.owl with one instance Jonh of class Person (Person of the simpleMJena.owl)
    You will find attached the two files Java for the two ontologies.

    Is my import of the class Person in newMJena.owl correct?

    Would you please response my previous message if you have any idea. thank you in advance.

     
  • Aicha

    Aicha - 2013-01-09
     
  • Aicha

    Aicha - 2013-01-09
     
MongoDB Logo MongoDB