concept streamingmarkupbuilder in category groovy

appears as: StreamingMarkupBuilder
Groovy in Action, Second Edition

This is an excerpt from Manning's book Groovy in Action, Second Edition.

In this chapter, you’ll try out representative builders that come bundled with Groovy, including NodeBuilder, MarkupBuilder, StreamingMarkupBuilder, AntBuilder, SwingBuilder, and SceneGraphBuilder from GroovyFX. You should also consult the API documentation for other builders such as CliBuilder, JmxBuilder, NamespaceBuilder, ObjectGraphBuilder, DOMBuilder, SAXBuilder, StaxBuilder, and CompilerCustomizationBuilder. Each of these builder implementations has specific uses and details, but they all follow the same general pattern of building some kind of nested data or product using nested (but otherwise standard) Groovy code.

11.4. Working with StreamingMarkupBuilder

In streaming scenarios (for example, when creating large markup files) you might consider using StreamingMarkupBuilder. It’s almost a drop-in replacement for MarkupBuilder but there are a few differences you should be aware of. First let’s take our invoices example and tweak it to use StreamingMarkupBuilder as shown in the following listing.

Listing 11.8. Invoice example with StreamingMarkupBuilder