From XML Schema to XtextBy Agnes Fröschl, Bernd Landauer, and Bernhard Müller.
Since the invention of Extensible Markup Language (XML) [Harold], it has gained a great popularity. The language is nowadays used as configuration and exchange format for a vast amount of applications. Some examples are the GPS Exchange Format (GPX), Scalable Vector Graphics (SVG) or configuration files for Computer Numeric Control (CNC) machines for production data. To make sure a provided XML file is valid, XML Schema Definition (XSD) [Gao] was introduced. However, XML and XSD are both optimized for machine processing and not human readability [Badros].
To bring language engineers, i.e., for example, the person who designed the instruction reader for a CNC machine and domain experts, i.e., for example, the person who operates the CNC machine, together, the XMLText Framework [Neubauer] has been introduced. It provides a transformation from XSD to Xtext-based Domain Specific Language (DSL) [Eysholdt, Tolvanen] with a more comprehensive and easily human readable concrete syntax.
In this work, we describe various XSD features that are not yet supported or limited by the XMLText transformation as well as our efforts to extend it . The target is to escape fixed concrete syntax and provide an easy to use and customizable syntax for non-language engineers. Another important key feature is to keep backward compatibility, such that systems, which rely on XML files as an input source, do not need to be adapted to fit the new syntax.
Extension of the XMLText frameworkAlthough some features are already implemented in XMLText, XSD provides an extensive amount of advanced features, for which support has still to be created. Our work mainly focused on extending the Ecore and Xtext Grammar generation.
Data types were our first area of contribution. Instead of proper Xtext Terminals, only stubs were created. We implemented valid Terminals for various data types. With this extension, only minor efforts were necessary to implement the support of various length restrictions for strings.
A more advanced feature was the implementation of mixed content, i.e., the support for the mixed=true XSD attribute. This construct allows the mixing of various newly defined elements in the created syntax or, in other words, text content with arbitrary text elements between tags.
Finally, we implemented ID and IDREF to ensure unique values for certain elements to which others can refer to. The related features KEY and KEYREF have been examined but their support has not been implemented due to the usage of complex XPath rules which are beyond the scope of our project.
Concrete Syntax DSLMaking the concrete syntax DSL even more readable and customizable, we explored the possibilities of Xtext to adapt the concrete syntax and style the appearance in the editor.
The figure below shows an example how a customized concrete syntax for a company hierarchy could look like. Other implemented extensions can be seen too, like date data type which yields an error if the date is not valid, e.g. month greater than 12. Auto-completion for IDREF values referencing available ID values. An arbitrary text content element between the named tags.
|customized concrete syntax DSL|
Future WorkThe XMLText framework targets a quite complex problem, not least because of the feature richness of XSD and respectively XML. There are several topics for further extensions. Future work may include following Topics:
- Implementation of further XSD features closing existing gaps,
- an XPath to OCL [Warmer] converter to fully support for example KEY and KEYREF XSD features,
- a fully automized generation of customized concrete syntax DSL, which includes a configuration wizard for syntax adaption,
- and a CSS interpreter for concrete syntax DSL styling.
[Badros] Badros, G.J.: JavaML: A Markup Language for Java Source Code. Computer Networks 33(1), 159-177 (2000).
[Eysholdt] Eysholdt, M., Behrens, H.: Xtext: Implement your Language Faster than the Quick and Dirty Way. In: Companion Proc. of OOPSLA. pp. 307-309. ACM (2010).[Gao] Gao, Shudi, et al. W3C XML schema definition language (XSD) 1.1 part 1: Structures. In: W3C Candidate Recommendation 30.7.2 (2009).
[Harold] Harold, E.R., Means, W.S., Udemadu, K.: XML in a Nutshell, vol. 8. O'reilly Sebastopol, CA (2004).
[Neubauer] Neubauer, P., Bergmayr, A., Mayerhofer, T., Troya, J., Wimmer, M.: XMLText: From XML Schema to Xtext. In: Proceedings of the International Conference on Software Language Engineering. pp. 71-76. ACM, New York, NY, USA (2015).
[Tolvanen] Tolvanen, J., Kelly, S.: De ning domain-speci c modeling languages to automate product derivation: Collected experiences. In: Proc. of SPLC. pp. 198-209 (2005).
[Warmer] Warmer, Jos B., and Anneke G. Kleppe. The Object Constraint Language: Precise Modeling With UML. In: Addison-Wesley Object Technology Series (1998).
XMLText framework website: http://xmltext.big.tuwien.ac.at/