Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:12:05+00:00 2026-06-18T03:12:05+00:00

I know there is a simple solution for this but I have no idea

  • 0

I know there is a simple solution for this but I have no idea how to implement it.

I’m looking for how to implement the answer rather than what I need to do. Half the answer is already on this page:
Xtext cross referencing and scoping

My problem is with the grammar below:

DomainModel:
    "DOMAINMODEL" name=ID "{"
        "ENTITYS" "{"
            (Entitys+=Entity)*
        "}"
        "ENTITY_RELATIONSHIP" "{"
            (Relationships+=Relationship)*
        "}" 
    "}";

Entity:
    name=ID "{"
        (Attributes+=Attribute)*
    "}";

Attribute:
    StringAttribute | NumberAttribute | ImageAttribute;

StringAttribute:
    "STRING" name=ID;

NumberAttribute:
    "NUMBER" name=ID;

ImageAttribute:
    "IMAGE" name=ID;

// Relationship = [new table name] : [shared key name] -> ref_table(ref_id)
Relationship:
    name=ID ":" newEntityName=ID "->" refEntityName=[Entity|ID]"("refName=[Attribute|ID]")"; // <- Problem here

When I write the model, I cannot get the “refName=[Attribute|ID]” to reference to attributes inside an entity.
In the code below

DOMAINMODEL auctionHouse{
    ENTITYS {

       lots{      
          NUMBER id0
          NUMBER lotNo
          STRING name
          STRING priceEstimate
          STRING description
       }  
       auctions{
          NUMBER id1
          NUMBER date
          STRING description
       }
       auction_lots{
          NUMBER id2
          STRING lot_id
          NUMBER auction_id
       }

    }

    ENTITY_RELATIONSHIP {
        auction_lots : lot_id -> lots(id0) // <- Will not find 'id0'
        auction_lots : auction_id -> auctions(id1) // <- Will not find 'id1'
    }

}

How can I widen the scope?
How can I differentiate between two attributes with the same name but in different scopes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:12:06+00:00Added an answer on June 18, 2026 at 3:12 am

    The problem with the references is that they simply cannot be found in that scope, what you could do is introduce a qualified name and use that in your cross-reference and change your grammar accordingly, ie:-

    QualifiedName:
        ID ('.' ID)*;
    
    Relationship:
        name=ID ":" newEntityName=ID "->" refName=[Attribute|QualifiedName];
    

    Now it should be possible to reference by using the qualified ID:

    ENTITY_RELATIONSHIP {
        auction_lots : lot_id -> auctionHouse.lots.id0
        auction_lots : auction_id -> auctionHouse.auctions.id1
    }
    

    If you can’t change the grammar like this to make use of the default way Xtext handles names then you would need to look into providing your own qualified names, a great article for that is this Qualified Names Article

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there must be a really simple answer to this question, but I
I know this is a simple question for someone out there, but I have
I know there is no simple answer to my question but I would appreciate
I know there is a simple way to do this but I can't seem
I know there should be a simple fix for this, but im braindead at
Simple query, possibly impossible but I know there are some clever people out there
I feel there is a simple solution to this -- I've looked at other
First, I have a stateless bean which do a simple retreive, looking like this.
I know that there must be a really simple solution to the below problem
I just wish to know if there is a simple way to call a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.