Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#35 create an sadl model: porblem with grammar!!

open
nobody
Grammar (8)
5
2012-08-22
2012-08-22
Aicha
No

Hi,

I want to create an sadl model. I start with an InstanceDeclaration. I follow the grammar existing in sadl.xtext but I have this error:

java.lang.RuntimeException: The value 'customer' is an invalid NAME
Semantic Object: Model.elements[0]->InstanceDeclaration.typeDecl->TypeDeclaration.instName->ResourceName'customer'
at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:66)
at org.eclipse.xtext.serializer.tokens.ValueSerializer.serializeAssignedValue(ValueSerializer.java:95)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:455)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:380)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_ResourceName(AbstractSadlSemanticSequencer.java:1713)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:653)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:215)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_TypeDeclaration(AbstractSadlSemanticSequencer.java:1842)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:725)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:222)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:380)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_InstanceDeclaration(AbstractSadlSemanticSequencer.java:1206)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:410)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:373)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_Model(AbstractSadlSemanticSequencer.java:1479)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:544)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:76)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:84)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:106)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:286)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1417)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:986)
at test.ReadItemConnectionFileMeta.test(ReadItemConnectionFileMeta.java:237)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

It is my first time to use sadl!! if somebody has an idea of this bug.
The code of the creation of my InstanceDecalaration is attached.

Thanks.

Discussion

  • Aicha
    Aicha
    2012-08-22

     
    Attachments
  • Andrew W Crapo
    Andrew W Crapo
    2012-08-22

    I am not really understanding what you are doing. SADL is an English-like language with grammar defined in SADL.xtext. You can't define an individual until you have defined the class to which it will belong. You have attached source code, but in the SADL IDE you write sentences, like this:

    Mammal is a class.
    Dog is a type of Mammal.
    Lassie is a Dog.

    So here we have declared the individual Lassie.
    L

     
  • Aicha
    Aicha
    2012-08-22

    Hi,
    thank you for your response crapo.
    I want to create this syntax: "Person is a class" like you mentionned in your example but I want to extract the deferent elements for an xmi file.

    I want to know how can I create my sadl model from an xmi file? how to write an sadl file from an xmi file?

    I understood from my little reading that I have to set the grammar for each element of the xmi file (for that I define the grammar for an instanceDeclaration).

    I am in the wrong way?

    Thanks

     
  • It sounds like you want to use Xtext to translate XML into SADL? I have not used Xtext in this way. The closest thing i am aware of is the JUnit tests for parsing SADL files, which parse a SADL file from code rather from the IDE. That might be similar to how one would parse the XML? Or do you already have an xml parser? If so, you can call the methods in the ModelManager class to construct and save a SADL model. Since SADL is a only a language for creating and maintaining OWL models, would you want to create the OWL model directly?

    In my experience translating XML to OWL there is more to it than just API calls--many domain-specific assumptions newer to bew specified...

     
  • Hello, I'm working with bsaicha.

    Actually, we'd like to programmatically create the SADL file from some other objects. For instance, we'd like to initialize an SADL file from an OWL file or from some other objects that we own. Then, we'd like to let the user manually enrich his model in the SADL editor.

    bsaicha's question is about serializing the SADL model.
    Actually, we're able to run this sample:

    Resource sadlRes = resourceSet.createResource(uri);
    SadlFactory sadl = SadlFactory.eINSTANCE;
    Model model = sadl.createModel();
    sadlRes.getContents().add(model);
    ModelName modelName = sadl.createModelName();
    modelName.setBaseUri("http://org.sadl.test");
    modelName.setVersion("1.0");
    model.setModelName(modelName);
    sadlRes.save(null);

    But as soon as we want to give an alias to the model by just adding:
    modelName.setAlias("Test");

    we got an exception saying:
    java.lang.RuntimeException: The value 'Test' is an invalid NAME
    Semantic Object: Model.modelName->ModelName
    at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
    at org.eclipse.xtext.serializer.tokens.ValueSerializer.serializeAssignedValue(ValueSerializer.java:65)

    We have the same kind of error when it comes to concepts (as shown in bsaicha's code sample).

    Any idea about how we should serialize the SADL model?

     
  • after some debugging, the serializer is expecting a rule named ID instead of NAME.
    If I change the
    I don't know exactly where I can change this. In a grammar file? which one?
    Is it a bug?
    Any idea is welcome.

     
  • Andrew W Crapo
    Andrew W Crapo
    2012-09-04

    I'm starting to understand the question better--thanks!
    I've not used the code in this say. However, the grammar is defined in com.ge.research.Sadl.xtext. In particular, the rule for this is:
    ModelName :
    'uri' baseUri=STRING ('alias' alias=NAME)? ('version' version=STRING)? EOS;
    The Xtext-generated code for setAlias in com.ge.research.sadl.sadl.implModleNameImpl is:
    public void setAlias(String newAlias)
    {
    String oldAlias = alias;
    alias = newAlias;
    if (eNotificationRequired())
    eNotify(new ENotificationImpl(this, Notification.SET, SadlPackage.MODEL_NAME__ALIAS, oldAlias, alias));
    }
    If I set a break point and stop here when parsing a model being loaded into the editor, the argument is just a string and it works fine.
    Your question is really an Xtext question that I can't answer. You might try Xtext forums...

     
  • Andrew W Crapo
    Andrew W Crapo
    2012-09-04

    p.s. Are you using Xtext 2.1.0? That is the version that SADL is currently meant to work with.

     
  • Thanks for the reply.
    actually, my eclipse uses Xtext 2.3.1.
    Do you suggest me to downgrade to 2.1.0?

    The error seems to be related to xtext. We'll investigate further.

     
  • The error disappears if I replace "RULE_ID" by "RULE_NAME" in the "InternalSadl.tokens" file.
    But I'm quite sure that it's a good thing to do...

    I'm not familiar with neither with xtext nor with sadl yet. We'll see if we encounter other issues...

     
  • actually, I wanted to say "I'm not quite sure", but it seems that I can't edit a comment...

     
  • Howdy! Someone in my Facebook group shared this site with us so I came to look it over. I'm definitely loving the information. I'm book-marking and will be tweeting this to my followers! Superb blog and terrific design.
    north face jackets for women http://whlbnilmhs.wallinside.com/

     
  • Tremendous information thanks a lot for publishing. The facts are in all the content of the blog you will discover something to learn.
    <a href="http://softwarelivre.org/bottomcurler65/iwkcncpp5" title="Choose">Choose</a>