Creating an RTF Template



Creating an RTF Template


Introduction

Rich Text Format (RTF) is a specification used by common word processing applications, such as Microsoft Word. When you save a document, RTF is a file type option that you select.
XML Publisher's RTF Template Parser converts documents saved as the RTF file type to XSL-FO. You can therefore create report designs using many of your standard word processing application's design features and XML Publisher will recognize and maintain the design.
During design time, you add data fields and other markup to your template using XML Publisher's simplified tags for XSL expressions. These tags associate the XML report data to your report layout. If you are familiar with XSL and prefer not to use the simplified tags, XML Publisher also supports the use of pure XSL elements in the template.
In addition to your word processing application's formatting features, XML Publisher supports other advanced reporting features such as conditional formatting, dynamic data columns, running totals, and charts.
If you wish to include code directly in your template, you can include any XSL element, many FO elements, and a set of SQL expressions extended by XML Publisher.



Supported Modes
XML Publisher supports two methods for creating RTF templates:
  • Basic RTF Method
    Use any word processing application that supports RTF version 1.6 writer (or later) to design a template using XML Publisher's simplified syntax.
  • Form Field Method
    Using Microsoft Word's form field feature allows you to place the syntax in hidden form fields, rather than directly into the design of your template. XML Publisher supports Microsoft Word 2000 (or later) with Microsoft Windows version 2000 (or later).
    Note: If you use XSL or XSL:FO code rather than the simplified syntax, you must use the form field method.
This guide describes how to create RTF templates using both methods.


Prerequisites
Before you design your template, you must:
  • Know the business rules that apply to the data from your source report.
  • Generate a sample of your source report in XML.
  • Be familiar with the formatting features of your word processing application.


Overview

Creating an RTF template file consists of two basic steps:
  1. Design your template layout.
    Use the formatting features of your word processing application and save the file as RTF.
  2. Mark up your template layout.
    Insert the XML Publisher simplified tags.
When you design your template layout, you must understand how to associate the XML input file to the layout. This chapter presents a sample template layout with its input XML file to illustrate how to make the proper associations to add the markup tags to the template.


Using the XML Publisher Template Builder

The Template Builder is an extension to Microsoft Word that simplifies the development of RTF templates. It automates many of the manual steps that are covered in this chapter. Use it in conjunction with this manual to increase your productivity.
The Template Builder is tightly integrated with Microsoft Word and allows you to perform the following functions:
  • Insert data fields
  • Insert data-driven tables
  • Insert data-driven forms
  • Insert data-driven charts
  • Preview your template with sample XML data
  • Browse and update the content of form fields
  • Extract boilerplate text into an XLIFF translation file and test translations
Manual steps for performing these functions are covered in this chapter. Instructions and tutorials for using the Template Builder are available from the readme and help files delivered with the tool.
Note: If you are running XML Publisher through the E-Business Suite, please see Oracle Meta Link note 357308.1, "About Oracle XML Publisher Release 5.6.1" for the patch number for the Oracle XML Publisher Desktop components. See the patch readme and help files for user documentation and desktop system requirements.


Associating the XML Data to the Template Layout

The following is a sample layout for a Payables Invoice Register:
Sample Template Layout

Note the following:
  • The data fields that are defined on the template
    For example: Supplier, Invoice Number, and Invoice Date
  • The elements of the template that will repeat when the report is run.
    For example, all the fields on the template will repeat for each Supplier that is reported. Each row of the invoice table will repeat for each invoice that is reported.


XML Input File

Following is the XML file that will be used as input to the Payables Invoice Register report template:
Note: To simplify the example, the XML output shown below has been modified from the actual output from the Payables report.
 <?xml version="1.0" encoding="WINDOWS-1252" ?>

- <VENDOR_REPORT>

- <LIST_G_VENDOR_NAME>

- <G_VENDOR_NAME>

<VENDOR_NAME>COMPANY A</VENDOR_NAME>

- <LIST_G_INVOICE_NUM>

- <G_INVOICE_NUM>

<SET_OF_BOOKS_ID>124</SET_OF_BOOKS_ID>

<GL_DATE>10-NOV-03</GL_DATE>

<INV_TYPE>Standard</INV_TYPE>

<INVOICE_NUM>031110</INVOICE_NUM>

<INVOICE_DATE>10-NOV-03</INVOICE_DATE>

<INVOICE_CURRENCY_CODE>EUR</INVOICE_CURRENCY_CODE>

<ENT_AMT>122</ENT_AMT>

<ACCTD_AMT>122</ACCTD_AMT>

<VAT_CODE>VAT22%</VAT_CODE>

</G_INVOICE_NUM>

</LIST_G_INVOICE_NUM>

<ENT_SUM_VENDOR>1000.00</ENT_SUM_VENDOR>

<ACCTD_SUM_VENDOR>1000.00</ACCTD_SUM_VENDOR>

</G_VENDOR_NAME>

</LIST_G_VENDOR_NAME>

<ACCTD_SUM_REP>108763.68</ACCTD_SUM_REP>

<ENT_SUM_REP>122039</ENT_SUM_REP>

</VENDOR_REPORT> 
XML files are composed of elements. Each tag set is an element. For example <INVOICE_DATE> </INVOICE_DATE> is the invoice date element. "INVOICE_DATE" is the tag name. The data between the tags is the value of the element. For example, the value of INVOICE_DATE is "10-NOV-03".
The elements of the XML file have a hierarchical structure. Another way of saying this is that the elements have parent-child relationships. In the XML sample, some elements are contained within the tags of another element. The containing element is the parent and the included elements are its children.
Every XML file has only one root element that contains all the other elements. In this example, VENDOR_REPORT is the root element. The elements LIST_G_VENDOR_NAME, ACCTD_SUM_REP, and ENT_SUM_REP are contained between the VENDOR_REPORT tags and are children of VENDOR_REPORT. Each child element can have child elements of its own.

Identifying Placeholders and Groups

Your template content and layout must correspond to the content and hierarchy of the input XML file. Each data field in your template must map to an element in the XML file. Each group of repeating elements in your template must correspond to a parent-child relationship in the XML file.
To map the data fields you define placeholders. To designate the repeating elements, you define groups.
Note: XML Publisher supports regrouping of data if your report requires grouping that does not follow the hierarchy of your incoming XML data. For information on using this feature, see Regrouping the XML Data.

Placeholders

Each data field in your report template must correspond to an element in the XML file. When you mark up your template design, you define placeholders for the XML elements. The placeholder maps the template report field to the XML element. At runtime the placeholder is replaced by the value of the element of the same name in the XML data file.
For example, the "Supplier" field from the sample report layout corresponds to the XML element VENDOR_NAME. When you mark up your template, you create a placeholder for VENDOR_NAME in the position of the Supplier field. At runtime, this placeholder will be replaced by the value of the element from the XML file (the value in the sample file is COMPANY A).

Identifying the Groups of Repeating Elements

The sample report lists suppliers and their invoices. There are fields that repeat for each supplier. One of these fields is the supplier's invoices. There are fields that repeat for each invoice. The report therefore consists of two groups of repeating fields:
  • Fields that repeat for each supplier
  • Fields that repeat for each invoice
The invoices group is nested inside the suppliers group. This can be represented as follows:
Suppliers
  • Supplier Name
  • Invoices
    • Invoice Num
    • Invoice Date
    • GL Date
    • Currency
    • Entered Amount
    • Accounted Amount
  • Total Entered Amount
  • Total Accounted Amount
Compare this structure to the hierarchy of the XML input file. The fields that belong to the Suppliers group shown above are children of the element G_VENDOR_NAME. The fields that belong to the Invoices group are children of the element G_INVOICE_NUM.
By defining a group, you are notifying XML Publisher that for each occurrence of an element (parent), you want the included fields (children) displayed. At runtime, XML Publisher will loop through the occurrences of the element and display the fields each time.

Designing the Template Layout

Use your word processing application's formatting features to create the design.
For example:
  • Select the size, font, and alignment of text
  • Insert bullets and numbering
  • Draw borders around paragraphs
  • Include a watermark
  • Include images (jpg, gif, or png)
  • Use table autoformatting features
  • Insert a header and footer
    For additional information on inserting headers and footers, see Defining Headers and Footers.
For a detailed list of supported formatting features in Microsoft Word, see Supported Native Formatting Features. Additional formatting and reporting features are described at the end of this section.

 

Adding Markup to the Template Layout

