groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garneke <>
Subject StreamingMarkupBuilder attempting to stream input strips CR & LF characters.
Date Tue, 31 May 2016 17:16:30 GMT

I need to wrap an existing file's contents within an XML tag.  In this case
the file being wrapped is also XML.
I would like to minimize the memory requirements as the input file maybe
large.  With the StreamingMarkupBuilder class I can include a Reader as
input and bind to an output file.  This seems to be the ideal solution,
however, this is modifying the original files contents.  It is escaping all
of the special XML characters but stripping CR and LF characters.  I cannot
alter the wrapped contents like this.

Does anyone have a suggestion.  Here is some sample code of what I am
(Note:  the metadata is just a GPathResult object containing required
metadata .)
Reader inputReader = inputFile.newReader("UTF-8");
def sbuilder = new StreamingMarkupBuilder()
sbuilder.encoding = 'UTF-8';

  mkp.pi('xml':['version':'1.1', 'encoding':'UTF-8'])
  mkp.declareNamespace( 'xsi' : "" )
	mkp.yield metadata.get()
	'Payload'(['length':"${(inputFile.length()-skipVal)}"], inputReader)
}.writeTo( outWriter );


View this message in context:
Sent from the Groovy Users mailing list archive at

View raw message