Enterprise Report Server (ERS) notes



Setting up an XML ERS project
=============================

This document gives a very brief description of what's required to set
up an ERS project. For more information, look at the documentation
produced by the serverdocs project.

To create a minimalist XML project under ERS, at least seven files
need to be created. The files have to be correctly named for the
project to work. The names are given below:

1.  description.txt file which contains text that will be displayed on
    the welcome HTML page.

2.  documentNames.txt file that contains names of different project
    options that are displayed as choice menu. The names also
    correspond to the names of the main python module(s). If the
    file contains one name, the page with choice menu is skipped.

3.  sample<yourName>.xml  file that should contain the main "data"
    of the project. This file is read by the parser and displayed in the
    html page text area. It can be modified from the text area; that means
    it can even be empty when loaded. Note that file name has to begin
    with sample+<your_extension>.xml. If more than one XML file beginning
    with "sample" exists in the directory, they will all be displayed
    in the drop-down option menu on the html page.

4.  <yourName>.dtd is 'data type definition' file used by the xml
    document. This file is optional, but required if you want to validate
    your xml.

5.  rmltemplate.prep file that contains the template needed to
    translate XML to RML, which in turn is converted to PDF by the ERS
    engine. This file can contain arbitrary python code contained in curly
    brackets {{ }}. This code is pre-processed by preppy and sent to PDF
    output. It contains the main "story" of the document. Any text NOT
    inside curly brackets is in RML - the Report Markup Language. See the
    RML documentation for more details about this.

6.  <ERS_main>.py file is the project’s entry point. As mentioned
    earlier, its name must be specified in the documentNames.txt file. The
    file must contain the function go(dictionary) that gets called by the
    ERS engine. The go function in this case calls WrappedXMLProcessor’s
    object go(dictionary) method.

7.  <ERS_main>.cgi file that is the project contact with the
    "outside world". It has to live in your web server cgi-bin
    directory. This file contains a simple python script that calls our
    project’s main file <ERS_main>.py.

The ERS engine needs special directories where produced and log files
will be kept. Create directories named pdfout and logs under your web
server root directory.

A simple project
================
All files and their contents are listed below. They all must reside in
the same directory, in this case ers/examples/bongo, apart from
<ERS_CGI_script>.cgi, which has to be in cgi-bin directory of your web
server. You can copy the text and save it as files named above the text
(filenames underlines with dashes).

 
description.txt
---------------
This is a really trivial example ERS client.


documentNames.txt
-----------------
bongo


sample_bongo_0.xml
----------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE user SYSTEM "sample.dtd">
<user>
	<name>Joe Cool</name>
</user>


bongo.dtd
----------
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT user (name)>
<!ELEMENT name (#PCDATA)>


rmltemplate.prep
----------------
<!DOCTYPE document SYSTEM "rml_1_0.dtd"> 
<document filename="HelloWorld.pdf">

{{script}} name = str(data.name) {{endscript}}

<template pageSize="(595, 842)" leftMargin="72" showBoundary="1">
	<pageTemplate id="main">
	<frame id="first" x1="1in" y1="1in" width="6.27in" height="9.69in"/>
	</pageTemplate>
</template>

<stylesheet>
	<initialize>
		<alias id="style.normal" value="style.Normal"/>
	</initialize>
	<paraStyle name="normal" fontName="Helvetica" fontSize="10" leading="12" spaceAfter="10"/>
</stylesheet>

<story>
	<para style="normal">				
		{{"Hello "+name+"!"}}		
	</para>
</story>
</document>


bongo.py
--------
from rlextra.ers.framework import WrappedXMLProcessor
def go(dictionary):
    return WrappedXMLProcessor().go(dictionary)


bongo.cgi
---------
#!c:\Python\python -u
#change the above line to wherever your python.exe
#lives. It is assumed your project files live under
#/Python/rlextra/ers/examples/bongo directory
if __name__=="__main__":
        from rlextra.ers.controller import main
        main(1,APPDIR="C:/Python/rlextra/ers/examples/bongo",SCRIPT_PFX="ers_bongo")





