Thursday, February 28, 2008

Groovy's MarkupBuilder and Namespaces

Yesterday Kit Plummer posted an XML example using Ruby to demonstrate how to include attributes and namespaces. So I went on a quest to duplicate his output using Groovy to compare the difference and evangelize.

Here is the desired output:

<person:person text='test'>
Using the Groovy Console, and Groovy's ninja-like MarkupBuilder, you can execute the following script to get attributes and namespace prefixes:
import groovy.xml.MarkupBuilder

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

xml.'person:person'(text: 'test') {

println writer.toString()

If you prefer to define a default namespace instead do this:
xml.person(xmlns: '', text: 'test') {
Finally, here is an example that uses them all:
xml.'person:person'('xmlns:person': '', xmlns: '', text: 'test') {

This will output:
<person:person xmlns:person='' xmlns='' text='test'>
I think it's more readable than the Ruby example and definitely much better than the equivalent Java code.

By the way, I attempted to use this online syntax highlighter and did not like it. Does anyone know of a good online syntax highlighter?

Friday, February 8, 2008

Volunteering as Hudson OpenSolaris IPS maintainer

Starting with an open request by Hudson project lead Kohsuke Kawaguchi, I volunteered to be an OpenSolaris IPS package maintainer for Hudson. Not sure I am qualified but I am a huge Hudson advocate and am looking forward to the challenge.

My main goals are to:

  • Learn more about how open source communities work
  • Go in the opposite direction of my comfort zone and learn something new
Stay tuned on this Hudson wiki page I have created to document this effort.

Thursday, February 7, 2008

Grails 1.x to add Maven 2 plugin support

From an InfoQ interview with Grails project lead Graeme Rocher discussing the recent release of Grails 1.0 and its future:

In addition, we plan to include Maven 2 support out of the box with Grails through a Maven 2 plug-in that hooks Grails into the Maven life cycle. Remember Grails is not just a web framework, but a software stack which aims to solve every part of the software life cycle from the build system to the ORM layer.
For those of use already using maven2 this is pretty good news. Not that there weren't ways to get around it, but it will be nice to have maven2 support out of the box.