Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Loading and navigating a DSL Model
Loading and navigating a DSL Model [message #916144] Tue, 18 September 2012 15:59 Go to next message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi

I am a beginner in Xtext and have a few basic questions. Maybe you can give me some examples/hints or point me into the right direction. Smile

With e.g. XML I have the possibility to load an existing file into a DOM representation. This allows me to navigate and traverse through the tree at runtime.

Now I would like to replace this XML by a new DSL using Xtext. Does Xtext provide anything that gives me the same possibilities as with the XML?

So after defining the DSL and creating a sample file, is there a possibility to programmatically load this example file into a memory model using Xtext libraries?
And if yes, how can this be achieved and how can the model then be traversed to access the information of the example file?

Thank you very much for your help
matthias
Re: Loading and navigating a DSL Model [message #916156 is a reply to message #916144] Tue, 18 September 2012 16:15 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

On 18.09.12 08.59, Matthias Villiger wrote:
>
> I am a beginner in Xtext and have a few basic questions. Maybe you can
> give me some examples/hints or point me into the right direction. :)

You should have some understanding of EMF to utilize Xtext, like
modeling with Ecore, loading resources and navigating EObjects.

> Now I would like to replace this XML by a new DSL using Xtext. Does
> Xtext provide anything that gives me the same possibilities as with the
> XML?

When Xtext parses a file, you get a DOM consisting of instances of your
Ecore classes assembled into a hierarchy corresponding to the parsed
file's text.

> So after defining the DSL and creating a sample file, is there a
> possibility to programmatically load this example file into a memory
> model using Xtext libraries?

Xtext registers a so-called resource factory for a file extension, so
whenever such a file is loaded by EMF's the parser will kick in and
build the EObject structure for you.

> And if yes, how can this be achieved and how can the model then be
> traversed to access the information of the example file?

When you have loaded the resource, you just traverse its contents.

Hallvard
Re: Loading and navigating a DSL Model [message #916607 is a reply to message #916144] Wed, 19 September 2012 08:17 Go to previous message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi Hallvard,

Thank you very much for the fast reply. This did help me a lot. I have my things working already!

regards,
matthias
Previous Topic:deleted
Next Topic:open editor checked by Xtext
Goto Forum:
  


Current Time: Thu Apr 25 05:50:16 GMT 2024

Powered by FUDForum. Page generated in 0.03364 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top