Introduction

XmlEngine is a tool that produces forms and reports according to templates defined in XML, including FOP (Formatting Objects Processor), or HTML mark-up languages. These templates combined with a configuration file define the design of forms and reports and let users to have full control of how the information is organized and displayed. XmlEngine can be used as part of other applications, as we do in Openbravo ERP, or as a servlet as in the examples included in this manual. XmlEngine produces highly customized reports and has advanced report features such as headers and footers, data grouping and data functions.

This document explains, by examples, the basic concepts of XmlEngine and how is integrated in Openbravo ERP.

Module

All the code used in this document, is available as a module: Concepts - XmlEngine. Open your module management console, search and install the Concepts - XmlEngine module.

The XML template

<?xml version="1.0"encoding="UTF-8"?><REPORT><TEMPLATEfile="sample2.html"/><!-- id attribute must be same than in the html template --><!-- name attribute is used by the controller (java) to set the value --><PARAMETERid="paramParagraph"name="paragraph"default=""/></REPORT>

We want to replace the xxx string with a valid CSS text-decoration string.

The XML template

<?xml version="1.0"encoding="UTF-8"?><REPORT><TEMPLATEfile="sample3.html"/><!-- id attribute must be same than in the html template --><!-- name attribute is used by the controller (java) to set the value --><!-- attribute is the one defined in the html template --><!-- replace is the string that will be replaced by the parameter on the defined attribute content --><PARAMETERid="paramStyle"name="style"attribute="style"replace="xxx"/></REPORT>

The XML template

<?xml version="1.0"encoding="UTF-8"?><REPORT><TEMPLATEfile="sample5.html"/><!-- param2 will be used in the MODULE function --><!-- the default attribute in parameters is the default value when no data is passed --><PARAMETERid="param2"name="param2"default="2"/><STRUCTUREname="structure1"><!-- rownum field is the record number defined in the xsql --><FIELDid="fieldRownum">rownum</FIELD><!-- Function definition --><!-- id = tag id of the html template --><!-- name = name of the function to be called, MODULE, ADD, SUM, etc --><!-- arg1 = first argument of the function --><!-- arg2 = second argument of the function --><!-- format = number formatting defined in Format.xml file --><!-- attribute = html attribute we want to change --><!-- replace = string pattern we want to replace/change --><FUNCTIONid="fieldEvenOddRow"name="MODULE" arg1="fieldRownum" arg2="param2"format="integerEdition"attribute="class"replace="yy"/><FIELDid="fieldProductId">m_product_id</FIELD><FIELDid="fieldValue">value</FIELD><FIELDid="fieldName">name</FIELD><SECTIONid="sectionDetail"/></STRUCTURE></REPORT>

The XML template

<?xml version="1.0"encoding="UTF-8"?><REPORT><TEMPLATEfile="sample6.html"/><STRUCTUREname="structure1"><!-- You can format a numeric value using the format attribute, you just need to pick a format name from the Format.xml config file --><FIELDid="fieldeuroInform"format="euroInform">number</FIELD><FIELDid="fieldeuroRelation"format="euroRelation">number</FIELD><FIELDid="fieldeuroEdition"format="euroEdition">number</FIELD><FIELDid="fieldeuroExcel"format="euroExcel">number</FIELD><FIELDid="fieldpriceInform"format="priceInform">number</FIELD><FIELDid="fieldpriceRelation"format="priceRelation">number</FIELD><FIELDid="fieldpriceEdition"format="priceEdition">number</FIELD><FIELDid="fieldintegerInform"format="integerInform">number</FIELD><FIELDid="fieldintegerRelation"format="integerRelation">number</FIELD><FIELDid="fieldintegerEdition"format="integerEdition">number</FIELD><FIELDid="fieldintegerExcel"format="integerExcel">number</FIELD><FIELDid="fieldpriceExcel"format="priceExcel">number</FIELD><FIELDid="fieldqtyRelation"format="qtyRelation">number</FIELD><FIELDid="fieldqtyEdition"format="qtyEdition">number</FIELD><FIELDid="fieldqtyExcel"format="qtyExcel">number</FIELD><FIELDid="fieldgeneralQtyRelation"format="generalQtyRelation">number</FIELD><FIELDid="fieldgeneralQtyEdition"format="generalQtyEdition">number</FIELD><FIELDid="fieldgeneralQtyExcel"format="generalQtyExcel">number</FIELD><FIELDid="fieldamountInform"format="amountInform">number</FIELD><SECTIONid="sectionDetail"/></STRUCTURE></REPORT>