简体   繁体   English

我可以将XText用于涉及XML文件类型的DSL吗?

[英]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. 我已经定义了一个小型DSL,它主要以不同类型的XML文件的形式与一些属性文件一起编写。 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). 这非常有效,但我希望创建一个Eclipse编辑器,以便为初学者更轻松地编辑这些文件(我已经有了一个有效的解析器)。

The main XML file can reference some items from the .properties files and vice-versa. 主XML文件可以引用.properties文件中的某些项,反之亦然。 THe main xml file can also reference other XML files. 主xml文件也可以引用其他XML文件。 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). 某些选项应仅基于.properties文件的内容在主xml文件中可用,并且基于可添加到DSL项目的一些osgi插件(语法是动态的,具体取决于上下文)。 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. 语言的结构是固定的,但每个属性中可用的选项或属性的选择本身都会根据插件.jar文件中包含的元数据而变化。

Questions: 问题:

Does XText support dynamic syntax (validation changes depending on external factors)? XText是否支持动态语法(验证更改取决于外部因素)?
Does XText support XML files / .properties files? XText是否支持XML文件/ .properties文件?

Thank you very much for your help in advance. 非常感谢您的帮助。

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? 我不完全理解你的目标,但如果你有一个XSD,你是否考虑将其转换为Ecore模型,然后为此构建一个Xtext语法? 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 ? 或者,如果您从头开始,首先构建您的DSL语法,然后将ecore导出为XSD,并使用我刚刚在http://blog2.vorburger.ch/2012/07/xtext-xml中发布的帮助器。 HTML HTH. HTH。

Please read the Xtext documentation . 请阅读Xtext文档

Does XText support dynamic syntax (validation changes depending on external factors)? XText是否支持动态语法(验证更改取决于外部因素)?

Xtext automatically validates the syntax using the grammar definition. Xtext使用语法定义自动验证语法。 Additionally, you can write arbitrary validations in Java or Check. 此外,您可以在Java或Check中编写任意验证。

Does XText support XML files / .properties files? XText是否支持XML文件/ .properties文件?

If you define a grammar for them, of course. 当然,如果你为它们定义语法。 ;) Neither of them are too difficult. ;)它们都不太困难。

如果您不必拥有XML / XSD,那么您所依赖的实际上更多的是具有可读性(比如JSON,但强类型?)“通用”DSL,用于受某种“元”限制的数据结构模型“(用XCore表示,这是一个EMF Ecore模型的DSL,你可以从XSD导入..),然后可能是我的EMF简单对象表示法ESON(ex-EFactory)在https://github.com / vorburger / efactory你感兴趣吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM