rubyxmldslbuilder

Implementing a DSL in Ruby for generating domain specific XML


I'd like to implement a DSL in Ruby for generating domain specific XML documents (i.e. XML which conforms to a specific schema). I can use e.g. Builder to write the XML in Ruby, which is already a great improvement on writing the XML manually, but I'd also like:

So my plan at the moment is to extend Builder with the convenience methods and ignore the schema restriction side of things for now.

My questions to the community are does this sounds like a reasonable plan, and more importantly, are there any DSLs out there that extend Builder in some fashion that I could use for inspiration.

Unfortunately googling for ruby, xml, builder, extend, dsl, ... doesn't return very interesting results.


Solution

  • I don't know if it uses Builder, but haml is certainly worth looking at.

    I also found this article which mentions many more, of those, probably Markaby is the closest to your idea, but the last commit on GitHub is from 2008. Surely looking at _why's code should be entertaining.