XML Publisher converts the formatting that you apply in your word processing application to XSL-FO. You add markup to create the mapping between your layout and the XML file and to include features that cannot be represented directly in your format.
The most basic markup elements are placeholders, to define the XML data elements; and groups, to define the repeating elements.
XML Publisher provides tags to add markup to your template.
Note: For the XSL equivalents of the XML Publisher tags, see XSL Equivalent Syntax.

Creating Placeholders

The placeholder maps the template field to the XML element data field. At runtime the placeholder is replaced by the value of the element of the same name in the XML data file.
Enter placeholders in your document using the following syntax:
<?XML element tag name?>
Note: The placeholder must match the XML element tag name exactly. It is case sensitive.
There are two ways to insert placeholders in your document:
  1. Basic RTF Method: Insert the placeholder syntax directly into your template document.
  2. Form Field Method: (Requires Microsoft Word) Insert the placeholder syntax in Microsoft Word's Text Form Field Options window. This method allows you to maintain the appearance of your template.

Basic RTF Method

Enter the placeholder syntax in your document where you want the XML data value to appear.
Enter the element's XML tag name using the syntax:
<?XML element tag name?>
In the example, the template field "Supplier" maps to the XML element VENDOR_NAME. In your document, enter:
<?VENDOR_NAME?>
The entry in the template is shown in the following figure:

Form Field Method

Use Microsoft Word's Text Form Field Options window to insert the placeholder tags:
  1. Enable the Forms toolbar in your Microsoft Word application.
  2. Position your cursor in the place you want to create a placeholder.
  3. Select the Text Form Field toolbar icon. This action inserts a form field area in your document.
  4. Double-click the form field area to invoke the Text Form Field Options dialog box.
  5. (Optional) Enter a description of the field in the Default text field. The entry in this field will populate the placeholder's position on the template.
    For the example, enter "Supplier 1".
  6. Select the Add Help Text button.
  7. In the help text entry field, enter the XML element's tag name using the syntax:
    <?XML element tag name?>
    You can enter multiple element tag names in the text entry field.
    In the example, the report field "Supplier" maps to the XML element VENDOR_NAME. In the Form Field Help Text field enter:
    <?VENDOR_NAME?>
    The following figure shows the Text Form Field Options dialog box and the Form Field Help Text dialog box with the appropriate entries for the Supplier field.
    Tip: For longer strings of XML Publisher syntax, use the Help Key (F1) tab instead of the Status Bar tab. The text entry field on the Help Key (F1) tab allows more characters.
  8. Select OK to apply.
    The Default text is displayed in the form field on your template.
    The figure below shows the Supplier field from the template with the added form field markup.

Complete the Example

The following table shows the entries made to complete the example. The Template Field Name is the display name from the template. The Default Text Entry is the value entered in the Default Text field of the Text Form Field Options dialog box (form field method only). The Placeholder Entry is the XML element tag name entered either in the Form Field Help Text field (form field method) or directly on the template.




Template Field Name
Default Text Entry (Form Field Method)
Placeholder Entry (XML Tag Name)
Invoice Num
1234566
<?INVOICE_NUM?>
Invoice Date
1-Jan-2004
<?INVOICE_DATE?>
GL Date
1-Jan-2004
<?GL_DATE?>
Curr
USD
<?INVOICE_CURRENCY_CODE?>
Entered Amt
1000.00
<?ENT_AMT?>
Accounted Amt
1000.00
<?ACCTD_AMT?>
(Total of Entered Amt column)
1000.00
<?ENT_SUM_VENDOR?>
(Total of Accounted Amt column)
1000.00
<?ACCTD_SUM_VENDOR?>
The following figure shows the Payables Invoice Register with the completed form field placeholder markup.
See the Payables Invoice Register with Completed Basic RTF Markup for the completed basic RTF markup.

Defining Groups

By defining a group, you are notifying XML Publisher that for each occurrence of an element, you want the included fields displayed. At runtime, XML Publisher will loop through the occurrences of the element and display the fields each time.
In the example, for each occurrence of G_VENDOR_NAME in the XML file, we want the template to display its child elements VENDOR_NAME (Supplier Name), G_INVOICE_NUM (the Invoices group), Total Entered Amount, and Total Accounted Amount. And, for each occurrence of G_INVOICE_NUM (Invoices group), we want the template to display Invoice Number, Invoice Date, GL Date, Currency, Entered Amount, and Accounted Amount.
To designate a group of repeating fields, insert the grouping tags around the elements to repeat.
Insert the following tag before the first element:
<?for-each:XML group element tag name?>
Insert the following tag after the final element:
<?end for-each?>

Grouping scenarios

Note that the group element must be a parent of the repeating elements in the XML input file.
  • If you insert the grouping tags around text or formatting elements, the text and formatting elements between the group tags will be repeated.
  • If you insert the tags around a table, the table will be repeated.
  • If you insert the tags around text in a table cell, the text in the table cell between the tags will be repeated.
  • If you insert the tags around two different table cells, but in the same table row, the single row will be repeated.
  • If you insert the tags around two different table rows, the rows between the tags will be repeated (this does not include the row that contains the "end group" tag).

Basic RTF Method

Enter the tags in your document to define the beginning and end of the repeating element group.
To create the Suppliers group in the example, insert the tag
<?for-each:G_VENDOR_NAME?>
before the Supplier field that you previously created.
Insert <?end for-each?> in the document after the summary row.
The following figure shows the Payables Invoice Register with the basic RTF grouping and placeholder markup:

 

Form Field Method

  1. Insert a form field to designate the beginning of the group.
    In the help text field enter:
    <?for-each:group element tag name?>
    To create the Suppliers group in the example, insert a form field before the Suppliers field that you previously created. In the help text field enter:
    <?for-each:G_VENDOR_NAME?>
    For the example, enter the Default text "Group: Suppliers" to designate the beginning of the group on the template. The Default text is not required, but can make the template easier to read.
  2. Insert a form field after the final placeholder element in the group. In the help text field enter <?end for-each?>.
    For the example, enter the Default text "End: Suppliers" after the summary row to designate the end of the group on the template.
    The following figure shows the template after the markup to designate the Suppliers group was added.


Complete the Example

The second group in the example is the invoices group. The repeating elements in this group are displayed in the table. For each invoice, the table row should repeat. Create a group within the table to contain these elements.
Note: For each invoice, only the table row should repeat, not the entire table. Placing the grouping tags at the beginning and end of the table row will repeat only the row. If you place the tags around the table, then for each new invoice the entire table with headings will be repeated.
To mark up the example, insert the grouping tag <?for-each:G_INVOICE_NUM?> in the table cell before the Invoice Num placeholder. Enter the Default text "Group:Invoices" to designate the beginning of the group.
Insert the end tag inside the final table cell of the row after the Accounted Amt placeholder. Enter the Default text "End:Invoices" to designate the end of the group.
The following figure shows the completed example using the form field method:

Defining Headers and Footers

Native Support

XML Publisher supports the use of the native RTF header and footer feature. To create a header or footer, use the your word processing application's header and footer insertion tools. As an alternative, or if you have multiple headers and footers, you can use start:body and end body tags to distinguish the header and footer regions from the body of your report.

Inserting Placeholders in the Header and Footer

At the time of this writing, Microsoft Word does not support form fields in the header and footer. You must therefore insert the placeholder syntax directly into the template (basic RTF method), or use the start body/end body syntax described in the next section.

Multiple or Complex Headers and Footers

If your template requires multiple headers and footers, create them by using XML Publisher tags to define the body area of your report. You may also want to use this method if your header and footer contain complex objects that you wish to place in form fields. When you define the body area, the elements occurring before the beginning of the body area will compose the header. The elements occurring after the body area will compose the footer.
Use the following tags to enclose the body area of your report:
<?start:body?>
<?end body?>
Use the tags either directly in the template, or in form fields.
The Payables Invoice Register contains a simple header and footer and therefore does not require the start body/end body tags. However, if you wanted to add another header to the template, define the body area as follows:
  1. Insert <?start:body?> before the Suppliers group tag: <?for-each:G_VENDOR_NAME?>
  2. Insert <?end body?> after the Suppliers group closing tag: <?end for-each?>
The following figure shows the Payables Invoice Register with the start body/end body tags inserted:

Different First Page and Different Odd and Even Page Support

If your report requires a different header and footer on the first page of your report; or, if your report requires different headers and footers for odd and even pages, you can define this behavior using Microsoft Word's Page Setup dialog.
  1. Select Page Setup from the File menu.
  2. In the Page Setup dialog, select the Layout tab.
  3. In the Headers and footers region of the dialog, select the appropriate check box:
    Different odd and even
    Different first page
  4. Insert your headers and footers into your template as desired.
At runtime your generated report will exhibit the defined header and footer behavior.

