XML2RB, day 2

I’ve added day two to this XML2RB experiment:


Erik V. - http://www.erikveen.dds.nl/

“I’m walking this road. I’ve never here before. I don’t know
where it ends.”

… Although I was writing Ruby, I was still handling XML and,
above all, I was still thinking XML.

Can’t we just translate XML to Ruby code? In theory we could:
assume that we translate every tag in XML to a method call in
Ruby, than the attributes of the tag are the named parameters
of the call and the body of the tag (child tags and/or text) is
handled by the block.

Let’s take this XML:

This file builds freenet...

It can be translated to Ruby, almost line-by-line:

project(:default=> “dist”, :basedir=> “.”, :name=> “Freenet”) {
description {
text! "\n This file builds freenet…\n "

This Ruby code could run if we write a DSL library: ruby -r ant

Instead of writing an interpreter and coding against REXML, we
only have to build the DSL. Or can it be generated?..

Let’s turn theory into practice. After all, that’s the best
proof of a concept. “In theory, there’s no difference between
theory and practice; in practice, there is.”

This is just an experiment. Maybe, after a couple of days, I
say: “Stupid idea!” Maybe not. Let’s find out…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs