You are on page 1of 6

Repeating Frame Tags

<?for-each:G_INVOICES?> <?end for-each?>

Individual Columns:

Group Tag
<?for-each:current-group()?>,<?INDUSTRY?>, <?SALES?>, <?end for-each?>
<?end for-each-group?>
<?end for-each-group?>

Comments or To disable a part of the text in RTF file.

<?if:1=2?> <?end if?>

<?for-each:G_VENDOR_NAME?>, <?VENDOR_NAME?>, <?ADDRESS?>, <?end for-each?>

<?for-each:G_VENDOR_NAME?><?if:position() mod 2=0?>, <?VENDOR_NAME?>, <?ADDRESS?>, <?end if?>
<?if:position() mod 2=1?>, <?VENDOR_NAME?>, <?ADDRESS?>, <?end if?><?end for-each?>

I Table 3: If you would like a striped effect on your rows this can be achieved in the template. We now use two almost
identical data rows in the table. The native XSL position() function is used to assign each row a numeric value, an if
statement is then used to test the value, so at the beginning of each row we get an if statement:
1st Row: if:position() mod 2=0
2nd Row: if:position() mod 2=1
The position() function will return a number for the row of data starting at 1. The mod or modulus function will
return a 0 or a 1 depending on the result e.g. 2 mod 2 returns 0 and 3 mod 2 returns a 1. So we shade each row as
required and add the if statement and at runtime the rows will be alternately shaded, in this case white and gray.
Repeatable Row Headers
If your invoices break across a page and you want to repeat the column header row this can be achieved using
MSWords functionality.
1. Highlight the header row
2. Table > Table Properties
3. Under the Row tab select the Repeat as Header row at the top of each page
If the invoices table breaks across a page the header row will be repeated.

Splitting Rows across pages

You can prevent rows splitting across a page break by using MSWords functionality:
1. Highlight the data row
2. Table > Table Properties
3. Under the Row tab deselect the Allow row to break across pages
Rows that would normally be split across two pages will now be moved to the second page to preserve the row data

Now lets combine the Suppliers with their Invoices, we will create an output that lists each Supplier and then their

Field Name Contents Description

Grp:Supplier for-each:G_VENDOR Used to loop through the Supplier members
Supplier 1 VENDOR_NAME Supplier Name
1 Long Avenue ADDRESS Address
Grp:Invoice <?for-each:G_INVOICE_NUM?> Used to loop through the Invoice group
1134922 <?INVOICE_NUM?> Invoice Number
1-Jan-2004 <?INVOICE_DATE?> Invoice Date
USD <?INVOICE_CURRENCY_CODE?> Invoice Currency Code
1-Jan-2004 <?GL_DATE?> GL Date
1000.00 <?ENT_AMT?> Entered amount
1000.00 <?ACCT_AMT?> Accounted Amount
End Invoice <?end for-each?> Ends the Invoice loop
End Supplier end for-each Ends the Supplier loop
We have two choices when it comes the the totals:
In this case the XML data contains the values at supplier level so we can just use a new field containing, <?
ENT_SUM_VENDOR?> and <?ACCTD_SUM_VENDOR?> respectively.
Alternatively we can use a native XSL SUM function to calculate the summary
<?sum(ENT_AMT)?> and <?sum(ACCTD_AMT)?>
This works very well but you should note that you are now performing calculations in the middle tier which is not as per
formant as in the database. You should perform as much of your business processing in the database as possible.
You also notice that we can give some context to the total by adding another form field to contain the supplier name, <?
VENDOR_NAME?>, as we are in the invoices level can simply reference the parent vendor name value for the supplier.

Report Totals
Similar to the supplier totals we can create placeholders for the report totals, these are contained in the XML but can also
be calculated.
<?sum(ENT_AMT)?> and sum(ACCTD_AMT)?>, to ensure that the calculation is applied to the whole data set ie for all
suppliers we place the table after the closing End Supplier field.

Invoice Listing by Supplier 6 Number Formatting

In this template we will focus on number formatting. There are several choices on how to formatt your number output:
XSL natively supports number formatting using its format-number function, it returns a formatted string and takes the

string format-number(number,format,[decimalformat])

Parameter Description
Number Required.Specifies the number to be
Format Required. Specifies the format pattern.
Here are some of the characters used in the formatting 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)
Decimalformat Optional.

So for example to format the entered amount for thousands and 2 decimal places we would use the following in the
format-number(ENT_AMT, "###,###.00" ) which would convert 1234.5 to 1,234.50
If you have negative numbers these are supported too in the format:
format-number(ENT_AMT, "###,###.00";"(###,###.00)" ) the second format denotes how the negative number should be
displayed, note the semi colon separating the formats. So -1234.5 would become (1,234,50)
To handle thousand/decimal delimeter formatting you need to do a little work on your template. XSL supports any
delimiters but it needs to be told what to use. You do this by declaring the decimal format in your template thus:
<xsl:decimal-format name="Euro" decimal-separator="," grouping-separator="." xdofo:ctx="begin"/>
Name is the name you give you format, this can be referenced from your format-number calls
decimal-separator this is the character you wish to use as the decimal point
grouping-separator this is the charater you wish to use to denote the thousand separator.
There are several other options that can be set but these are the basic two.
Please note the use of the xdofo:ctx=begin this is an advanced feature which forces the decimal format declaration to
the root of the template no matter where it is put in the physical RTF.
So when we call the format function this time we use:
<?format-number(ACCTD_AMT,'#.###,00', 'Euro')?>
this time 1234.5 will become 1.234,50 as expected. Note the format string has changed this time.
The other alternative is to use MSWords native field formatting. If you open one of the fields below youll notice that
there is a field type drop down list that includes Number as an option. You can select this, then select the number
format you require.
XDO Formatting once finalized XDO will format the numbers and dates according to runtime locale settings. Details to
In this template the
Entered Amt uses <?format-number(ENT_AMT,"#,###.00")?>
Accounted Amt uses <?format-number(ACCTD_AMT,"#.###,00","Euro")?>
Supplier totals use the MSWord formatting
Variable Declaration and calling:
<?xdoxslt:set_variable($_XDOCTX, 'x', 1)?> <?xdoxslt:get_variable($_XDOCTX, 'x')?>

<?xdoxslt:set_variable($_XDOCTX, 'x', xdoxslt:get_variable($_XDOCTX, 'x')+10)?><?xdoxslt:get_variable($_XDOCTX, 'x')?>

Running Totals
<?xdoxslt:set_variable($_XDOCTX, 'RTotVar', 0)?>

<?xdoxslt:set_variable($_XDOCTX, 'RTotVar', xdoxslt:get_variable($_XDOCTX, 'RTotVar') + ACCTD_AMT)?><?

xdoxslt:get_variable($_XDOCTX, 'RTotVar')?>

Page Totals


Conditional Highlighting with Text Decoration

Setting font to bold if invoice amount greater than 1000.

<?if:ACCTD_AMT>1000?><xsl:attribute xdofo:ctx="block" name="font-weight">bold</xsl:attribute><?end if?>

<?if:ACCTD_AMT>1000?><xsl:attribute xdofo:ctx="block" name="background-color">lime</xsl:attribute><?end if?>

Repeating Header
IFUse the for-each@section to repeat the header inforamtion across pages of the output document. In this case the Customer Name will
be repeated if the line information runs across more than one page, the page numbering will also be reset