# XML2RB, day 2

**URL:** <https://www.ruby-forum.com/t/xml2rb-day-2/100412>\
**Category:** Ruby\
**Created:** [July 28, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/xml2rb-day-2/100412 "2006-07-28T20:45:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikveen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/59ef9b/32.png) [@erikveen](https://www.ruby-forum.com/u/erikveen)\
**Post date:** [July 28, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/xml2rb-day-2/100412/1 "2006-07-28T20:45:57Z")

</div>

I’ve added day two to this XML2RB experiment:

[http://www.erikveen.dds.nl/xml2rb/index.html](http://www.erikveen.dds.nl/xml2rb/index.html)

gegroet,  
Erik V. - [http://www.erikveen.dds.nl/](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  
build.rb

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…
