Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText importing a specific file extension(Importing a specific file extension)
XText importing a specific file extension [message #1794744] Wed, 05 September 2018 23:31 Go to next message
Agner Ballejo is currently offline Agner BallejoFriend
Messages: 3
Registered: September 2018
Junior Member
Hello everyone, I'm new here and I'm new with Xtext!

I'm trying to make a grammar for importing Schemas, for example, XSD.
I'm trying to import using "importURI" attribute, but I'm not getting any success on this...

See my grammar code below:
Import:
	'import' importURI=STRING 'as' name=ID
;


And i also added a new extension for ResourceServiceProvider as XSD:
<extension
       point="org.eclipse.xtext.extension_resourceServiceProvider">
    	<resourceServiceProvider
          class="mygrammar.resource..XsdResourceServiceProvider"
          uriExtension="xsd">
    </resourceServiceProvider>
 </extension>


But when I test with, for example, the following syntax: import "test.xsd" as Idm
My ResourceServiceProvider is never called, I tried to overrides ImportUriGlobalScopeProvider, but the method "getScope" is never called with my resource...

And I also need to create a "free" URI, for example, I would like to use a URI like: "C:/test.xsd".

I tried to follow some topics here, but without success :/

Can anyone help me with this? ;)

Thanks a lot!
Re: XText importing a specific file extension [message #1794802 is a reply to message #1794744] Thu, 06 September 2018 17:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
how do you call this code?
standalone / eclipse ? if eclipse is the xsd file in a project. if standalone how do you populate the resourceset. imports just make things visible. its not a follow the import and load the resource


here is an example on how to provide a resource service provider for uml
https://www.dietrich-it.de/xtext/uml/iresourceserviceprovider/2011/07/17/xtext-2-0-and-uml.html


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText importing a specific file extension [message #1794807 is a reply to message #1794802] Thu, 06 September 2018 19:19 Go to previous messageGo to next message
Agner Ballejo is currently offline Agner BallejoFriend
Messages: 3
Registered: September 2018
Junior Member
Hello Christian, thank you for your reply.

I'm using Eclipse!

Since i created this topic i got a success when I put XSD file in the same project, but i would like to load a file outside the project, using my own strategy for reading..
And how can i get the "name" attribute for Import?

I will read your shared link

Thank you!
Re: XText importing a specific file extension [message #1794813 is a reply to message #1794807] Fri, 07 September 2018 04:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you please exüplain what you mean by

Get Name Attribute

E.g. with a code or pseudo code snippet


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText importing a specific file extension [message #1794896 is a reply to message #1794813] Mon, 10 September 2018 13:48 Go to previous messageGo to next message
Agner Ballejo is currently offline Agner BallejoFriend
Messages: 3
Registered: September 2018
Junior Member
Hello Christian,

I mean "name" attribute in import definition (bold):

Import:
'import' importURI=STRING 'as' name=ID
;
Re: XText importing a specific file extension [message #1794897 is a reply to message #1794896] Mon, 10 September 2018 14:39 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
import.getName()? please give more context

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Need help to implement an ambiguous grammar (ACSL grammar)
Next Topic:Syntax for bitwise AND operator
Goto Forum:
  


Current Time: Sat Apr 20 05:29:22 GMT 2024

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

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

Back to the top