XML Publisher and Rowset Class

Example Class for an Application Package. Takes a Rowset and passes to the given Publisher Report and Template.

/********************************************************************************
SAMS_BRD220X Michael Nitschke 12/05/2011 XML Publisher
Common Class for XML Publisher

Users can use the method CreateXMLFilesFromRS to create only XML and XSD file,
very useful for XMLPublisher Template creation.

The PublishXMLReportFromRS method will create the XML Files and publish the given 
report.
********************************************************************************/
import PSXP_XMLGEN:*;
import PSXP_RPTDEFNMANAGER:*;

class XMLPublisher
   method XMLPublisher();
   method PublishXMLReportFromRS();
   method CreateXMLFilesFromRS();
   
   property Rowset rsData;
   property string sFileNameXSD;
   property string sFileNameXML;
   property string sRptDefn;
   property string sReportTemplate;
   property number processInstance;
   property string xmlFileName;
end-class;

method XMLPublisher
   /* Constructor. */
end-method;


/* Takes the rsData rowset property and uses it to publish a report, using other property values. */
method PublishXMLReportFromRS
   
   %This.CreateXMLFilesFromRS();
   
   /* Generate the report. */
   Local any &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn); /* report definition name */
   &oRptDefn.Get();
   &oRptDefn.SetRuntimeDataXMLFile(%This.xmlFileName); /* Connect report and data. */
   &oRptDefn.ProcessReport(&sReportTemplate, %Language_User, %Date, ""); /* report's template ID */
   &oRptDefn.OutDestination = %FilePath;
   
   /* Publish to Report Manager. */
   &oRptDefn.Publish("", "", "", &processInstance);
   
end-method;

method CreateXMLFilesFromRS
   
   /* Create XSD file. */
   Local PSXP_XMLGEN:RowSetDS &oXML_GENERATOR = create psxp_xmlgen:RowSetDS();
   Local string &my_schema = &oXML_GENERATOR.getXSDSchema(&rsData);
   Local File &XSD_File = GetFile(&sFileNameXSD, "W");
   &XSD_File.WriteLine(&my_schema);
   &XSD_File.Close();
   
   /* Create XML file. */
   Local string &my_xml = &oXML_GENERATOR.getXMLData(&rsData, "");
   Local File &XML_File = GetFile(&sFileNameXML, "W");
   &XML_File.WriteLine(&my_xml);
   %This.xmlFileName = &XML_File.Name;
   &XML_File.Close();
   
end-method;

Creating Section Breaks in XML Publisher/BI Publisher

Rather than using for-each:GROUP_NAME you use for-each@section:GROUP_NAME, every time xmlp hits a new member of GROUP_NAME the page numbering and header is reset.

(from www.orafaq.com forums)

Setting Up BI Publisher/XML Publisher

This can be fun. I had a lot of trouble with an error message stating I couldn't install the plug-in while Word was running. Shut down process after process to no avail.

Solution:
1. Download to your desktop the install file from Main Menu > Reporting Tools > XML Publisher > Setup > Design Helper.
2. Restart the machine in Safe Mode and install.

I also encountered further problems when trying to use some of the features such as the Chart object. Reinstall BI Publisher by navigating to: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\DotNetInstallFiles\setup.exe and following the prompts (next, ok, next, yes etc.)

XML / BI Publisher Example, using XML File as the Data Source

Note that using a Data Source of "XMLDoc" or "RowSet" has been deprecated. If you are going to create a new XML Publisher Report you are going to have to use a data source of "XML File" or "PS Query".

This is probably a good way of going about it anyway because you need to create the XML and XSD files before you can create the template anyway (unless you want to make them by hand).

Following is a simple example that could use some flourish, but illustrates the method clearly.



/* Super simple example of creating a XML Publisher report based on RowSet data.
   Note that producing reports from RowSet data or XMLDoc data has been deprecated.
   This example uses a Data Source of 'XML File'. */

import PSXP_XMLGEN:*;
import PSXP_RPTDEFNMANAGER:*;


/* Create Rowset(s) data for the report, however you need. */
Local Rowset &rsData = CreateRowset(Record.AMS_SOA_PROG_VW);
&rsData.Fill("WHERE EMPLID LIKE '3064%'");


Local string &sFileNameXSD = "Rowset.xsd";
Local string &sFileNameXML = "Rowset.xml";
Local string &sRptDefn = "AMS_SOA_XML";
Local string &sReportTemplate = "AMS_SOA_XML_1";

/* Create XSD file. */
Local PSXP_XMLGEN:RowSetDS &oXML_GENERATOR = create psxp_xmlgen:RowSetDS();
Local string &my_schema = &oXML_GENERATOR.getXSDSchema(&rsData);
Local File &XSD_File = GetFile(&sFileNameXSD, "W");
&XSD_File.WriteLine(&my_schema);
&XSD_File.Close();

/* Create XML file. */
Local string &my_xml = &oXML_GENERATOR.getXMLData(&rsData, "");
Local File &XML_File = GetFile(&sFileNameXML, "W");
&XML_File.WriteLine(&my_xml);
Local string &xmlFileName = &XML_File.Name; /* File.Name not available after File.Close() */
&XML_File.Close();


/* Generate the report. */
&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn); /* report definition name */
&oRptDefn.Get();
&oRptDefn.SetRuntimeDataXMLFile(&xmlFileName); /* Connect report and data. */
&oRptDefn.ProcessReport(&sRptTemplate, %Language_User, %Date, ""); /* report's template ID */
&oRptDefn.OutDestination = %FilePath;

/* Publish to Report Manager. */
&oRptDefn.Publish("", "", "", AMS_SOA_AET.PROCESS_INSTANCE);


Creating XML Publisher Documents with PeopleCode

Uploaded to own site in case it ever disappears from Oracle (or moves)
Nice doco on how to create XML from PeopleCode to use in BI Publisher (XML Publisher) or what have you.

Creating XML Publisher Documents with PeopleCode

My New View


View Larger Map

Run Control in App Engine


The Default State Record must be built as an SQL Table. This is not documented (I think).

You can then use the Run Control by binding as in the following example. If it is a Derived Work table, not an SQL Table, the %Bind value will be Null.