Monday, April 10, 2017

Creating XSL Sub Template and Include XSL template in RTF

Creating XSL Sub Template and Include it in RTF


In this article we shall see 
  1. How to create XSL sub template 
  2. How to import XSL sub template in RTF template.
  3. How to invoke template in XSL file, from RTF template

PREREQUISITE STEPS

Prerequisite steps include following
1.       Creating Concurrent Program Executable
2.       Creating Concurrent Program Definition
3.       Creating Data Definition.

Above steps will make sure that we have all required components which can give sample XML data for testing.

STEP1 – CREATING XSL-FO SUB TEMPLATE


Navigate to “XML Publisher” responsibility -> Templates tab and create template with details as shown below:-


Contents of file which is attached to this template is shown below:-

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
  <xsl:template name="formatnumber">
    <xsl:param name="NUMBERTOFORMAT"/>
    <xsl:value-of select="format-number($NUMBERTOFORMAT, '###.##.###,00', 'euro')"/>
  </xsl:template>
</xsl:stylesheet>

Above code formats given number into European format(in which group separator is dot and decimal separator is comma)

STEP2 – CREATING MAIN TEMPLATE(RTF TEMPLATE)

Navigate to “XML Publisher” responsibility -> Templates tab and create template with details as shown below:-


Contents of the RTF file is shown below, which contains “Import” statement for importing “XXCUST_FORMAT_NBR_XSL” template created in Step 1. Snapshot of RTF file is shown below:-



 As shown in above screenshot, XSL-FO template is imported into RTF template using below syntax

 <?import:xdo://XXXX.XXCUST_FORMAT_NBR_XSL.en.US/?> 

XXXX must be replaced with Application name of XSL-FO template.

Import statement for running the BI publisher output from RTF using “Preview” option(in MS Word), will be as below:-

<?import:file:///E:/Vani/xsl/XXCUST_FORMAT_NBR_XSL.xsl?>

XXCUST_FORMAT_NBR_XSL.xsl file resides in E:\Vani\XSL location

Template is invoked using below syntax

<xsl:call-template name=”formatnumber”>   
      <xsl:with-param name="NUMBERTOFORMAT" select="BEGIN_BAL"/> 
</xsl:call-template>

Report output and sample XML are shown below :-

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by Oracle Reports version 10.1.2.3.0 -->
<XXCUST_FORMAT_NBR>
  <LIST_G_COMPANY>
    <G_COMPANY>
      <BEGIN_BAL>5000000</BEGIN_BAL>
      <END_BAL>123242342.43</END_BAL>
    </G_COMPANY>
    <G_COMPANY>
      <BEGIN_BAL>56778.43</BEGIN_BAL>
      <END_BAL>2323223</END_BAL>
    </G_COMPANY>
    <G_COMPANY>
      <BEGIN_BAL>788778.45</BEGIN_BAL>
      <END_BAL>1111</END_BAL>
    </G_COMPANY>
  </LIST_G_COMPANY>
</XXCUST_FORMAT_NBR>



You can download XSL-FO template and RTF template from here.

No comments:

Post a Comment