How do I parameterize grails/groovy xml MarkupBuilder .builder syntax?

muppet-modding

New Member
This is my first question on SO so be gentle. I am writing some groovy code to generate xml using MarkupBuilder. The problem is that I have to generate lots of similar xml for lots of different product types and the code will become huge if I cannot parameterize it. Showing you might help you understand better:\[code\]def writer = new StringWriter()def builder = new groovy.xml.MarkupBuilder(writer)builder.'cr:request'('xmlns:prodType': 'http://www.myurl/ProductType', 'xmlns:cr': 'http://www.myurl/customerRequest'){...// Bla bla lots of elements and attributes...builder.'prodType:ProductGroupName'(ID:"IDPRD"+itemCount, internalID:internalID){ productGroup("PGroup") productName("PName") ProductSpecificDetails() { param("paramA") stringValue("valA") param("paramB") stringValue("valB") ...\[/code\]I am trying to parameterize 'prodType:ProductGroupName' or even just ProductGroupName in the code above. This means I will allow me to pass in various values for this along with the param list in order to generate xml dynamically for different products.Looking online I have tried surrounding ProductGroupName with ${} and I also passing it as a map [:] but so far to no avail.Does anyone know how I can achieve this?Any help is much appreciated.Thanks,Paul.
 
Back
Top