2-124 Oracle XML Publisher Report Designer's Guide
The pipe (|) is equal to the logical OR operator. In addition, XPath recognizes the logical
OR and AND, as well as the equality operators: <=, <, >, >=, ==, and !=. For example, we
can find all CDs released in 1985 or later using the following expression:
The first character in an XPath expression determines the point at which it should start
in the XML tree. Statements beginning with a forward slash (/) are considered absolute.
No slash indicates a relative reference. An example of a relative reference is:
This statement begins the search at the current reference point. That means if the
example occurred within a group of statements the reference point left by the previous
statement would be utilized.
A noted earlier, double forward slashes (//) retrieve every matching element regardless
of location in the document.
Context and Parent
To select current and parent elements, XPath recognizes the dot notation commonly
used to navigate directories. Use a single period (.) to select the current node and use
double periods (..) to return the parent of the current node. For example, to retrieve all
child nodes of the parent of the current node, use:
Therefore, to access all CDs from the sample XML, use the following expression:
You could also access all the CD tittles released in 1988 using the following:
The .. is used to navigate up the tree of elements to find the YEAR element at the same
level as the TITLE, where it is then tested for a match against "1988". You could also use
// in this case, but if the element YEAR is used elsewhere in the XML document, you
may get erroneous results.
XPath is an extremely powerful standard when combined with RTF templates allowing
you to use conditional formatting and filtering in your template.
If your XML data contains namespaces, you must declare them in the template prior to
referencing the namespace in a placeholder. Declare the namespace in the template
using either the basic RTF method or in a form field. Enter the following syntax:
<?namespace:namespace name= namespace url?>
VB.NET PDF: How to Create Watermark on PDF Document within
Using this VB.NET Imaging PDF Watermark Add-on, you simply create a watermark that consists of text or image And with our PDF Watermark Creator, users need no how to add text box to pdf; how to add text to a pdf document using reader
Creating an RTF Template 2-125
Once declared, you can use the namespace in the placeholder markup, for example:
Using the Context Commands
The XML Publisher syntax is simplified XSL instructions. This syntax, along with any
native XSL commands you may use in your template, is converted to XSL-FO when you
upload the template to the Template Manager. The placement of these instructions
within the converted stylesheet determines the behavior of your template.
XML Publisher's RTF processor places these instructions within the XSL-FO stylesheet
according to the most common context. However, sometimes you need to define the
context of the instructions differently to create a specific behavior. To support this
requirement, XML Publisher provides a set of context commands that allow you to
define the context (or placement) of the processing instructions. For example, using
context commands, you can:
Specify an if statement in a table to refer to a cell, a row, a column or the whole
Specify a for-each loop to repeat either the current data or the complete section (to
create new headers and footers and restart the page numbering)
Define a variable in the current loop or at the beginning of the document.
You can specify a context for both processing commands using the XML Publisher
syntax and those using native XSL.
To specify a context for a processing command using the simplified XML Publisher
syntax, simply add @context to the syntax instruction. For example:
<?for-each@section:INVOICE?> - specifies that the group INVOICE
should begin a new section for each occurrence. By adding the section context,
you can reset the header and footer and page numbering.
<?if@column:VAT?> - specifies that the if statement should apply to the VAT
To specify a context for an XSL command, add the xdofo:ctx="context"
attribute to your tags to specify the context for the insertion of the instructions. The
value of the context determines where your code is placed.
<xsl:for-each xdofo:ctx="section" select ="INVOICE">
XML Publisher supports the following context types:
C# Excel - Excel Conversion & Rendering in C#.NET
without using other external third-party dependencies like Adobe Acrobat. you may easily achieve the following Excel file conversions. Excel to PDF Conversion. add text boxes to pdf document; adding text to pdf in acrobat
2-126 Oracle XML Publisher Report Designer's Guide
The statement affects the whole section including the header and footer. For
example, a for-each@section context command creates a new section for each
occurrence - with restarted page numbering and header and footer.
See Batch Reports, page 2-95 for an example of this usage.
The statement will affect the whole column of a table. This context is typically used
to show and hide table columns depending on the data.
See Column Formatting, page 2-67 for an example.
The statement will affect the cell of a table. This is often used together with
@column in cross-tab tables to create a dynamic number of columns.
See Cross-Tab Support, page 2-96 for an example.
The statement will affect multiple complete fo:blocks (RTF paragraphs). This
context is typically used for if and for-each statements. It can also be used to apply
formatting to a paragraph or a table cell.
See Cell Highlighting, page 2-72 for an example.
The context will become the single statement inside an fo:inline block. This context
is used for variables.
The statement is inserted immediately after the surrounding statement. This is the
default for <?sort?> statements that need to follow the surrounding for-each
as the first element.
The statement becomes a single statement inside an fo:block (RTF paragraph). This
is typically not useful for control statements (such as if and for-each) but is
useful for statements that generate text, such as call-template.
The statement will affect multiple complete inline sections. An inline section is text
that uses the same formatting, such as a group of words rendered as bold.
See If Statements in Boilerplate Text, page 2-64.
The statement will be placed at the beginning of the XSL stylesheet. This is
required for global variables. See Defining Parameters, page 2-90.
The statement will be placed at the end of the XSL stylesheet.
The following table shows the default context for the XML Publisher commands:
Creating an RTF Template 2-127
Using XSL Elements
You can use any XSL element in your template by inserting the XSL syntax into a form
If you are using the basic RTF method, you cannot insert XSL syntax directly into your
template. XML Publisher has extended the following XSL elements for use in RTF
To use these in a basic-method RTF template, you must use the XML Publisher Tag
form of the XSL element. If you are using form fields, use either option.
Apply a Template Rule
Use this element to apply a template rule to the current element's child nodes.
XSL Syntax: <xsl:apply-templates select="name">
XML Publisher Tag: <?apply:name?>
2-128 Oracle XML Publisher Report Designer's Guide
This function applies to <xsl:template-match="n"> where n is the element name.
Copy the Current Node
Use this element to create a copy of the current node.
XSL Syntax: <xsl:copy-of select="name">
XML Publisher Tag: <?copy-of:name?>
Use this element to call a named template to be inserted into or applied to the current
template. For example, use this feature to render a table multiple times.
XSL Syntax: <xsl:call-template name="name">
XML Publisher Tag: <?call-template:name?>
Use this element to apply a set of rules when a specified node is matched.
XSL Syntax: <xsl:template name="name">
XML Publisher Tag: <?template:name?>
Use this element to declare a local or global variable.
XSL Syntax: <xsl:variable name="name">
XML Publisher Tag: <?variable:name?>
<xsl:variable name="color" select="'red'"/>
Assigns the value "red" to the "color" variable. The variable can then be referenced in
Use this element to import the contents of one style sheet into another.
Note: An imported style sheet has lower precedence than the importing
XSL Syntax: <xsl:import href="url">
XML Publisher Tag: <?import:url?>
Creating an RTF Template 2-129
Define the Root Element of the Stylesheet
This and the <xsl:stylesheet> element are completely synonymous elements. Both
are used to define the root element of the style sheet.
Note: An included style sheet has the same precedence as the including
XSL Syntax: <xsl:stylesheet xmlns:x="url">
XML Publisher Tag: <?namespace:x=url?>
Note: The namespace must be declared in the template. See Namespace
Support, page 2-124.
Native XSL Number Formatting
The native XSL format-number function takes the basic format:
Required. Specifies the number to be formatted.
Required. Specifies the format pattern. Use the following
characters to specify the pattern:
# (Denotes a digit. Example: ####)
0 (Denotes leading and following zeros. Example: 0000.00)
. (The position of the decimal point Example: ###.##)
, (The group separator for thousands. Example: ###,###.##)
% (Displays the number as a percentage. Example: ##%)
; (Pattern separator. The first pattern will be used for
positive numbers and the second for negative numbers)
Optional. For more information on the decimal format please
consult any basic XSLT manual.
2-130 Oracle XML Publisher Report Designer's Guide
Using FO Elements
You can use the native FO syntax inside the Microsoft Word form fields.
For more information on XSL-FO see the W3C Website at
The full list of FO elements supported by XML Publisher can be found in the Appendix:
Supported XSL-FO Elements, page A-1.
To optimize the exact placement of elements when the template is transformed into
XSL, it is recommended that you use tables to define the placement and alignment.
Note the use of tables in the Payables Invoice Register:
A table is used in the header to place the image, the title, and the date in exact positions.
By using a table, each element can be aligned within its own cell; thereby allowing a left
alignment for the image, a center alignment for the title, and a right alignment for the
date and page number.
A table is also used for the totals line of the report to achieve alignment with the entries
in the Invoices table.
Tables used for formatting only can be hidden at runtime by turning off (hiding) the
Documents you may be interested
Documents you may be interested