XML DB-Description

[Top]  [Chapter]  [Previous]  [Next]

The interface "Reporter" manages a DB-Description defined in XML. The XML structure is used to define and validate the variables.

 

Please don't mix up this DB-Description with the template used by the "Token to Template Conversion". The first is a true XML data while the latter is formatted text with added tokens to mark fields and bands.

 

This is the XML data which was created in the first example. The XML data can be simply saved using Report.SaveToFile, edited in a separate application and loaded back in using LoadFromFile.

 

<?xml version="1.0" encoding="windows-1252"?>

<main Type="Section">

<group Name="ORDERS" Title="ORDERS" Mode="0">

 <field Name="ORDERS.ID" Title="ID" Mode="2"/>

 <field Name="ORDERS.ARTICLE_ID" Title="ARTICLE_ID" Mode="2"/>

 <field Name="ORDERS.ORDER_ID" Title="ORDER_ID" Mode="2"/>

 <field Name="ORDERS.CUSTOMER_ID" Title="CUSTOMER_ID" Mode="2"/>

 <field Name="ORDERS.ARTICLE" Title="ARTICLE"/>

 <field Name="ORDERS.PRICE" Title="PRICE"/>

 <field Name="ORDERS.AMOUNT" Title="AMOUNT"/>

 <var Name="ORDER_PRICE"

  Title="Sub Total"

  Description="Price * Amount"

  StartFormula="=0"

  LoopFormula="=ORDERS.AMOUNT*ORDERS.PRICE"

  Format="CUR=$"/>

 <var Name="TOTAL_PRICE"

  Title="Total"

  Description="Sum of all ORDER_PRICE"

  StartFormula="=0"

  LoopFormula="+=ORDERS.AMOUNT*ORDERS.PRICE"

  Format="CUR=$"

  Mode="2"/>

 <header Title="Header"/>

 <data Title="Data"/>

 <footer Title="Footer"/>

 </group>

</main>

 

In the XML structure the possible group nesting is outlined. Also fields which are available are defined. Optionally calculated fields ("var") to create totals can be also added. The XML structure also contains information for the creation of a default reporting template. Here the obligatory groups and bands are created (Mode). Text can be filled in using HTML code. The captions use the 'Titel' defined for a field. (So changing just one element will update all references)

 

The XML structure can be created using program code. At best by reading the structure of a database connection and reusing the "Titel" and information of the field. To do so the Reporter interface has several procedures to add groups, fields and bands. It is also possible to add bands and fields to an existing template.

 

Once the default template has been created it can still be edited in the regular text editor.

 


[xmltemplate_template.htm]    Copyright © 2007 by WPCubed GmbH