DataSplice Reporting Plug-in Documentation
From DataSplice
This document covers using the reporting plug-in in DataSplice to generate and print reports of various data. The reports are rendered as HTML documents, which can then be printed out as desired.
Creating Templates
Reports are HTML templates with special control statements that are used to render and display a web page, which can then be printed. This allows the formatting, style, and layout capabilities of HTML pages to be used to create the reports. The templates are for the most part normal web pages, which allows them to be authored using various web content tools.
Note that the templates must be well-formed XML documents. This can add some complication to certain templates that is described below in the control statements section. In addition, the control statements are within the ds:namespace, which must be declared in the document or it will not be parsed correctly. The header for each template should look like:
<?xml version="1.0"?>
<html xmlns:ds="http://datasplice.com/xml/">
...
Control Statements
All control statements are XML elements within the statement that effect the contents of the element. The names are within the ds: namespace to separate them from the rest of the HTML.
<ds:query>
Performs a query against a target view and repeats the contents for each matching record. The contents should be HTML and text that renders the particular record, and can contain additional ds:query commands to fetch sub queries of child data, etc.
Several attributes are used to control the specifics of the
- View [required] - Specifies the name of the view to query
- Filter - Provides the where clause used to filter the data. The syntax of this is the same as the query function described in the expression reference.
- OrderBy - Can be used to sort the results if desired. Again, the syntax is the same as the order clause for the query function.
DataSplice attributes within the element content and the Filter setting are replaced using the current values in the context.
The following renders a table for the History view, finding all records that match
the CURRENT_STATUS attribute and adding a row for each transaction sorted by date:
<table>
<tr>
<th>Name</th>
<th>Date</th>
</tr>
<ds:query View="History" Filter="Status = ${CURRENT_STATUS}" OrderBy="Transaction Date">
<tr>
<td>${Name}</td>
<td>${Transaction Date}</td>
</tr>
</ds:query>
</table>
<ds:section>
Specifies sections that should only be rendered under certain conditions. This should specify a Condition attribute, and the contents of the section will only be rendered if the expression evaluates to true.
<table>
<ds:query View="Test">
<ds:section Condition="${Is Tool}">
<tr class="toolRow">
<td>${Name}</td>
<td>${Description}</td>
</tr>
</ds:section>
<ds:section Condition="!${Is Tool}">
<tr class="itemRow">
<td>${Name}</td>
<td>${Description}</td>
</tr>
</ds:section>
</ds:query>
</table>
<ds:pre> / <ds:post>
These commands can be used within a ds:query element to render text before and after the matching records. This is similar to having the text before/after the ds:query command, but the contents are only rendered if the query matches at least one record.
If these commands are used to contain start and end elements, the main template would not be well-formed:
<ds:query View="Test">
<ds:pre><div class="Test"></ds:pre>
...
<ds:post></div></ds:post>
</ds:query>
In these cases, the contents need to be commented out (<!-- <div class="Test"> -->)
so the document is valid, and the plug-in will remove the comments when rendering the
report. This does mean that these sections will not be visible if previewing the template
in a web browser, or using a GUI tool to edit the document.If the contents of the pre/
post commands are self-contained the comment tags are unnecessary.
For instance, the following might be used to display child records within an unordered list:
<pre>
<ul>
<ds:query View="Child" Filter="...">
<li>${Name}</li>
</ds:query>
</ul>
However, this will render an empty list element (<ul></ul>) if there are no matching child
records. The pre/post commands can be used to render these sections, but only if there the
query matches at least one record:
<ds:query View="Child" Filter="...">
<ds:pre><!-- <ul> --></ds:pre>
<li>${Name}</li>
<ds:post><!-- </ul> --></ds:post>
</ds:query>
Note that in this case the ul tag must be commented out in order to maintain a well-formed
XML document.