The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

bromose (5) [Avatar] Offline
#1
Hi I have found some errors in listing 4.31 - I post the corrected code with marking of the errors as comments.

Hope it is helpfull

Best regards,
Kaj Bromose


import groovy.xml.MarkupBuilder //In book: port groovy.xml.MarkupBuilder
writer = new StringWriter()
builder = new MarkupBuilder(writer)

builder.orders() {
payload.split('
').each {line -> // In book: payload.split('n').each {line ->
def fields = line.split(',')
order() {
subscriberId(fields[0])
productId(fields[1]) // In: book productId(csvFields[1])
status(fields[2]) // In book: status(csvFields[2])
}
}
}
return writer.toString()
David Dossot (233) [Avatar] Offline
#2
Re: Listing 4.31 Transforming a CSV payload to XML. - error
Thanks for reporting this.

It's actually a code inclusion problem as the actual source code file from which the example is taken from is correct: https://github.com/ddossot/mule-in-action-2e/blob/master/chapter04/src/main/resources/orderTransformer.groovy

D.
bromose (5) [Avatar] Offline
#3
Re: Listing 4.31 Transforming a CSV payload to XML. - error
The code You refer to seems Wong. It seems to me that the csvFields[ should have been fields[

Best Regards, Kaj Bromose
David Dossot (233) [Avatar] Offline
#4
Re: Listing 4.31 Transforming a CSV payload to XML. - error
Good catch, thanks!
vromero (6) [Avatar] Offline
#5
Re: Listing 4.31 Transforming a CSV payload to XML. - error
This is fixed for the next MEAP update.