Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
XML2RB, day 2
Erik Veenstra
7/28/2006 6:43:00 PM
I've added day two to this XML2RB experiment:
http://www.erikve...
xml2rb/...
gegroet,
Erik V. -
http://www.erikve...
"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:
<project name="Freenet" default="dist" basedir=".">
<description>
This file builds freenet...
</description>
</project>
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...
----------------------------------------------------------------
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
XML2RB, day 2
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password