0

Trying to make a meta model for Mongoose and MondoDb, using metamodeling concepts, eclipse and xtext.

I am trying to assign object that i created in my test.mydsl file to another object in the same file, but i get error in my test.mydsl file.

I am trying to assign created Schema(sc1) object to Collection(col) object, but currently getting an error

error message

the feature 'validate' of 'paket.impl.NCollectionImpl@67d76e14{platform:/resource/test/classes/test.mydsl#//@collections.0}' contains an unresolved proxy 'paket.impl.SchemaImpl@361d8284{platform:/resource/test/classes/test.mydsl#|0}'

my grammar for Schema and Collection

Schema returns Schema:
    {Schema}
    ('Schema' '<' Name=EString) '>'
    '{'
        (schemaExpression+=Expression ( "," schemaExpression+=Expression)*)?
        (verificationDocumentElement+=VerDocElement ( "," verificationDocumentElement+=VerDocElement)*)?
    '}';

NCollection returns NCollection:
    {NCollection}
    ('Collection' '<' Name=EString) ',' (validate=[Schema|EString])? '>'
    '{'
        (document+=Document ( "," document+=Document)*)?
    '}';

my test.mydsl

Database<db1>{

    Schema<sc1>{
        var ja=lp   
        ime:{
            type:String,
            min:123.0
        }

    }
    Collection<col, sc1> 
    {

    }
}

I tried all, but unsuccessful.

Any ideas what to do?

Thanks

EDIT:

Maybe I was not clear enough. The major problem is with "validate" attribute in NCollection rule. When I create my Schema object(sc1 in test.mydsl) and then try to pass it to Collection(col in test.mydsl) as a "sc1", the "validate" attribute cannot accept it like string, and I don't know how to pass it like Schema object. I hope this explanation helps.

branko terzic
  • 654
  • 1
  • 8
  • 27

2 Answers2

0

Please try to use name=EStringinstead of Name=EString as Xtext imposes a special default semantics for the attribute name. Also I recommend to look into the documentation.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23
  • Tnx for answer, but actually that works just fine. I have a problem with (validate=[Schema|EString]). As i post in test.mydsl file, when i try to pass sc1 as a parameter in Collection, xtext can not pass this created sc1 Schema object to validate attribute in Collection. I cannot simply pass sc1 as a Schema object, even validate can accept Schema and EString as well. – branko terzic Apr 20 '15 at 10:39
  • I understand you did try to use `'Schema' '<' name=EString` rather than `Name=EString`? – Sebastian Zarnekow Apr 20 '15 at 10:47
  • How does your definition of EString look like? – Sebastian Zarnekow Apr 20 '15 at 11:37
  • Defined like this: EString returns ecore::EString: STRING | ID; terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; terminal STRING : '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"' | "'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'" – branko terzic Apr 20 '15 at 11:56
  • Did you register a value converter for EString that strips the quotes? – Sebastian Zarnekow Apr 20 '15 at 16:18
  • I didn't understand quite well. Can you give me an example of what do you mean? You mean something like this: 'sc1' in test.mydsl? – branko terzic Apr 21 '15 at 09:19
0

The code

validate=[Schema|EString]

says: I want a schema reference via a String, i.e. "sc1" instead of the name. Xtext doesn't know how to convert a string into a reference. Use this instead:

validate=[Schema]

which is short for

validate=[Schema|ID]

That will use the name of the Schema as reference. Note that you have to write

('Schema' '<' name=EString) '>'

i.e. lower case name to make it work. Xtext has special handling for properties called name.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • Thank you so much for an answer. "Name" property is actually a derived property from parent abstract EClass called "NamedElement", and it serves me to give a name to my Schema. And when write name instead of Name it returns me an error: Cannot find compatible feature name in sealed EClass Schema from imported package http://www.project.com/paket: The type 'Schema' does not have a feature 'name'. – branko terzic Apr 21 '15 at 14:49
  • I changed Name(i.e. upper case) into name(i.e. lower case) into a Schema definition, so role for Schema can look like: ('Schema' '<' name=EString) '>', and now it works. Thank you for a help. – branko terzic Apr 21 '15 at 15:26