You are here: Blog BI Publisher XML generation using BI Publisher Data Template

XML generation using BI Publisher Data Template

Written by  Raj
Rate this item
(10 votes)

Data Template is BI Publisher (XML Publisher) functionality to generate simple to complex XML in very proficient and scalable manner. It is Java based middleware solution, which generates the XML in UTF-8 encoding. XML generation API, formally Data Processor Class can be invoked from any java environment to execute the Data Template as long it has all required library in class path.

Data Template is metadata file, which hold the required information to generate and control the XML generation process.

I am using simple examples to introduce some basic and moderate features of Data Template. In later articles, we will touch some of the advance features as well.

1. Generating simple flat XML using single query. XML structure will be based on default data structure.


Please click here to review the xml output 

2. Single query with single group using Data Structure

Data Structure control the final XML structure.  You can design the Data Structure section according to your requirement and logical hierarchy of your data.

Please click here to review the xml output 

3. Single Query with multiple groups

This structure provides the master detail relationship or in other words a group hierarchy. This could be up to any level, depends on Data Structure.

Please click here to review the xml output 

4. Multiple queries and multiple groups.

Here multiple queries are logically related. Example, Emp and  Dept, Customer and Product, Invoice Header and Invoice Lines. Each query can have one or more group. Each group belongs to one and only one query.  One group can not have data from multiple queries.


5. Parameter to filter and control the data.

Within parameter section, we can define the parameter. Parameter can be use within queries as bind variables to filter the data. We need to  set the data type, the default values are optional. 

 

Please click here to review the xml output 

6. Using Summary functions

Data Template supports the following Summary function. They can be use at Higher-level group or at Report Level. A higher-level element can’t be referred at lower level.

SUM, AVG, MIN, MAX, FIRST, LAST

Please click here to review the xml output  

7. Data Template Properties

Data Template supports  following  properties to control and influence XML generation process.

A sample usage of these properties within Data Template.

Please click here to review the xml output 

8. Concatenated XML from two different queries.

The output will be simple concatenation.  This is required when there is no logical relation between the queries but still we want to report data on single Report. XML data from first query + XML Data from second query concatenated to single XML.


These are some of the simple functionality of Data Template.  You can use following simple java logic to test and run these data templates.

 9. Sample Java Program to Test Data Templates

 import oracle.apps.xdo.common.log.Logger;
import oracle.apps.xdo.dataengine.DataProcessor;
import oracle.jdbc.driver.OracleDriver;
import java.sql.Connection;
import java.sql.DriverManager;
public class sample {
public sample() {
}
public static void main(String[] args)
{
Logger.setLevel(Logger.STATEMENT);
test1();
}
 
public static Connection getConnection(String ConnectString,String user, String passwd)
{
Connection conn=null;
try {
DriverManager.registerDriver(new OracleDriver());
if (ConnectString != null && ConnectString.length()>0 )
{
conn =
DriverManager.getConnection("jdbc:oracle:thin:@"+ConnectString,user,passwd);
}
}
catch (Exception e )
{
e.printStackTrace();
}
return conn;
}
 
public static void test1()
{
Connection connection=null;
 
try {
connection = getConnection("localhost:1521:orcl","scott","tiger");
DataProcessor dataProcessor = new DataProcessor();
dataProcessor.setConnection(connection);
dataProcessor.setDataTemplate("c:\\test\\test1_template.xml")
dataProcessor.setOutput("c:\\test\\out\\test1_data.xml");
dataProcessor.processData();
} catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
connection.close();
} catch (Exception e)
{
e.printStackTrace();
}
} } }
 
Note: I have some technical difficulty in uploading XML files, Once resolved, I will upload all the sample Data Templates and XML output files.
Read 28840 times

Leave a comment

Make sure you enter the (*) required information where indicated.
Basic HTML code is allowed.