开发者

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:

  • convenience methods that would generate a whole bunch of XML for me
  • and possibly a way to restrict the generator to a schema (not necessarily an XSD or a DTD, but the implementation could possibly generate only certain tags)

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.


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

I also found this article wich 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