Skip to main content



      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 19:31 Go to next message
Eclipse UserFriend
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 13:28 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: XText importing a specific file extension [message #1794807 is a reply to message #1794802] Thu, 06 September 2018 15:19 Go to previous messageGo to next message
Eclipse UserFriend
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 00:03 Go to previous messageGo to next message
Eclipse UserFriend
Can you please exüplain what you mean by

Get Name Attribute

E.g. with a code or pseudo code snippet
Re: XText importing a specific file extension [message #1794896 is a reply to message #1794813] Mon, 10 September 2018 09:48 Go to previous messageGo to next message
Eclipse UserFriend
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 10:39 Go to previous message
Eclipse UserFriend
import.getName()? please give more context
Previous Topic:Need help to implement an ambiguous grammar (ACSL grammar)
Next Topic:Syntax for bitwise AND operator
Goto Forum:
  


Current Time: Sat Jun 21 01:37:25 EDT 2025

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

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

Back to the top