The BI Publisher syntax is simplified XSL instructions. This syntax, along with any native XSL commands you may use in the template, is converted to XSL-FO at runtime. The placement of these instructions within the converted stylesheet determines the behavior of the template.
BI Publisher's RTF processor places these instructions within the XSL-FO stylesheet according to the most common context. However, sometimes you must define the context of the instructions differently to create a specific behavior. To support this requirement, BI 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 table.
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 BI Publisher syntax and those using native XSL.
To specify a context for a processing command using the simplified BI 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 you do not want to restart the page numbering, then add the command: <?initial-page-number:'auto'?>
after the @section command to continue the page numbering across sections.
<?if@column:VAT?>
- Specifies that the if
statement should apply to the VAT column only.
To specify a context for an XSL command, add the xdofo:ctx="context" attribute to the tags to specify the context for the insertion of the instructions. The value of the context determines where the code is placed.
For example:
<xsl:for-each xdofo:ctx="section" select ="INVOICE">
<xsl:attribute xdofo:ctx="inblock" name="background-color">red</xsl:attribute>
BI Publisher supports the context types that are described in the following table:
Context | Description |
---|---|
section |
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. Note that you can retain continuous page numbering across sections by using the |
column |
The statement affects the whole column of a table. This context is typically used to show and hide table columns depending on the data. See Formatting Columns for an example. |
cell |
The statement affects the cell of a table. This is often used together with @column in pivot tables to create a dynamic number of columns. See Inserting Pivot Tables for an example. |
block |
The statement affects multiple complete fo:blocks (RTF paragraphs). This context is typically used for |
inline |
The context becomes the single statement inside an fo:inline block. This context is used for variables. |
incontext |
The statement is inserted immediately after the surrounding statement. This is the default for |
inblock |
The statement becomes a single statement inside an fo:block (RTF paragraph). This is typically not useful for control statements (such as |
inlines |
The statement affects multiple complete inline sections. An inline section is text that uses the same formatting, such as a group of words rendered as bold. See Using If Statements in Boilerplate Text. If you use |
begin |
The statement is placed at the beginning of the XSL stylesheet. This is required for global variables. See Setting Parameters. |
end |
The statement is placed at the end of the XSL stylesheet. |
The following table shows the default context for the BI Publisher commands:
Command | Context |
---|---|
apply-template |
inline |
attribute |
inline |
call-template |
inblock |
choose |
block |
for-each |
block |
if |
block |
import |
begin |
param |
begin |
sort |
incontext |
template |
end |
value-of |
inline |
variable |
end |