Friday, May 22, 2015

How to call BI publisher API (E-text Template based report) from java? (Step by Step Approach to call Document Processor Engine)

As we all know, that BI publisher engine is written in Java. Further, Oracle has shared us a set of public Java API’s to invoke document processor. Smile
In this article, I tried to explain the methodology to call BI publisher Document Processor Engine API using a Java wrapper with an example (Etext Template and Sample XML).
1.       To generate the text file based on XML file using Etext template.
2.       The call to XML Publisher Document Processor Engine should be via Java class file


Before proceeding with an example, it’s very important to understand the Parameter XML of standard Oracle BI Publisher Java Class oracle.apps.xdo.batch.DocumentProcessor.


Step1: Prepare a wrapper Java file for calling “DocumentProcessor”
import java.util.Arrays;
import java.util.Collections;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import oracle.apps.xdo.batch.DocumentProcessor;

public class callBIPublisher {

  public static void main(String[] args)
      // arg0 --- File path of the Document Processor Parameter XML
      // arg1  --- Temporary Directory path
      DocumentProcessor  docProcessor = new DocumentProcessor(args[0], args[1]);
    catch(Exception e)
Step2: Generate the Java Class File for wrapper java for calling “Document Processor”
javac -classpath $CLASSPATH
Step3: Place the generate class file to $JAVA_TOP
                cp callBIPublisher.class $JAVA_TOP
Step4: Prepare the Input Parameter file as per the oracle documentation
xml version="1.0" encoding="UTF-8" ?> 
     <xapi:requestset xmlns:xapi="">
           <xapi:filesystem output="report.txt" /> 
         <xapi:document output-type="text">
           <xapi:template type="etext" location="ETEXTTEMPLATE.rtf">
             <xapi:data location="INPUTDATAXML.xml">
Step5: Prepare the E-text Template file and Input XML File
Incase, if you want to  know more about E-Text Templates, Please refer




Step1: Call the java wrapper class callBIPublisher with parameter file

               java -classpath $CLASSPATH callBIPublisher PARAMETERXML.xml .

Step2: Check the output file

Now, the mentioned command can be called from a host based concurrent program. I hope this helps !!  Happy Sharing Smile Smile Smile

1 Responses to “How to call BI publisher API (E-text Template based report) from java? (Step by Step Approach to call Document Processor Engine)”

Anonymous said...
December 10, 2017 at 12:29 AM

How do you call eText that has sequence definitions defined in the template? above code gives error. it works with simpler eText templates for sure. any pointers? thx.

Post a Comment


The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.