There are various ways to produce and consume XML, CSV, JSON, and other text data using Moqui Framework.
Groovy has a good API for producing and consuming XML with:
There are many other XML libraries written in Java that be used with Moqui such as dom4j and JDOM. If you prefer these just include the JAR files in the Gradle build and code away.
For CSV files Moqui uses the Apache Commons CSV library, and just like with XML files other libraries can be used too. You can see how Moqui uses this in the
In Moqui Framework the main tool for repotting and exporting data is the XML Form, especially the list form. XML Screens and Forms can be rendered in various modes including XML, CSV, and plain text. To do this set the renderMode field in the context either in screen actions or for web requests with a request parameter. This is matched against the screen-facade.screen-text-output.type attribute in the Moqui Conf XML file and can be set to any value defined there, including the default Moqui ones (csv, html, text, xml, xsl-fo) or any that you define in your runtime Moqui Conf XML file.
The XML Form is probably setup for pagination (this is the default). To get all results instead of pagination for an export (or any other reason) set the pageNoLimit field to true. In some cases you will not want to render any of the parent screens that normally decorate the final screen to render, especially for XML files. For CSV files other screen elements are generally ignored. This can be done by setting the lastStandalone field to true meaning that the last screen is rendered standalone and not within parent screens in the screen path. These can be set in screen actions of for web requests as a request parameter.
Just as with other XML Screen and XML Form output modes the FTL macro template used to produce output can be customized by include and override/add. With this approach you can get custom output for a particular screen (including subscreens, so for an entire app or app section, etc) or for everything running in Moqui.
For a detailed example of a screen and form that has CSV, XML, and XSL-FO (PDF) output options see the List Form View/Export Example section.