The aim of this is to automatically generate TextMate language grammars from RELAX NG XML Schemas. As both TextMate grammars and RELAX NG Schemas can be written as XML, our program mainly consists of a XSLT transformation.
Note that RELAX NG schemas can be generated from DTDs or W3C XML Schemas using tools such as Trang.
Currently, XML namespace are not dealt with. You’ll have to modify your RNG schemas so that the RNG namespace is the default namespace — both empty and not defined. See known issues.
./rng2txmt.sh schema.rng
Generates the language grammars schema.plist.xml and schema.plist in the "Generated Language Grammars" repository.
Everything should run directly on Mac OS X 10.5 Leopard. Developer Tools might need to be installed.
xsltproc
(compiled withexslt
support)plutil
- a
sh
compatible shell
What it currently does. Not much.
- look for and mark invalid tags or attributes under or in a given tag
- avoid to create empty repository entries
- give a tag-aware scope for attributes (aim is to generate auto-completion lists aside)
What I would like it to do at some point in a not-so-far future.
-
improve scope definitions
-
(in progress) have parent-tag-aware scopes for auto-completion of tags, i.e.
<a> <b/> </a> <!-- b is in a scope related to a -->
<b attr="value" /> <!-- attribute is in a scope related to b -->
-
actually generate completion list.
-
have basic namespace support
Issues which are not on considered a priority or currently seem unavoidable.
- TextMate language grammars are deterministic. I thus don’t think it’s possible to generate (exact) grammars from non-deterministic RNG schemas. However, these are rare in real-life. In particular, both DTDs and W3C XML Schemas always are deterministic.
- Dealing with XML namespace (especially default namespace) in XSLT stylesheets is quite a mess. Currently, only the default namespace is dealt with. Currently, one thus have to make edits
- No management of many RNG construction.
- No management of file reference.
- No indentation of the generated plist. TextMate can however indent results by itself.
- Probably too many scopes.
- Relax NG, a schema language for XML
- TextMate, a text editor for Mac OS X
- TextMate Language Grammars, the documentation of TextMate concerning language grammars
- Trang, a XML Schema and DTDs from/to RELAX NG converter