Archive for the ‘XML’ Category

Flexibility

Wednesday, August 30th, 2006

I’ve spent the past hour or so with a co-worker trying to get a Cocoon+Java+RSS+MySQL+XSL+DELI system to do the simplest of tasks. What a nightmare. It is incredible in its flexiblitlity. I can’t think of much it can’t do. But what it does do is very little. It seems as though the chaps who built this system spent 90% of their time on the framework of the application and about 5% on the application itself. It has huge potential but all the bits that actually do things aren’t there. String replace? Nope. I had to find an XSL template that someone else had rewritten to get that.

It’s the autobahn without the Porsche. The scaffolding without the building. The bricks without the builder.

It’s cool and wonderful and so much fun to work with but ultimately it is insanity when all you want is to get the job done. The glass without the beer (thanks for that one, Elaine.)

This is where Ruby on Rails is kicking Java and .NET web-frameworks all over the park. They are visionary and capable of far more than Rails. But Rails actually does common tasks that you need to do. It is less flexible but ultimately more productive.

For those few edge cases that it can’t handle I’ll write a function in something else and pipe it in.

Ruby + OPML

Monday, August 28th, 2006

Ruby really is more productive. I wanted to add OPML support to a project of ours and from past .NET experience with this wasn’t looking all that forward to it. But rexml and rio came to the rescue.

Here is some sample Ruby code that extracts all the URLs from an OPML file:

opml_file = ''
rio('http://share.opml.org/opml/top100.opml') > opml_file
opml_doc = Document.new(opml_file)
urls = XPath.match(opml_doc, '//@xmlUrl')

That is it. rio does the hard work of saving the web-stored OPML file into a string. rexml does the hard job of parsing that string into an XML document and then we use XPath to find all of the xmlUrl attributes.

rexml comes with most standard Ruby installs and you can install rio with gem install rio. The rio documentation is here.

YAML and JSON

Tuesday, July 18th, 2006

In JSON on the Web, or: The Revenge of SML Simon talks about the growing use of JSON and YAML in competition to XML. Having used all three I have to say I like JSON a good deal more than YAML while XML is still useful. YAML actually really bugs me and I often stumble over its rigid formatting. I’d prefer Rails to use straight Ruby for it’s config files.

Simon says:

It also had the advantage of building right on an existing programming language, JavaScript, and could easily describe itself as JavaScript Object Notation (JSON).

Which is very true. It is lovely to use and requires no new concepts to learn.

Look at the JSON carefully!

It’s a subset of YAML, as it turns out. Well, not a perfect subset at first, but with the departure of JavaScript comments, it’s very close.

Technically yes but in practice not at all. YAML often trips me up when a text editor puts in a tab instead of a space or a value contains a colon or you have two blocks with the same name but different values. JSON just works nicely and you can format and align it pretty much anyway that suits your coding style.

I definitley see a good future for JSON but hope that YAML remains a config file language at most.