We’ve released a new set of Fabulator gems. These give us the better ways of defining structural elements and implementing classes. We’ll be building on these in the next releases to provide a general library scheme in XML.
The goal is to allow the creation of extension tag libraries in XML without having to write Ruby code. We want to reserve Ruby (or whatever lower-level language is used to build the enabling framework) for those extensions that can not be written given existing extensions and language capabilities.
The library concept is part of the core Fabulator gem. It provides a separate namespace for the library (http://dh.tamu.edu/ns/fabulator/library/1.0#). With a few new class methods that will be in the next release of Fabulator (0.0.8), the grammar extension is able to place itself within the library container:
<g:token g:name="LETTER" g:matches="[:alpha:]" />
<g:token g:name="NUMBER" g:matches="[:digit:]" />
<g:token g:name="LETTER" g:matches="[:upper:]" g:mode="upper"/>
<g:token g:name="LETTER" g:matches="[:lower:]" g:mode="lower"/>
<g:when g:matches="^^ [mode normal] LETTER NUMBER [mode upper] LETTER" />
If we map the ‘m’ prefix to the ‘http://example.com/ns/grammar’ namespace (corresponding to the l:ns attribute value), then we can run ‘m:something?(‘a0A’)’ and get back ‘true’. We can also run ‘m:something(‘a0A’)/NUMBER’ and get back the string ‘0’ (not the integer 0 though). We won’t get anything though when we run at against the string ‘a0a’ because the second ‘a’ doesn’t match the LETTER token in the ‘upper’ mode.
Our next step is to provide a mechanism in the Radiant Fabulator extension for managing libraries. Hopefully we can have that by the end of this week. We’ll release all of the relevant gems at that point.
Having a library capability and the grammar extension will allow us to put in one location all of the text patterns that we use in a project. Regular expressions won’t be magic values embedded in programs.