Today, I'm stuck to bed due to something that appears to be a Gastroenteritis. Don't worry, I won't give any detail, but wow, I've forgot I contain so much fluids.
Please notice that there is no relation between XLinq and Gastroenteritis.
I've read with pleasure this article about a new way to create xml files using ruby. And I've wonder how can I have the same thing on Mono. All I needed, was a language which supports duck typing. I have boo. I'm not a sitting duck Miles!
I took me a little more than an hour to have something working like the ruby library. I've translated the end of the article, which is about the creation of a xhtml document. Here is my boo version
import System
import NUnit.Framework
[TestFixture]
class XhtmlTestFixture:
[Test]
def go():
x = XmlBuilder(Console.Out)
x.Instruct_("xml",
{"version" : "1.0", "encoding" : "utf-8"})
x.Declare_("html", "-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")
x.html() do:
x.head() do:
x.title("My Projects")
x.style({"type" : "text/css"}) do:
x.Text_("body {font-family: courier new;}")
x.body() do:
x.h1("My projects")
x.p("The projects I'm working on:")
x.ul() do:
x.li("Mono")
x.li("Cecil")
x.li("...")
Here is the project of the whole thing, including unit tests.
Notice that it could of course be improved, especially, the XmlBuilder thing could extends XmlTextWriter. But this was simple enough for me. Cool huh?