English 中文(简体)
Can I use XText for a DSL involving an XML file type?
原标题:

I have defined a small DSL that is mostly written in the form of different types of XML files in conjuction with some property files. This works very well but I wish to create an Eclipse Editor to make editing these files easier for beginners (I already have a working parser).

The main XML file can reference some items from the .properties files and vice-versa. THe main xml file can also reference other XML files. Certain options should only be available in the main xml file based on the contents of the .properties files and based on some osgi plugins that can be added to the DSL project (the syntax is dynamic depending on context). The structure of the language is fixed but the options available in each attribute or the choice of attributes themselves changes depending on metadata contained in plugin .jar files.

Questions:

Does XText support dynamic syntax (validation changes depending on external factors)?
Does XText support XML files / .properties files?

Thank you very much for your help in advance.

最佳回答

Please read the Xtext documentation.

Does XText support dynamic syntax (validation changes depending on external factors)?

Xtext automatically validates the syntax using the grammar definition. Additionally, you can write arbitrary validations in Java or Check.

Does XText support XML files / .properties files?

If you define a grammar for them, of course. ;) Neither of them are too difficult.

问题回答

I don t completely understand what you are after, but if you have an XSD, have you considering turning that into an Ecore model, and then building a Xtext grammar for that? Or if you are starting from scratch, build your DSL Grammar first, then export the ecore as XSD, and use helpers like I ve just posted in my http://blog2.vorburger.ch/2012/07/xtext-xml.html ? HTH.

If you don t have to have XML / XSD, and what you are after in essence really is more having a readable (say JSON-like, but strongly typed?) "generic" DSL for data structures constrained by some sort of "meta model" (say expressed in XCore, which is a DSL for an EMF Ecore model, which you can import from a XSD..), then maybe my EMF Simple Object Notation ESON (ex-EFactory) at https://github.com/vorburger/efactory is of interest to you?





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签