You are on page 1of 18

Oracle XML Publisher Training Document

Raju Ch

An Insider Guide to XML Publisher
Oracle XML Publisher has gained a lot of popularity among developers and also among the
businesses as its very easy to create a report using XML Publisher and even more easy to
generate reports in various formats like PDF, EXCEL, RTF etc.
XML Publisher
Oracle XML Publisher has gained a lot of popularity among developers and also among the businesses as
its very easy to create a report using XML Publisher and even more easy to generate reports in various
formats like PDF, EXCEL, RTF etc.
Oracle created XML Publisher is as a template based tool for publishing reports and much more along
with Oracle E-business Suite. XML Publisher is powerful enough to populate the data fetched by a PL
SQL package into a custom, yes custom, template and then generate the report in any of the desired form
such as PDF, HTML, RTF, EXCEL (HTML) and even PLAIN TEXT for transmission using EFT and EDI.
Difference between Classical Reporting Tools and XML Publisher:
The classical reporting tool had very different approach from that of XML Publisher e.g. in Report 6i used
to combine all the aspects of report generation i.e. the data definition, the report layout and the translation
in to a single entity. In this case it became very complex and cumbersome even if the report needed minor
changes. Also if the same report is required in another language then one more report needs to be
generated in other language. All these and many more hiccups made Oracle to come up with XML
Publisher.
With XML Publisher things were very different in a positive way. XML Publisher treats all the three aspects
of report generation i.e. the data definition, the report layout and the translation separately at design time,
but at run time all the three aspects are brought together and the final report is generated. So if the report
needs changes at the report layout level then Data Definition and the Translation part are not supposed to
be touched and only the Report Design can be changed alone. This means less time and money is being
spent in maintenance of these reports.
The working of the XML Publisher can be understood with the help of the following diagram:

Business Logic: In this part or aspect the required data (as per the business logic) is
extracted/fetched from the database and is converted in to XML Strings.
Report Layout: In this aspect or section of the XML Publisher the layout or the template of the final report
to be generated is stored and Managed in the Template Manager. These layouts or template can be very
easily created using familiar word processing software like Microsoft Word, Microsoft Excel etc.
Translation: The translation handler will manage the translation that is required at runtime.

