As of v1.15.0, incorporated into Incode Platform (
Java Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Build Status

This module, intended for use with Apache Isis, provides a wrapper around XDocReport. XDocReport is an API to merge XML documents into MS Office (.docx) or OpenOffice (.odt) files, optionally converting into another format, notably PDF.

How to configure/use

You can either use this module "out-of-the-box", or you can fork this repo and extend to your own requirements.


To use "out-of-the-box":

  • update your classpath by adding this dependency in your dom project’s pom.xml:

  • update the getModules() method of your AppManifest:

    public List<Class<?>> getModules() {
        return Arrays.asList(

"Out-of-the-box" (-SNAPSHOT)

If you want to use the current -SNAPSHOT, then the steps are the same as above, except:

  • when updating the classpath, specify the appropriate -SNAPSHOT version:

  • add the repository definition to pick up the most recent snapshot (we use the Cloudbees continuous integration service). We suggest defining the repository in a <profile>:


Forking the repo

If instead you want to extend this module’s functionality, then we recommend that you fork this repo. The repo is structured as follows:

  • pom.xml - parent pom

  • dom - the module implementation, depends on Isis applib


This module provides a single service, called XdocReportService. It has the following API:

@DomainService(nature = NatureOfService.DOMAIN)
public class XDocReportService {
    public byte[] render(
            byte[] templateBytes,                       (1)
            XDocReportModel dataModel,                  (2)
            OutputType outputType)                      (3)
        throws IOException { ... }
  1. the input template, eg the bytes of a Word .docx file

  2. holds the data to be merged into the template, discussed further below

The XDocReportModel parameter holds the data to be merged into the template. It is basically just a map of (Data) objects, where each such is either a single object, or is a list of objects:

public interface XDocReportModel {

    class Data {
        private final Object obj;
        private final Class<?> cls;
        private final boolean list;

        public static <T> Data list(final List<T> objects, final Class<T> cls) {
            return new Data(objects, cls, true);

        public static <T> Data object(final T object) {
            return new Data(object, object.getClass(), false);

    Map<String, Data> getContextData();

The OutputType meanwhile is simply an enum defining:

public enum OutputType {

Example Usage

From the unit tests:

// given
InputStream in= new FileInputStream(new File("src/test/java/org/isisaddons/module/xdocreport/dom/example/template/Project-template.docx"));
final byte[] templateBytes = IOUtils.toByteArray(in);

Project project = new Project("XDocReport");
List<Developer> developers = new ArrayList<>();
developers.add(new Developer("ZERR", "Angelo", ""));
developers.add(new Developer("Leclercq", "Pascal", ""));
final ProjectDevelopersModel dataModel = new ProjectDevelopersModel(project, developers);   (1)

// when
final byte[] docxBytes = service.render(templateBytes, dataModel, OutputType.DOCX);

// then
IOUtils.write(docxBytes,new FileOutputStream(new File("target/Project.docx")));
  1. see below


public class ProjectDevelopersModel implements XDocReportModel {

    private final Project project;
    private final List<Developer> developers;

    public Map<String, Data> getContextData() {
        return ImmutableMap.of(
                "project", Data.object(project),
                "developers", Data.list(developers, Developer.class));

Change Log

  • 1.14.0 - released against Isis 1.14.0

  • 1.13.1 - released against Isis 1.13.0, fixes #1

  • 1.13.0 - released against Isis 1.13.0


Copyright 2016 Dan Haywood

Licensed under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.


The application uses icons from icons8.

Maven deploy notes

Only the dom module is deployed, and is done so using Sonatype’s OSS support (see user guide).

Release to Sonatype’s Snapshot Repo

To deploy a snapshot, use:

pushd dom
mvn clean deploy

The artifacts should be available in Sonatype’s Snapshot Repo.

Release an Interim Build

If you have commit access to this project (or a fork of your own) then you can create interim releases using the script.

The idea is that this will - in a new branch - update the dom/pom.xml with a timestamped version (eg It then pushes the branch (and a tag) to the specified remote.

A CI server such as Jenkins can monitor the branches matching the wildcard origin/interim/* and create a build. These artifacts can then be published to a snapshot repository.

For example:

sh 1.14.0 origin


  • 1.15.0 is the base release

  • origin is the name of the remote to which you have permissions to write to.

Release to Maven Central

The script automates the release process. It performs the following:

  • performs a sanity check (mvn clean install -o) that everything builds ok

  • bumps the pom.xml to a specified release version, and tag

  • performs a double check (mvn clean install -o) that everything still builds ok

  • releases the code using mvn clean deploy

  • bumps the pom.xml to a specified release version

For example:

sh 1.14.0 \
              1.15.0-SNAPSHOT \
              "this is not really my passphrase"


  • $1 is the release version

  • $2 is the snapshot version

  • $3 is the email of the secret key (~/.gnupg/secring.gpg) to use for signing

  • $4 is the corresponding passphrase for that secret key.

Other ways of specifying the key and passphrase are available, see the `pgp-maven-plugin’s documentation).

If the script completes successfully, then push changes:

git push origin master && git push origin 1.14.0

If the script fails to complete, then identify the cause, perform a git reset --hard to start over and fix the issue before trying again. Note that in the dom’s `pom.xml the nexus-staging-maven-plugin has the autoReleaseAfterClose setting set to true (to automatically stage, close and the release the repo). You may want to set this to false if debugging an issue.

According to Sonatype’s guide, it takes about 10 minutes to sync, but up to 2 hours to update search.