I also think that changing XML into functional code like this is quite natural, kudos for writing the module. I would post a more constructive comment, but right now I don't have a project that needs this kind of processing, and that's really the only way I'll get an idea of the strengths and weaknesses of this approach.