我可以将 XText 用于涉及 XML 文件类型的 DSL 吗?
我定义了一个小型 DSL,它主要以不同类型的 XML 文件和一些属性文件的形式编写。这工作得很好,但我希望创建一个 Eclipse 编辑器,以便初学者更容易编辑这些文件(我已经有一个可用的解析器)。
主 XML 文件可以引用 .properties 文件中的某些项目,反之亦然。主 xml 文件还可以引用其他 XML 文件。某些选项应该仅在基于 .properties 文件的内容和基于可添加到 DSL 项目的一些 osgi 插件的主 xml 文件中可用(语法是动态的,具体取决于上下文)。语言的结构是固定的,但每个属性中可用的选项或属性本身的选择会根据插件 .jar 文件中包含的元数据而变化。
问题:
XText 是否支持动态语法(验证根据外部因素而变化)?
XText 支持 XML 文件/.properties 文件吗?
非常感谢您提前提供的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请阅读 Xtext 文档。
Xtext 使用语法定义自动验证语法。此外,您可以用 Java 或 Check 编写任意验证。
当然,如果您为它们定义语法。 ;) 两者都不太困难。
Please read the Xtext documentation.
Xtext automatically validates the syntax using the grammar definition. Additionally, you can write arbitrary validations in Java or Check.
If you define a grammar for them, of course. ;) Neither of them are too difficult.
我不完全明白你在追求什么,但是如果你有一个 XSD,你是否考虑将其转换为 Ecore 模型,然后为其构建 Xtext 语法?或者,如果您从头开始,请首先构建 DSL 语法,然后将 ecore 导出为 XSD,并使用我刚刚在我的 http://blog2.vorburger.ch/2012/07/xtext-xml.html ? HTH。
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.
如果您不必拥有 XML / XSD,那么本质上您所追求的实际上是拥有一个可读的(例如类似 JSON,但强类型?)“通用”DSL,用于受某种“元”约束的数据结构。 model”(比如用 XCore 表示,它是 EMF Ecore 模型的 DSL,您可以从 XSD 导入它..),然后可能是我的 EMF 简单对象表示法 ESON(前 EFactory),位于 https://github.com/vorburger/efactory 您感兴趣吗?
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?