Images and Charts

Images

XML Publisher supports several methods for including images in your published document:

Direct Insertion

Insert the jpg, gif, or png image directly in your template.

URL Reference

URL Reference
  1. Insert a dummy image in your template.
  2. In the Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{'http://image location'}
    For example, enter: url:{'http://www.oracle.com/images/ora_log.gif'}

OA Media Directory Reference

Note: This method only applies to Oracle E-Business Suite installations.
  1. Insert a dummy image in your template.
  2. In the Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the OA_MEDIA directory:
    url:{'${OA_MEDIA}/image name'}
    For example, enter:
    url:{'${OA_MEDIA}/ORACLE_LOGO.gif'}

Element Reference from XML File

  1. Insert a dummy image in your template.
  2. In the Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full URL to the image.
    You can also build a URL based on multiple elements at runtime. Just use the concat function to build the URL string. For example:
    url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
    This method can also be used with the OA_MEDIA reference as follows:
    url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}

Chart Support

XML Publisher leverages the graph capabilities of Oracle Business Intelligence Beans (BI Beans) to enable you to define charts and graphs in your RTF templates that will be populated with data at runtime. XML Publisher supports all the graph types and component attributes available from the BI Beans graph DTD.
The BI Beans graph DTD is fully documented in the following technical note available from the Oracle Technology Network (OTN): "DTD for Customizing Graphs in Oracle Reports."
The following summarizes the steps to add a chart to your template. These steps will be discussed in detail in the example that follows:
  1. Insert a dummy image in your template to define the size and position of your chart.
  2. Add the definition for the chart to the Alternative text box of the dummy image. The chart definition requires XSL commands.
  3. At runtime XML Publisher calls the BI Beans applications to render the image that is then inserted into the final output document.

Adding a Sample Chart

Following is a piece of XML data showing total sales by company division.
<sales year=2004>

<division>

<name>Groceries</name>

<totalsales>3810</totalsales>

<costofsales>2100</costofsales>

</division>

<division>

<name>Toys</name>

<totalsales>2432</totalsales>

<costofsales>1200</costofsales>

</division>

<division>

<name>Cars</name>

<totalsales>6753</totalsales>

<costofsales>4100</costofsales>

</division>

<division>

<name>Hardware</name>

<totalsales>2543</totalsales>

<costofsales>1400</costofsales>

</division>

<division>

<name>Electronics</name>

<totalsales>5965</totalsales>

<costofsales>3560</costofsales>

</division>

</sales>
This example will show how to insert a chart into your template to display it as a vertical bar chart as shown in the following figure:

Note the following attributes of this chart:
  • The style is a vertical bar chart.
  • The chart displays a background grid.
  • The components are colored.
  • Sales totals are shown as Y-axis labels.
  • Divisions are shown as X-axis labels.
  • The chart is titled.
  • The chart displays a legend.
Each of these properties can be customized to suit individual report requirements.

Inserting the Dummy Image

The first step is to add a dummy image to the template in the position you want the chart to appear. The image size will define how big the chart image will be in the final document.
Important: You must insert the dummy image as a "Picture" and not any other kind of object.
The following figure shows an example of a dummy image:

The image can be embedded inside a for-each loop like any other form field if you want the chart to be repeated in the output based on the repeating data. In this example, the chart is defined within the sales year group so that a chart will be generated for each year of data present in the XML file.
Right-click the image to open the Format Picture palette and select the Web tab. Use the Alternative text entry box to enter the code to define the chart characteristics and data definition for the chart.

Adding Code to the Alternative Text Box

The following graphic shows an example of the XML Publisher code in the Format Picture Alternative text box:

The content of the Alternative text represents the chart that will be rendered in the final document. For this chart, the text is as follows:
chart:

<Graph graphType = "BAR_VERT_CLUST">

<Title text="Company Sales 2004" visible="true" horizontalAlignment="CENTER"/>

<Y1Title text="Sales in Thousands" visible="true"/>

<O1Title text="Division" visible="true"/>

<LocalGridData colCount="{count(//division)}" rowCount="1">

<RowLabels>

<Label>Total Sales $1000s</Label>

</RowLabels>

<ColLabels>

<xsl:for-each select="//division">

<Label>

<xsl:value-of select="name"/>

</Label>

</xsl:for-each>

</ColLabels>

<DataValues>

<RowData>

<xsl:for-each select="//division">

<Cell>

<xsl:value-of select="totalsales"/>

</Cell>

</xsl:for-each>

</RowData>

</DataValues>

</LocalGridData>

</Graph>
The first element of your chart text must be the chart: element to inform the RTF parser that the following code describes a chart object.
Next is the opening <Graph> tag. Note that the whole of the code resides within the tags of the <Graph> element. This element has an attribute to define the chart type: graphType. If this attribute is not declared, the default chart is a vertical bar chart. BI Beans supports many different chart types. Several more types are presented in this section. For a complete listing, see the BI Beans graph DTD documentation.
The following code section defines the chart type and attributes:
<Title text="Company Sales 2004" visible="true" horizontalAlignment="CENTER"/>

<Y1Title text="Sales in Thousands" visible="true"/>

<O1Title text="Division" visible="true"/>
All of these values can be declared or you can substitute values from the XML data at runtime. For example, you can retrieve the chart title from an XML tag by using the following syntax:
<Title text="{CHARTTITLE}" visible="true" horizontalAlighment="CENTER"/>
where "CHARTTITLE" is the XML tag name that contains the chart title. Note that the tag name is enclosed in curly braces.
The next section defines the column and row labels:
<LocalGridData colCount="{count(//division)}" rowCount="1">

<RowLabels>

<Label>Total Sales $1000s</Label>

</RowLabels>

<ColLabels>

<xsl:for-each select="//division">

<Label>

<xsl:value-of select="name"/>

</Label>

</xsl:for-each>

</ColLabels>
The LocalGridData element has two attributes: colCount and rowCount. These define the number of columns and rows that will be shown at runtime. In this example, a count function calculates the number of columns to render:
colCount="{count(//division)}"
The rowCount has been hard-coded to 1. This value defines the number of sets of data to be charted. In this case it is 1.
Next the code defines the row and column labels. These can be declared, or a value from the XML data can be substituted at runtime. The row label will be used in the chart legend (that is, "Total Sales $1000s").
The column labels for this example are derived from the data: Groceries, Toys, Cars, and so on. This is done using a for-each loop:
 <ColLabels>

<xsl:for-each select="//division">

<Label>

<xsl:value-of select="name"/>

</Label>

</xsl:for-each>

</ColLabels>
This code loops through the <division> group and inserts the value of the <name> element into the <Label> tag. At runtime, this will generate the following XML:
<ColLabels>

<Label>Groceries</Label>

<Label>Toys</Label>

<Label>Cars</Label>

<Label>Hardware</Label>

<Label>Electronics</Label>

</ColLabels>
The next section defines the actual data values to chart:
<DataValues>

<RowData>

<xsl:for-each select="//division">

<Cell>

<xsl:value-of select="totalsales"/>

</Cell>

</xsl:for-each>

</RowData>

</DataValues>
Similar to the labels section, the code loops through the data to build the XML that is passed to the BI Beans rendering engine. This will generate the following XML:
<DataValues>

<RowData>

<Cell>3810</Cell>

<Cell>2432</Cell>

<Cell>6753</Cell>

<Cell>2543</Cell>

<Cell>5965</Cell>

</RowData>

</DataValues>

Additional Chart Samples

You can also display this data in a pie chart as shown in the following figure:

The following is the code added to the template to render this chart at runtime:
chart:

<Graph graphType="PIE">

<Title text="Company Sales 2004" visible="true"

horizontalAlignment="CENTER"/>

<LocalGridData rowCount="{count(//division)}" colCount="1">

<RowLabels>

<xsl:for-each select="//division">

<Label>

<xsl:value-of select="name"/>

</Label>

</xsl:for-each>

</RowLabels>

<DataValues>

<xsl:for-each select="//division">

<RowData>

<Cell>

<xsl:value-of select="totalsales"/>

</Cell>

</RowData>

</xsl:for-each>

</DataValues>

</LocalGridData>

</Graph>

Horizontal Bar Chart Sample

The following example shows total sales and cost of sales charted in a horizontal bar format. This example also adds the data from the cost of sales element (<costofsales>) to the chart:

The following code defines this chart in the template:
chart:

<Graph graphType = "BAR_HORIZ_CLUST">

<Title text="Company Sales 2004" visible="true" horizontalAlignment="CENTER"/>

<LocalGridData colCount="{count(//division)}" rowCount="2">