2.Oracle XML Publisher Training Document Raju Ch How to generate reports using XML Publisher Pre-Requisites: 1. Create an AOL concurrent program that will execute the PL SQL stored procedure created in step 1. you will be able to see one more menu item named “Template Builder” as shown in the image below. Run the AOL concurrent program so that it in turn executes the PL SQL stored procedure to . this will start the Install Shield Wizard which will guide you throughout the process 2. MS Office 2000 or higher to create templates. Steps to generate a report using XML Publisher: 1. Oracle XML Publisher Release 5. Steps to install XML Publisher: 1. 2. 3. Go to XML Publisher Desktop and double click the setup. Upload the finalized template or layout of the report to Oracle Application using XML Publisher Administrator responsibility. set many preferences and preview the output of the report. 5.5 or higher. Create a PL SQL Package or Procedure that will fetch the required data as per the business requirement and then place the data to be displayed in XML tags into an output file. 4. After the installation is completed Open MS Word.exe. Create a template or the desired layout of the report to be generated using Template Builder.5 itself). Template builder (Usually gets installed with Oracle XML Publisher 5. This menu will enable you embed the XML data into your template. 3.

per_grades pg WHERE papf. o_retcode OUT VARCHAR2) AS -->Cursor to fetch Employee Records CURSOR csr_employee IS SELECT papf. Below is a simple example of such a PL SQL package. 6. papf.date_end.date_start.effective_start_date AND papf. papf. -->Cursor to fetch employee’s dependent (Children) records CURSOR csr_children (p_person_id NUMBER) IS SELECT papf.person_id AND pcr. SYSDATE) AND papf. papf.person_id prsn_id.contact_type = 'C' AND TRUNC (SYSDATE) BETWEEN NVL (pcr.effective_start_date AND paaf.person_id child_id. SYSDATE) AND NVL (pg.effective_end_date AND TRUNC (SYSDATE) BETWEEN NVL (pg. -->Package Body CREATE OR REPLACE PACKAGE BODY XXAA_XDO_PLSQL_XMLP_REPORT AS PROCEDURE XXAA_EMP_DETAILS (o_errbuf OUT VARCHAR2. BEGIN . Republish the Report. SYSDATE) AND NVL (pcr. per_all_people_f papf WHERE pcr.business_group_id. Now let’s elaborate each and every point mentioned above: We will create a PL SQL package that will fetch the data from the data base tables and then populate the same data in to XML tags. END XXAA_XDO_PLSQL_XMLP_REPORT.Oracle XML Publisher Training Document Raju Ch generate the data for the report. pg. o_retcode OUT VARCHAR2).person_id = paaf.date_from. SYSDATE) AND TRUNC (SYSDATE) BETWEEN papf.assignment_type = 'E' AND paaf.person_id AND paaf. papf.person_id = p_person_id AND pcr.business_group_id = 202 .primary_flag = 'Y' AND TRUNC (SYSDATE) BETWEEN papf.contact_person_id = papf.date_of_birth dob FROM per_contact_relationships pcr.effective_start_date AND papf.full_name prsn_name.grade_id = pg. -->Package Specification CREATE OR REPLACE PACKAGE XXAA_XDO_PLSQL_XMLP_REPORT AS PROCEDURE XXAA_EMP_DETAILS (o_errbuf OUT VARCHAR2.date_to. per_all_assignments_f paaf.full_name child_name.effective_end_date AND TRUNC (SYSDATE) BETWEEN paaf.grade_id AND paaf.name grade FROM per_all_people_f papf. employee_number emp_no.effective_end_date.

' <CHILD_DOB>' || v_children. ' <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL>').PUT_LINE ( FND_FILE. FND_FILE.PUT_LINE ( FND_FILE.PUT_LINE (FND_FILE.dob || '</CHILD_DOB>'). /*finally Close the starting Report tag*/ FND_FILE.XXAA_EMP_DETAILS Here’s the navigation for creating an Executable Nav: Application Developer Responsibility -> Concurrent ->Executable .PUT_LINE (FND_FILE. FND_FILE.grade || '</GRADE>').OUTPUT.OUTPUT. FND_FILE. END XXAA_XDO_PLSQL_XMLP_REPORT.PUT_LINE ( FND_FILE. ' <CHILD_CLASS> I</CHILD_CLASS>').OUTPUT. /*Embed data between XML tags for ex:.OUTPUT.0"?>’*/ FND_FILE.PUT_LINE ( FND_FILE. ' <EMP_NO>' || v_employee. We will name the executable as XXAA_XDO_PLSQL_XMLP_REPORT that will call above mentioned procedure XXAA_XDO_PLSQL_XMLP_REPORT. ' </G_EMP_NAME>'). FND_FILE. ' <CHILD_NAME>' || v_children.PUT_LINE ( FND_FILE. ' <CHILD_FEES>100 </CHILD_FEES>').0"?>').OUTPUT.PUT_LINE (FND_FILE.OUTPUT.PUT_LINE ( FND_FILE. /*Close the group tag </G_EMP_NAME> at the end of employee record*/ FND_FILE.prsn_name || '</EMP_NAME>').OUTPUT. ' <G_EMP_NAME>').PUT_LINE (FND_FILE.OUTPUT. ' </G_NO_CHILD>').OUTPUT.OUTPUT. FOR v_children IN csr_children (v_employee. /*Close the group tag </G_NO_CHILD> at the end of child record*/ FND_FILE.<EMP_NAME>Abeesh</EMP_NAME>*/ FND_FILE. ' <G_NO_CHILD>'). END XXAA_EMP_DETAILS. FND_FILE. Now we will have to create an executable and attach the newly created executable to a concurrent program. '<XXAA_EMP_DETAILS>'). so that the PL SQL stored procedure can be executed. '<?xml version="1. END LOOP.PUT_LINE ( FND_FILE. ' <EMP_NAME>' || v_employee.child_name || '</CHILD_NAME>'). ' <GRADE>' || v_employee. FOR v_employee IN csr_employee LOOP /*for each record create a group tag <G_EMP_NAME> at the start*/ FND_FILE.PUT_LINE (FND_FILE.PUT_LINE ( FND_FILE.Oracle XML Publisher Training Document Raju Ch /*First line of XML data should be ‘<?xml version="1.prsn_id) LOOP /*for each child record create a group tag <G_NO_CHILD> at the start*/ FND_FILE. END LOOP.emp_no || '</EMP_NO>').OUTPUT.OUTPUT. FND_FILE.OUTPUT.PUT_LINE (FND_FILE. '</XXAA_EMP_DETAILS>'). FND_FILE. FND_FILE.OUTPUT.PUT_LINE ( FND_FILE.OUTPUT.

Oracle XML Publisher Training Document Raju Ch Also we need to create a new concurrent Program say (“XXAA PLSQL XML Publisher Report”) that will call above mentioned executable XXAA_XDO_PLSQL_XMLP_REPORT with output format as XML To create new concurrent program just go to Nav: Application Developer Responsibility -> Concurrent ->Program .

Nav : System Administrator Security Responsibility Request .Oracle XML Publisher Training Document Raju Ch Attach the newly created Concurrent Program to a specific Request Group “Global HRMS Reports & Process” from where the Concurrent Program is supposed to run. This step can be understood from the screen shot below.

.Oracle XML Publisher Training Document Raju Ch From the appropriate responsibility. use the Submit Request form to run the concurrent request and cross check the XML output that is generated.

click on the view output button so as to see the XML file along with the data that has been generated as a result of the concurrent program run. Once you run the concurrent program. this is because we haven’t yet attached any layout or template to the report being generated.Oracle XML Publisher Training Document Raju Ch As you can see that the block mentioning the Layout is blank. .

West</GRADE> <G_NO_CHILD> <CHILD_NAME>Schwartz. Jeremy</CHILD_NAME> <CHILD_DOB>31-MAR-89</CHILD_DOB> <CHILD_CLASS> I</CHILD_CLASS> <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL> <CHILD_FEES>100 </CHILD_FEES> </G_NO_CHILD> <G_NO_CHILD> <CHILD_NAME>Schwartz. Francine</CHILD_NAME> <CHILD_DOB>14-DEC-95</CHILD_DOB> <CHILD_CLASS> I</CHILD_CLASS> <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL> <CHILD_FEES>100 </CHILD_FEES> </G_NO_CHILD> </G_EMP_NAME> <G_EMP_NAME> Raju Ch .0"?> <XXAA_EMP_DETAILS> <G_EMP_NAME> <EMP_NAME>Walker. Kenneth (Ken)</EMP_NAME> <EMP_NO>4</EMP_NO> <GRADE>500. Toby</EMP_NAME> <EMP_NO>310</EMP_NO> <GRADE>100.South</GRADE> </G_EMP_NAME> <G_EMP_NAME> <EMP_NAME>Schwartz.1.Oracle XML Publisher Training Document <?xml version="1.2. Mr.

Let’s have a look at how each step is supposed to be performed.1.</CHILD_NAME> <CHILD_DOB>05-MAY-94</CHILD_DOB> <CHILD_CLASS> I</CHILD_CLASS> <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL> <CHILD_FEES>100 </CHILD_FEES> </G_NO_CHILD> </G_EMP_NAME> <G_EMP_NAME> <EMP_NAME>User.xml”). Donald</EMP_NAME> <EMP_NO>1011</EMP_NO> <GRADE>200. For the next step we will create a template which will act as the layout for the final report that will be generated soon. Robert</EMP_NAME> <EMP_NO>349</EMP_NO> <GRADE>100. For this step we need to use the Microsoft MS Word application to design a template and then save the template a “RTF” file on your desktop computer.East</GRADE> </G_EMP_NAME> </XXAA_EMP_DETAILS> Please save this XML file on your desktop computer with some name say (“XXAA_XDO_PLSQL_XMLP_REPORT. .1. Marking up the XML template layout with the XML tags. John</CHILD_NAME> <CHILD_DOB>15-SEP-91</CHILD_DOB> <CHILD_CLASS> I</CHILD_CLASS> <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL> <CHILD_FEES>100 </CHILD_FEES> </G_NO_CHILD> <G_NO_CHILD> <CHILD_NAME>Alexander. Robert Jr. but make sure that you remove all the dashes “-“ that appear in the file. Creation of a template in itself is a two step process. Loretta</CHILD_NAME> <CHILD_DOB>22-NOV-98</CHILD_DOB> <CHILD_CLASS> I</CHILD_CLASS> <CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL> <CHILD_FEES>100 </CHILD_FEES> </G_NO_CHILD> </G_EMP_NAME> <G_EMP_NAME> <EMP_NAME>James. Test</EMP_NAME> <EMP_NO>2630</EMP_NO> <GRADE>100. Designing the template as specified in the business requirement.West</GRADE> <G_NO_CHILD> <CHILD_NAME>Alexander.East</GRADE> <G_NO_CHILD> <CHILD_NAME>James. Designing the template as specified in the business requirement.Oracle XML Publisher Training Document Raju Ch <EMP_NAME>Alexander.2.

we need to insert the XML tags into the template.Oracle XML Publisher Training Document Raju Ch Marking up the XML template layout with the XML tags. . these tags will be replaced by data at runtime. In order to achieve this go to the “BI Publisher” menu and the select Data and then Load XML Data. Once done with the creation of the template.

Oracle XML Publisher Training Document Raju Ch .

Just select the appropriate tag and click on the “Insert” button. This will open a different popup window which will ask to select the parent node. Suppose we want to add the summation of a column also at some place in the report layout.xml” file that we have saved on our desktop? The data from the same file will be used to preview the report. To achieve this we should have “XML Publisher Administrator” responsibility to the user. Note: 1. To insert the repeating tags into the XML report layout. then we need to select the “Insert” and then “Field” and then select the tag whose summation is supposed to be displayed. But you must be thinking that we don’t have data. To preview the report select “Preview” from the menu under “Template Builder” menu. XML Publisher gives you the freedom to preview the report before running it. Using this responsibility we can add a template to the report. The screen shot below displays the insertion of “Emp_Name” tag into the report layout. this is a very easy step and fun to do. and then “Table/Form” will look as shown in the screen shot below. our report template will look as the one shown in the below screen shot. Add the report layout template in to Oracle Application. This will open up a popup containing all the XML tags that we got in our “XXAA_XDO_PLSQL_XMLP_REPORT. locate the place where the data will be inserted at runtime.Oracle XML Publisher Training Document Raju Ch We will be asked to select the XML data. This will become clear by the following screen shot.xml” file. in our case the parent node is “G_NO_CHILD”. Once all the above mentioned steps are over. The next step is to add the XML tags to the report template layout. The popup window opened by selecting “Insert”.xml” file that we have saved previously to our desktop computer? We just need to select that file. highlight that place and then from the “Template Builder” menu select the “Insert” menu and then select the “Field” item. remember the “XXAA_XDO_PLSQL_XMLP_REPORT. . In the report layout. we have to select the “Insert” and then “Table/Form” from the “Template Builder” menu. then how come we can preview the report? Remember the “XXAA_XDO_PLSQL_XMLP_REPORT.

hence we will assign the data definition that we have created in the previous step to our template. as this allows the concurrent manager to get a list of templates that are available for that concurrent program at runtime.Oracle XML Publisher Training Document Raju Ch The process of adding a template to the report is again broken into steps for easy understanding and remembrance. Step-1 : Initially we have to register our concurrent request as a data definition. Doing this is simple. go to the XML Publisher Administrator and then templates and Create Template. the data definition code (shown highlighted) should be the same as that of the concurrent program short name. . Then upload the RTF template layout and select the language and territory. The most important point to remember here is that. While registering the template we will be asked to assign an already existing Data Definition to it. Give a name to the data definition. Here’s the screen shot of the Data Definition creation page with the data definition code highlighted. Step-2 : Now we will register our template with the use of template manager. To achieve this go to XML Publisher Administrator -> Data Definitions -> Create Data Definition.

Also. .Oracle XML Publisher Training Document Raju Ch This will be the final step in the generation of the report. To complete this step. Since. we have attached the template to the concurrent program we can see that the Layout Block displays the name of the template that has been attached to the report. template language and also the output format for the report to be generated. In the layout section of the submit request window we can select the template (if there are more than one template). from this window we can activate the XML Publisher’s preview feature. run the concurrent program from the appropriate responsibility.

Oracle XML Publisher Training Document Raju Ch .

. we can even republish and view the report or simply we can reprint the report.Oracle XML Publisher Training Document Raju Ch Upon the completion of the concurrent program run click on the view output run button to view the final report that has been generated. Below screen shot shows the report generated in the EXCEL format. We can republish and print the report. There are many other options also available on the Concurrent Manager menu.

layout. Reprint – sends the published request to the selected printer For more details on XML Publisher Please visit http://oracleapps88. Republish and Print – This action allows us to select a new template and output format for the completed concurrent request data. Republish and View – this option allows us to select a new template and output format for the completed request data for viewing only. The formatting is performed without creating a new concurrent request.blogspot.Oracle XML Publisher Training Document Raju Ch The difference between these actions is given below.in/search/label/XMLP . The data. and output selections are sent to XML Publisher to republish the request data.