<RowLabels>

<Label>Total Sales ('000s)</Label>

<Label>Cost of Sales ('000s)</Label>

</RowLabels>

<ColLabels>

<xsl:for-each select="//division">

<Label><xsl:value-of select="name"/></Label>

</xsl:for-each>

</ColLabels>

<DataValues>

<RowData>

<xsl:for-each select="//division">

<Cell><xsl:value-of select="totalsales"/></Cell>

</xsl:for-each>

</RowData>

<RowData>

<xsl:for-each select="//division">

<Cell><xsl:value-of select="costofsales"/></Cell>

</xsl:for-each>

</RowData>

</DataValues>

</LocalGridData>

</Graph>
To accommodate the second set of data, the rowCount attribute for the LocalGridData element is set to 2. Also note the DataValues section defines two sets of data: one for Total Sales and one for Cost of Sales.

Changing the Appearance of Your Chart

There are many attributes available from the BI Beans graph DTD that you can manipulate to change the look and feel of your chart. For example, the previous chart can be changed to remove the grid, place a graduated background, and change the bar colors and fonts as shown in the following figure:

The code to support this is as follows:
chart:

<Graph graphType = "BAR_HORIZ_CLUST">

<SeriesItems>

<Series id="0" color="#ffcc00"/>

<Series id="1" color="#ff6600"/>

</SeriesItems>

<O1MajorTick visible="false"/>

<X1MajorTick visible="false"/>

<Y1MajorTick visible="false"/>

<Y2MajorTick visible="false"/>

<MarkerText visible="true" markerTextPlace="MTP_CENTER"/>

<PlotArea borderTransparent="true">

<SFX fillType="FT_GRADIENT" gradientDirection="GD_LEFT"

gradientNumPins="300">

<GradientPinStyle pinIndex="1" position="1"

gradientPinLeftColor="#999999"

gradientPinRightColor="#cc6600"/>

</SFX>

</PlotArea>

<Title text="Company Sales 2004" visible="true">

<GraphFont name="Tahoma" bold="false"/>

</Title>

. . .

</Graph>
The colors for the bars are defined in the SeriesItems section. The colors are defined in hexadecimal format as follows:
<SeriesItems>

<Series id="0" color="#ffcc00"/>

<Series id="1" color="#ff6600"/>

</SeriesItems> 
The following code hides the chart grid:
 <O1MajorTick visible="false"/>

<X1MajorTick visible="false"/>

<Y1MajorTick visible="false"/>

<Y2MajorTick visible="false"/>
The MarkerText tag places the data values on the chart bars:
<MarkerText visible="true" markerTextPlace="MTP_CENTER"/> 
The Plot Area section defines the background. The SFX element establishes the gradient and the border Transparent attribute hides the plot border:
<PlotArea borderTransparent="true">

<SFX fillType="FT_GRADIENT" gradientDirection="GD_LEFT"

gradientNumPins="300">

<GradientPinStyle pinIndex="1" position="1"

gradientPinLeftColor="#999999"

gradientPinRightColor="#cc6600"/>

</SFX>

</PlotArea>
The Title text tag has also been updated to specify a new font type and size:
<Title text="Company Sales 2004" visible="true">

<GraphFont name="Tahoma" bold="false"/>

</Title>

Drawing, Shape and Clip Art Support

XML Publisher supports Microsoft Word drawing, shape, and clip art features. You can add these objects to your template and they will be rendered in your final PDF output.
The following AutoShape categories are supported:
  • Lines - straight, arrowed, connectors, curve, free form, and scribble
  • Connectors - straight connectors only are supported. Curved connectors can be achieved by using a curved line and specifying the end styles to the line.
  • Basic Shapes - all shapes are supported.
  • Block arrows - all arrows are supported.
  • Flowchart - all flowchart objects are supported.
  • Stars and Banners - all objects are supported.
  • Callouts - the "line" callouts are not supported.
  • Clip Art - add images to your templates using the Microsoft Clip Art libraries

Freehand Drawing

Use the freehand drawing tool in Microsoft Word to create drawings in your template to be rendered in the final PDF output.

Hyperlinks

You can add hyperlinks to your shapes. See Hyperlinks.

Layering

You can layer shapes on top of each other and use the transparency setting in Microsoft Word to allows shapes on lower layers to show through. The following graphic shows an example of layered shapes:

3-D Effects

XML Publisher does not currently support the 3-D option for shapes.

Microsoft Equation

Use the equation editor to generate equations in your output. The following figure shows an example of an equation:

Organization Chart

Use the organization chart functionality in your templates and the chart will be rendered in the output. The following image shows an example of an organization chart:

WordArt

You can use Microsoft Word's WordArt functionality in your templates. The following graphic shows a WordArt example:

Note: Some Microsoft WordArt uses a bitmap operation that currently cannot be converted to SVG. To use the unsupported WordArt in your template, you can take a screenshot of the WordArt then save it as an image (gif, jpeg, or png) and replace the WordArt with the image.

Data Driven Shape Support

In addition to supporting the static shapes and features in your templates, XML Publisher supports the manipulation of shapes based on incoming data or parameters, as well. The following manipulations are supported:
  • Replicate
  • Move
  • Change size
  • Add text
  • Skew
  • Rotate
These manipulations not only apply to single shapes, but you can use the group feature in Microsoft Word to combine shapes together and manipulate them as a group.

Placement of Commands

Enter manipulation commands for a shape in the Web tab of the shape's properties dialog as shown in the following example figure:

Replicate a Shape

You can replicate a shape based on incoming XML data in the same way you replicate data elements in a for-each loop. To do this, use a for-each@shape command in conjunction with a shape-offset declaration. For example, to replicate a shape down the page, use the following syntax:
<?for-each@shape:SHAPE_GROUP?>

<?shape-offset-y:(position()-1)*100?>

<?end for-each?>
where
for-each@shape opens the for-each loop for the shape context
SHAPE_GROUP is the name of the repeating element from the XML file. For each occurrence of the element SHAPE_GROUP a new shape will be created.
shape-offset-y: - is the command to offset the shape along the y-axis.
(position()-1)*100) - sets the offset in pixels per occurrence. The XSL position command returns the record counter in the group (that is 1,2,3,4); one is subtracted from that number and the result is multiplied by 100. Therefore for the first occurrence the offset would be 0: (1-1) * 100. The offset for the second occurrence would be 100 pixels: (2-1) *100. And for each subsequent occurrence the offset would be another 100 pixels down the page.

Add Text to a Shape

You can add text to a shape dynamically either from the incoming XML data or from a parameter value. In the property dialog enter the following syntax:
<?shape-text:SHAPETEXT?>
where SHAPETEXT is the element name in the XML data. At runtime the text will be inserted into the shape.

Add Text along a Path

You can add text along a line or curve from incoming XML data or a parameter. After drawing the line, in the property dialog enter:
<?shape-text-along-path:SHAPETEXT?>
where SHAPETEXT is the element from the XML data. At runtime the value of the element SHAPETEXT will be inserted above and along the line.

Moving a Shape

You can move a shape or transpose it along both the x and y-axes based on the XML data. For example to move a shape 200 pixels along the y-axis and 300 along the x-axis, enter the following commands in the property dialog of the shape:
<?shape-offset-x:300?>

<?shape-offset-y:200?>

Rotating a Shape

To rotate a shape about a specified axis based on the incoming data, use the following command:
<?shape-rotate:ANGLE;'POSITION'?>
where
ANGLE is the number of degrees to rotate the shape. If the angle is positive, the rotation is clockwise; if negative, the rotation is counterclockwise.
POSITION is the point about which to carry out the rotation, for example, 'left/top'. Valid values are combinations of left, right, or center with center, top, or bottom. The default is left/top. The following figure shows these valid values:

To rotate this rectangle shape about the bottom right corner, enter the following syntax:
<?shape-rotate:60,'right/bottom'?>
You can also specify an x,y coordinate within the shape itself about which to rotate.

Skewing a Shape

You can skew a shape along its x or y axis using the following commands:
<?shape-skew-x:ANGLE;'POSITION'?>

<?shape-skew-y:ANGLE;'POSITION'?>
where
ANGLE is the number of degrees to skew the shape. If the angle is positive, the skew is to the right.
POSITION is the point about which to carry out the rotation, for example, 'left/top'. Valid values are combinations of left, right, or center with center, top, or bottom. See the figure under Rotating a Shape. The default is 'left/top'.
For example, to skew a shape by 30 degrees about the bottom right hand corner, enter the following:
<?shape-skew-x:number(.)*30;'right/bottom'?>

Changing the Size of a Shape

You can change the size of a shape using the appropriate commands either along a single axis or both axes. To change a shape's size along both axes, use:
<?shape-size:RATIO?>
where RATIO is the numeric ratio to increase or decrease the size of the shape. Therefore a value of 2 would generate a shape twice the height and width of the original. A value of 0.5 would generate a shape half the size of the original.
To change a shape's size along the x or y axis, use:
<?shape-size-x:RATIO?>

<?shape-size-y:RATIO?>
Changing only the x or y value has the effect of stretching or shrinking the shape along an axis. This can be data driven.

Combining Commands

You can also combine these commands to carry out multiple transformations on a shape at one time. For example, you can replicate a shape and for each replication, rotate it by some angle and change the size at the same time.
The following example shows how to replicate a shape, move it 50 pixels down the page, rotate it by five degrees about the center, stretch it along the x-axis and add the number of the shape as text:
<for-each@shape:SHAPE_GROUP?>

<?shape-text:position()?>

<?shape-offset-y:position()*50?>

<?shape-rotate:5;'center/center'?>

<?shape-size-x:position()+1?>

<end for-each?>
This would generate the output shown in the following figure:

CD Ratings Example

This example demonstrates how to set up a template that will generate a star-rating based on data from an incoming XML file.
Assume the following incoming XML data:
<CATALOG>

<CD>

<TITLE>Empire Burlesque</TITLE>

<ARTIST>Bob Dylan</ARTIST>

<COUNTRY>USA</COUNTRY>

<COMPANY>Columbia</COMPANY>

<PRICE>10.90</PRICE>

<YEAR>1985</YEAR>

<USER_RATING>4</USER_RATING>

</CD>

<CD>

<TITLE>Hide Your Heart</TITLE>

<ARTIST>Bonnie Tylor</ARTIST>

<COUNTRY>UK</COUNTRY>

<COMPANY>CBS Records</COMPANY>

<PRICE>9.90</PRICE>

<YEAR>1988</YEAR>

<USER_RATING>3</USER_RATING>

</CD>

<CD>

<TITLE>Still got the blues</TITLE>

<ARTIST>Gary More</ARTIST>

<COUNTRY>UK</COUNTRY>

<COMPANY>Virgin Records</COMPANY>

<PRICE>10.20</PRICE>

<YEAR>1990</YEAR>

<USER_RATING>5</USER_RATING>

</CD>

<CD>

<TITLE>This is US</TITLE>

<ARTIST>Gary Lee</ARTIST>

<COUNTRY>UK</COUNTRY>

<COMPANY>Virgin Records</COMPANY>

<PRICE>12.20</PRICE>

<YEAR>1990</YEAR>

<USER_RATING>2</USER_RATING>

</CD>

<CATALOG>
Notice there is a USER_RATING element for each CD. Using this data element and the shape manipulation commands, we can create a visual representation of the ratings so that the reader can compare them at a glance.
A template to achieve this is shown in the following figure:

The values for the fields are shown in the following table:




Field
Form Field Entry
F
<?for-each:CD?>
TITLE
<?TITLE?>
ARTIST
<?ARTIST?>
E
<?end for-each?>
(star shape)
Web Tab Entry:
<?for-each@shape:xdoxslt:foreach_number($_XDOCTX,0,USER_RATING,1)?>
<?shape-offset-x:(position()-1)*25?>
<?end for-each?>
The form fields hold the simple element values. The only difference with this template is the value for the star shape. The replication command is placed in the Web tab of the Format AutoShape dialog.
In the for-each@shape command we are using a command to create a "for...next loop" construct. We specify 1 as the starting number; the value of USER_RATING as the final number; and 1 as the step value. As the template loops through the CDs, we create an inner loop to repeat a star shape for every USER_RATING value (that is, a value of 4 will generate 4 stars). The output from this template and the XML sample is shown in the following graphic:

Grouped Shape Example

This example shows how to combine shapes into a group and have them react to the incoming data both individually and as a group. Assume the following XML data:
<SALES>

<SALE>

<REGION>Americas</REGION>

<SOFTWARE>1200</SOFTWARE>

<HARDWARE>850</HARDWARE>

<SERVICES>2000</SERVICES>

</SALE>

<SALE>

<REGION>EMEA</REGION>

<SOFTWARE>1000</SOFTWARE>

<HARDWARE>800</HARDWARE>

<SERVICES>1100</SERVICES>

</SALE>

<SALE>

<REGION>APAC</REGION>

<SOFTWARE>900</SOFTWARE>

<HARDWARE>1200</HARDWARE>

<SERVICES>1500</SERVICES>

</SALE>

</SALES>
You can create a visual representation of this data so that users can very quickly understand the sales data across all regions. Do this by first creating the composite shape in Microsoft Word that you wish to manipulate. The following figure shows a composite shape made up of four components:

The shape consists of three cylinders: red, yellow, and blue. These will represent the data elements software, hardware, and services. The combined object also contains a rectangle that is enabled to receive text from the incoming data.
The following commands are entered into the Web tab:
Red cylinder: <?shape-size-y:SOFTWARE div 1000;'left/bottom'?>
Yellow cylinder: <?shape-size-y:HARDWARE div 1000;'left/bottom'?>
Blue cylinder: <?shape-size-y:SERVICES div 1000;'left/bottom'?>
The shape-size command is used to stretch or shrink the cylinder based on the values of the elements SOFTWARE, HARDWARE, and SERVICES. The value is divided by 1000 to set the stretch or shrink factor. For example, if the value is 2000, divide that by 1000 to get a factor of 2. The shape will generate as twice its current height.
The text-enabled rectangle contains the following command in its Web tab:
<?shape-text:REGION?>
At runtime the value of the REGION element will appear in the rectangle.
All of these shapes were then grouped together and in the Web tab for the grouped object, the following syntax is added:
<?for-each@shape:SALE?>

<?shape-offset-x:(position()-1)*110?>

<?end for-each?>
In this set of commands, the for-each@shape loops over the SALE group. The shape-offset command moves the next shape in the loop to the right by a specific number of pixels. The expression (position()-1) sets the position of the object. The position() function returns a record counter while in the loop, so for the first shape, the offset would be 1-1*100, or 0, which would place the first rendering of the object in the position defined in the template. Subsequent occurrences would be rendered at a 100 pixel offset along the x-axis (to the right).
At runtime three sets of shapes will be rendered across the page as shown in the following figure:

To make an even more visually representative report, these shapes can be superimposed onto a world map. Just use the "Order" dialog in Microsoft Word to layer the map behind the grouped shapes.
Microsoft Word 2000 Users: After you add the background map and overlay the shape group, use the Grouping dialog to make the entire composition one group.
Microsoft Word 2002/3 Users: These versions of Word have an option under Tools > Options, General tab to "Automatically generate drawing canvas when inserting auto shapes". Using this option removes the need to do the final grouping of the map and shapes. We can now generate a visually appealing output for our report as seen in the following figure:


Supported Native Formatting Features

In addition to the features already listed, XML Publisher supports the following features of Microsoft Word.

General Features

  • Large blocks of text
  • Page breaks
    To insert a page break, insert a Ctrl-Enter keystroke just before the closing tag of a group. For example if you want the template to start a new page for every Supplier in the Payables Invoice Register:
    1. Place the cursor just before the Supplier group's closing <?end for-each?> tag.
    2. Press Ctrl-Enter to insert a page break.
At runtime each Supplier will start on a new page.
Using this Microsoft Word native feature will cause a single blank page to print at the end of your report output. To avoid this single blank page, use XML Publisher's page break alias. See Special Features: Page Breaks.
  • Page numbering
    Insert page numbers into your final report by using the page numbering methods of your word processing application. For example, if you are using Microsoft Word:
    1. From the Insert menu, select Page Numbers...
    2. Select the Position, Alignment, and Format as desired.
At runtime the page numbers will be displayed as selected.

Alignment

Use your word processor's alignment features to align text, graphics, objects, and tables.
Note: Bidirectional languages are handled automatically using your word processing application's left/right alignment controls.

Tables

Supported table features include:
  • Nested Tables
  • Cell Alignment
    You can align any object in your template using your word processing application's alignment tools. This alignment will be reflected in the final report output.
  • Row spanning and column spanning
    You can span both columns and rows in your template as follows:
    1. Select the cells you wish to merge.
    2. From the Table menu, select Merge Cells.
    3. Align the data within the merged cell as you would normally.
At runtime the cells will appear merged.
  • Table Auto formatting
    XML Publisher recognizes the table auto formats available in Microsoft Word.
    1. Select the table you wish to format.
    2. From the Table menu, select Auto format.
    3. Select the desired table format.
At runtime, the table will be formatted using your selection.
  • Cell patterns and colors
    You can highlight cells or rows of a table with a pattern or color.
    1. Select the cell(s) or table.
    2. From the Table menu, select Table Properties.
    3. From the Table tab, select the Borders and Shading... button.
    4. Add borders and shading as desired.
  • Repeating table headers
    If your data is displayed in a table, and you expect the table to extend across multiple pages, you can define the header rows that you want to repeat at the start of each page.
    1. Select the row(s) you wish to repeat on each page.
    2. From the Table menu, select Heading Rows Repeat.
  • Prevent rows from breaking across pages.
    If you want to ensure that data within a row of a table is kept together on a page, you can set this as an option using Microsoft Word's Table Properties.
    1. Select the row(s) that you want to ensure do not break across a page.
    2. From the Table menu, select Table Properties.
    3. From the Row tab, deselect the check box "Allow row to break across pages".
  • Fixed-width columns
    To set the widths of your table columns:
    1. Select a column and then select Table > Table Properties.
    2. In the Table Properties dialog, select the Column tab.
    3. Enable the Preferred width checkbox and then enter the width as a Percent or in Inches.
    4. Select the Next Column button to set the width of the next column.
Note that the total width of the columns must add up to the total width of the table.
The following figure shows the Table Properties dialog:
  • Text truncation
    By default, if the text within a table cell will not fit within the cell, the text will be wrapped. To truncate the text instead, use the table properties dialog.
    1. Place your cursor in the cell in which you want the text truncated.
    2. Right-click your mouse and select Table Properties... from the menu, or navigate to Table > Table Properties...
    3. From the Table Properties dialog, select the Cell tab, then select Options...
    4. Deselect the Wrap Text check box.
      The following figure shows the Cell Options dialog.
An example of truncation is shown in the following graphic:

Date Fields

Insert dates using the date feature of your word processing application. Note that this date will correspond to the publishing date, not the request run date.

Multicolumn Page Support

XML Publisher supports Microsoft Word's Columns function to enable you to publish your output in multiple columns on a page.
Select Format > Columns to display the Columns dialog box to define the number of columns for your template. The following graphic shows the Columns dialog:

Multicolumn Page Example: Labels
To generate address labels in a two-column format:
  1. Divide your page into two columns using the Columns command.
  2. Define the repeatable group in the first column. Note that you define the repeatable group only in the first column, as shown in the following figure:

Tip: To prevent the address block from breaking across pages or columns, embed the label block inside a single-celled table. Then specify in the Table Properties that the row should not break across pages. See Prevent rows from breaking across pages.
This template will produce the following multicolumn output:

Background and Watermark Support

XML Publisher supports the "Background" feature in Microsoft Word. You can specify a single, graduated color or an image background for your template to be displayed in the PDF output. Note that this feature is supported for PDF output only.
To add a background to your template, use the Format > Background menu option.

Add a Background Using Microsoft Word 2000

From the Background pop up menu, you can:
  • Select a single color background from the color palette
  • Select Fill Effects to open the Fill Effects dialog. The Fill Effects dialog is shown in the following figure:

    From this dialog select one of the following supported options:
    • Gradient - this can be either one or two colors
    • Texture - choose one of the textures provided, or load your own
    • Pattern - select a pattern and background/foreground colors
    • Picture - load a picture to use as a background image

Add a Text or Image Watermark Using Microsoft Word 2002 or later

These versions of Microsoft Word allow you to add either a text or image watermark.
Use the Format > Background > Printed Watermark dialog to select either:
  • Picture Watermark - load an image and define how it should be scaled on the document
  • Text Watermark - use the predefined text options or enter your own, then specify the font, size and how the text should be rendered.
    The following figure shows the Printed Watermark dialog completed to display a text watermark:

Template Features

Page Breaks

To create a page break after the occurrence of a specific element use the "split-by-page-break" alias. This will cause the report output to insert a hard page break between every instance of a specific element.
To insert a page break between each occurrence of a group, insert the "split-by-page-break" form field within the group immediately before the <?end for-each?> tag that closes the group. In the Help Text of this form field enter the syntax:
<?split-by-page-break:?>
For the following XML, assume you want to create a page break for each new supplier:
<SUPPLIER>

<NAME>My Supplier</NAME>

<INVOICES>

<INVOICE>

<INVNUM>10001-1</INVNUM>

<INVDATE>1-Jan-2005</INVDATE>

<INVAMT>100</INVOICEAMT>

</INVOICE>

<INVOICE>

<INVNUM>10001-2</INVNUM>

<INVDATE>10-Jan-2005</INVDATE>

<INVAMT>200</INVOICEAMT>

</INVOICE>

</INVOICES>

</SUPPLIER>

<SUPPLIER>

<NAME>My Second Supplier</NAME>

<INVOICES>

<INVOICE>

<INVNUM>10001-1</INVNUM>

<INVDATE>11-Jan-2005</INVDATE>

<INVAMT>150</INVOICEAMT>

</INVOICE>

In the template sample shown in the following figure, the field called PageBreak contains the split-by-page-break syntax:

Place the Page Break field with the <?split-by-page-break:?> syntax immediately before the <?end for-each?> field. The Page Break field sits inside the end of the SUPPLIER loop. This will ensure a page break is inserted before the occurrence of each new supplier. This method avoids the ejection of an extra page at the end of the group when using the native Microsoft Word page break after the group.

Initial Page Number

Some reports require that the initial page number be set at a specified number. For example, monthly reports may be required to continue numbering from month to month. XML Publisher allows you to set the page number in the template to support this requirement.
Use the following syntax in your template to set the initial page number:
<?initial-page-number:pagenumber?>
Where page number is the XML element or parameter that holds the numeric value.
Example 1 - Set page number from XML data element
If your XML data contains an element to carry the initial page number, for example:
<REPORT>

<PAGESTART>200<\PAGESTART>

....

</REPORT>
Enter the following in your template:
<?initial-page-number:PAGESTART?>
Your initial page number will be the value of the PAGESTART element, which in this case is 200.
Example 2 - Set page number by passing a parameter value
If you define a parameter called PAGESTART, you can pass the initial value by calling the parameter.
Enter the following in your template:
<?initial-page-number:$PAGESTART?>
Note: You must first declare the parameter in your template. See Defining Parameters in Your Template.

Last Page Only Content

XML Publisher supports the Microsoft Word functionality to specify a different page layout for the first page, odd pages, and even pages. To implement these options, simply select Page Setup from the File menu, then select the Layout tab. XML Publisher will recognize the settings you make in this dialog.
However, Microsoft Word does not provide settings for a different last page only. This is useful for documents such as checks, invoices, or purchase orders on which you may want the content such as the check or the summary in a specific place only on the last page.
XML Publisher provides this ability. To utilize this feature, you must:
  1. Create a section break in your template to ensure the content of the final page is separated from the rest of the report.
  2. Insert the following syntax on the final page:
    <?start@last-page:body?>
    <?end body?>
Any content on the page that occurs above or below these two tags will appear only on the last page of the report. Also, note that because this command explicitly specifies the content of the final page, any desired headers or footers previously defined for the report must be reinserted on the last page.
This example uses the last page only feature for a report that generates an invoice listing with a summary to appear at the bottom of the last page.
Assume the following XML:
<?xml version="1.0" encoding="WINDOWS-1252"?>

<INVOICELIST>

<VENDOR>

<VENDOR_NAME>Nuts and Bolts Limited</VENDOR_NAME>

<ADDRESS>1 El Camino Real, Redwood City, CA 94065</ADDRESS>

<INVOICE>

<INV_TYPE>Standard</INV_TYPE>

<INVOICE_NUM>981110</INVOICE_NUM>

<INVOICE_DATE>10-NOV-04</INVOICE_DATE>

<INVOICE_CURRENCY_CODE>EUR</INVOICE_CURRENCY_CODE>

<ENT_AMT>122</ENT_AMT>

<ACCTD_AMT>122</ACCTD_AMT>

<VAT_CODE>VAT22%</VAT_CODE>

</INVOICE>

<INVOICE>

<INV_TYPE>Standard</INV_TYPE>

<INVOICE_NUM>100000</INVOICE_NUM>

<INVOICE_DATE>28-MAY-04</INVOICE_DATE>

<INVOICE_CURRENCY_CODE>FIM</INVOICE_CURRENCY_CODE>

<ENT_AMT>122</ENT_AMT>

<ACCTD_AMT>20.33</ACCTD_AMT>

<VAT_CODE>VAT22%</VAT_CODE>

</INVOICE>

</VENDOR>

<VENDOR>

...

<INVOICE>

...

</INVOICE>

</VENDOR>

<SUMMARY>

<SUM_ENT_AMT>61435</SUM_ENT_AMT>

<SUM_ACCTD_AMT>58264.68</SUM_ACCTD_AMT>

<TAX_CODE>EU22%</TAX_CODE>

</SUMMARY>

</INVOICELIST>
The report should show each VENDOR and their INVOICE data with a SUMMARY section that appears only on the last page, placed at the bottom of the page. The template for this is shown in the following figure:
Template Page One

Insert a Microsoft Word section break (type: next page) on the first page of the template. For the final page, insert new line characters to position the summary table at the bottom of the page. The summary table is shown in the following figure:
Last Page Only Layout

In this example:
  • The F and E components contain the for-each grouping statements.
  • The grayed report fields are placeholders for the XML elements.
  • The "Last Page Placeholder" field contains the syntax:
    <?start@last-page:body?> <?end body?>
    to declare the last page layout. Any content above or below this statement will appear on the last page only. The content above the statement is regarded as the header and the content below the statement is regarded as the footer.
If your reports contain headers and footers that you want to carry over onto the last page, you must reinsert them on the last page. For more information about headers and footers see Defining Headers and Footers.
You must insert a section break (type: next page) into the document to specify the last page layout. This example is available in the samples folder of the Oracle XML Publisher Template Builder for Word installation.
It is important to note that if the report is only one page in length, the first page layout will be used. If your report requires that a single page report should default to the last page layout (such as in a check printing implementation) then you can use the following alternate syntax for the "Last Page Placeholder" on the last page:
<?start@last-page-first:body?> <?end body?>
Substituting this syntax will result in the last page layout for reports that are only one page long.

Hyperlinks

XML Publisher supports several different types of hyperlinks. The hyperlinks can be fixed or dynamic and can link to either internal or external destinations. Hyperlinks can also be added to shapes.
  • To insert static hyperlinks to either text or a shape, use your word processing application's insert hyperlink feature:
    1. Select the text or shape.
    2. Use the right-mouse menu to select Hyperlink; or, select Hyperlink from the Insert menu.
    3. Enter the URL using any of the methods provided on the Insert Hyperlink dialog box.
The following screenshot shows the insertion of a static hyperlink using Microsoft Word's Insert Hyperlink dialog box.
  • If your input XML data includes an element that contains a hyperlink or part of one, you can create dynamic hyperlinks at runtime. In the Type the file or Web page name field of the Insert Hyperlink dialog box, enter the following syntax:
    {URL_LINK}
    where URL_LINK is the incoming data element name.
    If you have a fixed URL that you want to add elements from your XML data file to construct the URL, enter the following syntax:
    http://www.oracle.com?product={PRODUCT_NAME}
    where PRODUCT_NAME is the incoming data element name.
    In both these cases, at runtime the dynamic URL will be constructed.
    The following figure shows the insertion of a dynamic hyperlink using Microsoft Word's Insert Hyperlink dialog box. The data element SUPPLIER_URL from the incoming XML file will contain the hyperlink that will be inserted into the report at runtime.
  • You can also pass parameters at runtime to construct a dynamic URL.
    Enter the parameter and element names surrounded by braces to build up the URL as follows:
{$SERVER_URL}{REPORT}/cstid={CUSTOMER_ID}
Where SERVER_URL and REPORT are parameters passed to the template at runtime (note the $ sign) and CUSTOMER_ID is an XML data element. This link may render as:
http://myserver.domain:8888/CustomerReport/cstid=1234

Inserting Internal Links

Insert internal links into your template using Microsoft Word's Bookmark feature.
  1. Position your cursor in the desired destination in your document.
  2. Select Insert > Bookmark...
  3. In the Bookmark dialog, enter a name for this bookmark, and select Add.
  4. Select the text or shape in your document that you want to link back to the Bookmark target.
  5. Use the right-mouse menu to select Hyperlink; or select Hyperlink from the Insert menu.
  6. On the Insert Hyperlink dialog, select Bookmark.
  7. Choose the bookmark you created from the list.
At runtime, the link will be maintained in your generated report.

Table of Contents

XML Publisher supports the table of contents generation feature of the RTF specification. Follow your word processing application's procedures for inserting a table of contents.
XML Publisher also provides the ability to create dynamic section headings in your document from the XML data. You can then incorporate these into a table of contents.
To create dynamic headings:
  1. Enter a placeholder for the heading in the body of the document, and format it as a "Heading", using your word processing application's style feature. You cannot use form fields for this functionality.
    For example, you want your report to display a heading for each company reported. The XML data element tag name is <COMPANY_NAME>. In your template, enter <?COMPANY_NAME?> where you want the heading to appear. Now format the text as a Heading.
  2. Create a table of contents using your word processing application's table of contents feature.
At runtime the TOC placeholders and heading text will be substituted.

Generating Bookmarks in PDF Output

If you have defined a table of contents in your RTF template, you can use your table of contents definition to generate links in the Bookmarks tab in the navigation pane of your output PDF. The bookmarks can be either static or dynamically generated.
For information on creating the table of contents, see Table of Contents.
  • To create links for a static table of contents:
    Enter the syntax:
    <?copy-to-bookmark:?>
    directly above your table of contents and
    <?end copy-to-bookmark:?>
    directly below the table of contents.
  • To create links for a dynamic table of contents:
    If you have a dynamic table of contents in your, enter the syntax:
    <?convert-to-bookmark:?>
    directly above the table of contents and
    <?end convert-to-bookmark:?>
    directly below the table of contents.

Check Boxes

You can include a check box in your template that you can define to display as checked or unchecked based on a value from the incoming data.
To define a check box in your template:
  1. Position the cursor in your template where you want the check box to display, and select the Check Box Form Field from the Forms tool bar (shown in the following figure).
  2. Right-click the field to open the Check Box Form Field Options dialog.
  3. Specify the Default value as either Checked or Not Checked.
  4. In the Form Field Help Text dialog, enter the criteria for how the box should behave. This must be a boolean expression (that is, one that returns a true or false result).
    For example, suppose your XML data contains an element called <population>. You want the check box to appear checked if the value of <population> is greater than 10,000. Enter the following in the help text field:
<?population>10000?>
This is displayed in the following figure:

Note that you do not have to construct an "if" statement. The expression is treated as an "if" statement.
See the next section for a sample template using a check box.

droap Down Lists

XML Publisher allows you to use the droap-down form field to create a cross-reference in your template from your XML data to some other value that you define in the droap-down form field.
For example, suppose you have the following XML:
countries>

<country>

<name>Chad</name>

<population>7360000</population>

<continentIndex>5</continentIndex>

</country>

<country>

<name>China</name>

<population>1265530000</population>

<continentIndex>1</continentIndex>

</country>

<country>

<name>Chile</name>

<population>14677000</population>

<continentIndex>3</continentIndex>

</country>

. . .

</countries>
Notice that each <country> entry has a <continentindex> entry, which is a numeric value to represent the continent. Using the droap-down form field, you can create an index in your template that will cross-reference the <continentindex> value to the actual continent name. You can then display the name in your published report.
To create the index for the continent example:
  1. Position the cursor in your template where you want the value from the drop-down list to display, and select the drop-Down Form Field from the Forms tool bar (shown in the following figure).
  2. Right-click the field to display the drop-Down Form Field Options dialog.
  3. Add each value to the drop-down item field and the click Add to add it to the Items in drop-down list group. The values will be indexed starting from one for the first, and so on. For example, the list of continents will be stored as follows:



Index
alue
1
Asia

North America
3
South America
4
Europe
5
Africa
6
Australia

  1. Now use the Help Text box to enter the XML element name that will hold the index for the drop-down field values.
    For this example, enter
<?continentIndex?>
The following figure shows the drop-Down Form Field Options dialogs for this example:
Using the check box and drop-down list features, you can create a report to display population data with check boxes to demonstrate figures that reach a certain limit. An example is shown in the following figure:

The template to create this report is shown in the next figure:

where the fields have the following values:




Field
Form Field Entry
Description
FE
<?for-each:country?>
Begins the country repeating group.
China
<?name?>
Placeholder for the name element.
1,000,000
<?population?>
Placeholder for the population element.
(check box)
<?population>1000000?>

...
<dataTemplate name="INTDOMHOLD" defaultPackage="" description="INTDOMHOLD">
<parameters>
<parameter name="p_hold" dataType="VARCHAR2" defaultValue=""/>
</parameters>
<dataQuery>
<sqlStatement name="Q1" dataSourceRef=""><![CDATA[SELECT ooh.order_number
,ooh.flow_status_code header_status
,hp.party_name customer_name
, ool.line_number ||
'.' ||
ool.shipment_number line
,ott.NAME line_type
,ool.unit_selling_price expected_price
,ool.flow_status_code line_status
,ool.ordered_item
,'Yes' "Invoiceable Item"
,DECODE( oh.released_flag, 'N', 'Yes', 'No' ) hold_active
,ohd.NAME hold_name
,TO_CHAR( ohs.hold_until_date, 'DD-Mon-YYYY' ) hold_until_date
,TO_CHAR( ohs.hold_until_date, 'DD-Mon-YYYY' ) hold_release_date
,( SELECT rct.trx_number
FROM ra_customer_trx_lines_all rcl, ra_customer_trx_all rct
WHERE rct.customer_trx_id = rcl.customer_trx_id
AND rcl.interface_line_context = 'ORDER ENTRY'
AND rcl.sales_order_line = ool.line_number
AND rcl.sales_order = ooh.order_number
AND rcl.interface_line_attribute2 = 'OKS Billing Order' )invoice
,( SELECT TO_CHAR( rct.trx_date, 'DD-Mon-YYYY' )
FROM ra_customer_trx_lines_all rcl, ra_customer_trx_all rct
WHERE rct.customer_trx_id = rcl.customer_trx_id
AND rcl.interface_line_context = 'ORDER ENTRY'
AND rcl.sales_order_line = ool.line_number
AND rcl.sales_order = ooh.order_number
AND rcl.interface_line_attribute2 = 'OKS Billing Order' ) invoice_date
FROM oe_order_lines_all ool
,oe_order_headers_all ooh
,oe_order_holds_all oh
,mtl_system_items_b msi
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_acct_sites_all hcas
,apps.hz_cust_site_uses_all hcsu
,oe_transaction_types_tl ott
,oe_hold_sources_all ohs
,oe_hold_definitions ohd
WHERE ooh.header_id = ool.header_id
AND ool.org_id = msi.organization_id
AND ool.ordered_item = msi.segment1
AND msi.invoiceable_item_flag = 'Y'
AND ool.flow_status_code IN( 'CLOSED', 'INVOICE_HOLD' )
AND ool.line_type_id = ott.transaction_type_id
AND ott.NAME = 'OKS Billing Line'
AND ool.header_id = 11878
AND ool.line_id = oh.line_id
AND ooh.header_id = oh.header_id
AND oh.hold_source_id = ohs.hold_source_id
AND ohs.hold_id = ohd.hold_id
AND oh.released_flag = 'N'
AND ool.invoice_to_org_id = hcsu.site_use_id(+)
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id(+)
AND hca.party_id = hp.party_id(+)
AND hcas.cust_account_id = hca.cust_account_id(+)
AND hcsu.site_use_code(+) = 'BILL_TO'
AND ohd.NAME = NVL( :p_hold, ohd.NAME )
-- AND ohs.hold_until_date = NVL( :p_to_release, ohs.hold_until_date )
AND NOT EXISTS(
SELECT 1
FROM ra_customer_trx_lines_all
WHERE interface_line_context = 'ORDER ENTRY'
AND sales_order_line = ool.line_number
AND sales_order = ooh.order_number
AND interface_line_attribute2 = 'OKS Billing Line' )
UNION
SELECT ooh.order_number
,ooh.flow_status_code header_status
,hp.party_name customer_name
, ool.line_number ||
'.' ||
ool.shipment_number line
,ott.NAME line_type
,ool.unit_selling_price expected_price
,ool.flow_status_code line_status
,ool.ordered_item
,'Yes' "Invoiceable Item"
,DECODE( oh.released_flag, 'N', 'Yes', 'No' ) hold_active
,ohd.NAME hold_name
,TO_CHAR( ohs.hold_until_date, 'DD-Mon-YYYY' ) hold_until_date
,TO_CHAR( ohr.creation_date, 'DD-Mon-YYYY' ) hold_release_date
,( SELECT rct.trx_number
FROM ra_customer_trx_lines_all rcl, ra_customer_trx_all rct
WHERE rct.customer_trx_id = rcl.customer_trx_id
AND rcl.interface_line_context = 'ORDER ENTRY'
AND rcl.sales_order_line = ool.line_number
AND rcl.sales_order = ooh.order_number
AND rcl.interface_line_attribute2 = 'OKS Billing Order' ) invoice
,( SELECT TO_CHAR( rct.trx_date, 'DD-Mon-YYYY' )
FROM ra_customer_trx_lines_all rcl, ra_customer_trx_all rct
WHERE rct.customer_trx_id = rcl.customer_trx_id
AND rcl.interface_line_context = 'ORDER ENTRY'
AND rcl.sales_order_line = ool.line_number
AND rcl.sales_order = ooh.order_number
AND rcl.interface_line_attribute2 = 'OKS Billing Order' ) invoice_date
FROM oe_order_lines_all ool
,oe_order_headers_all ooh
,oe_order_holds_all oh
,mtl_system_items_b msi
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_acct_sites_all hcas
,apps.hz_cust_site_uses_all hcsu
,oe_transaction_types_tl ott
,oe_hold_sources_all ohs
,oe_hold_definitions ohd
,oe_hold_releases ohr
WHERE ooh.header_id = ool.header_id
AND ool.org_id = msi.organization_id
AND ool.ordered_item = msi.segment1
AND msi.invoiceable_item_flag = 'Y'
AND ool.flow_status_code IN( 'CLOSED', 'INVOICE_HOLD' )
AND ool.line_type_id = ott.transaction_type_id
AND ott.NAME = 'OKS Billing Line'
AND ool.header_id = 11878
AND ool.line_id = oh.line_id
AND ooh.header_id = oh.header_id
AND oh.hold_source_id = ohs.hold_source_id
AND ohs.hold_id = ohd.hold_id
AND oh.released_flag = 'Y'
AND ohr.hold_release_id = oh.hold_release_id
AND ool.invoice_to_org_id = hcsu.site_use_id(+)
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id(+)
AND hca.party_id = hp.party_id(+)
AND hcas.cust_account_id = hca.cust_account_id(+)
AND hcsu.site_use_code(+) = 'BILL_TO'
AND ohd.NAME = NVL( :p_hold, ohd.NAME )
-- AND ohr.creation_date = NVL( :p_to_release, ohr.creation_date )
AND NOT EXISTS(
SELECT 1
FROM ra_customer_trx_lines_all
WHERE interface_line_context = 'ORDER ENTRY'
AND sales_order_line = ool.line_number
AND sales_order = ooh.order_number
AND interface_line_attribute2 = 'OKS Billing Line')]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_ORDER" source="Q1" groupFilter="">
<element name="ORDER" value="ORDER" function=""/>
<element name="HEADER_STATUS" value="HEADER_STATUS" function=""/>
<element name="CUSTOMER" value="CUSTOMER" function=""/>
<element name="LINE" value="LINE" function=""/>
<element name="LINE_TYPE" value="LINE_TYPE" function=""/>
<element name="EXPECTED_PRICE" value="EXPECTED_PRICE" function=""/>
<element name="LINE_STATUS" value="LINE_STATUS" function=""/>
<element name="ORDERED_ITEM" value="ORDERED_ITEM" function=""/>
<element name="HOLD_ACTIVE" value="HOLD_ACTIVE" function=""/>
<element name="HOLD_NAME" value="HOLD_NAME" function=""/>
<element name="HOLD_UNTIL_DATE" value="HOLD_UNTIL_DATE" function=""/>
<element name="HOLD_RELEASE_DATE" value="HOLD_RELEASE_DATE" function=""/>
<element name="INVOICE" value="INVOICE" function=""/>
<element name="INVOICE_DATE" value="INVOICE_DATE" function=""/>
</group>
</dataStructure>
</dataTemplate>

4 comments:

  1. It is very nice blog.You have given information about RTF to PDF Converter is very unique and useful to all.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hi,

      Could you please help on the below....

      I inserted Line Graph in RTF Template and displaying the data using FOR-EACH loop(3 iterations) in RTF Template , here the issue is Graph not displaying the data based on FOR_EACH loop, it is displaying same data in the first iteration 3 times.

      Please help on this...

      Delete
  3. Hi Prasad - Can you please ping me rajeshgang7@gmail.com.

    ReplyDelete

How to find all cancel Requisitions

SELECT prha . *   FROM po_Requisition_headers_all prha , po_action_history pah   WHERE      1 = 1        AND pah . object_id ...