Sie sind auf Seite 1von 11

Browser version scriptSkip Headers

Oracle Business Intelligence Publisher Report Designer's Guide Release 10.1.3.4 Part Number E12187-01

Contents Previous Next

Extended Function Support in RTF Templates


Extended SQL and XSL Functions
BI Publisher has extended a set of SQL and XSL functions for use in RTF templates. The syntax for these extended functions is <?xdofx:expression?> for extended SQL functions or <?xdoxslt:expression?> for extended XSL functions. Note: You cannot mix xdofx statements with XSL expressions in the same context. For example, assume you had two elements, FIRST_NAME and LAST_NAME that you wanted to concatenate into a 30-character field and right pad the field with the character "x", you could NOT use the following: INCORRECT: <?xdofx:rpad(concat(FIRST_NAME,LAST_NAME),30, 'x')?> because concat is an XSL expression. Instead, you could use the following: CORRECT: <?xdofx:rpad(FIRST_NAME||LAST_NAME),30,'x')?> The supported functions are shown in the following table: SQL Statement or XSL Expression Usage 2+3 2-3 2*3 2/3 2**3 3||2 lpad('aaa',10,'.') <?xdofx:2+3?> <?xdofx:2-3?> <?xdofx:2*3?> <?xdofx:2/3?> <?xdofx:2**3?> <?xdofx:3||2?> <?xdofx:lpad('aaa',10,'.')?>

Description Addition Subtraction Multiplication Division Exponential Concatenation The lpad function pads the left side of a

string with a specific set of characters. The syntax for the lpad function is: lpad(string1,padded_length,[pad_string]) string1 is the string to pad characters to (the left-hand side). padded_length is the number of characters to return. pad_string is the string that will be padded to the left-hand side of string1 . rpad('aaa',10,'.') <?xdofx:rpad('aaa',10,'.')?> The rpad function pads the right side of a string with a specific set of characters. The syntax for the rpad function is: rpad(string1,padded_length,[pad_string] ). string1 is the string to pad characters to (the right-hand side). padded_length is the number of characters to return. pad_string is the string that will be padded to the right-hand side of string1 Removes spaces in a string. Enter the text to be trimmed, the function returns the trimmed text. Removes the leading white spaces in a string. Removes the trailing white spaces in a string. The truncate function returns number truncated to integer places right of the decimal point. If integer is omitted, then number is truncated to the whole integer value. integer can be negative to truncate values left of the decimal point. integer must be an integer. Example: <?xdoxslt:truncate(-2.3333)?> returns -2 Example: <?xdoxslt:truncate(2.7777, 2)?> returns 2.77 Example: <?xdoxslt:truncate(27.7777, -1)?> returns 20 The replicate function will replicate the specified string the specified number of

trim()

<?xdoxslt:trim( a )?>

ltrim() rtrim() truncate

<?xdoxslt:ltrim( a )?> <?xdoxslt:rtrim( a )?> <?xdoxslt:truncate ( number [, integer ] )?>

replicate

<?xdoxslt:replicate(string, integer)?>

times. Example: <?xdoxslt:replicate(oracle, 3)?> returns oracleoracleoracle decode('xxx','bbb','ccc','x <?xdofx:decode('xxx','bbb','ccc',' xx','ddd') xxx','ddd')?> The decode function has the functionality of an IF-THEN-ELSE statement. The syntax for the decode function is: decode(expression, search, result [,search, result]...[, default]) expression is the value to compare. search is the value that is compared against expression. result is the value returned, if expression is equal to search. default is returned if no matches are found. The instr function returns the location of a substring in a string. The syntax for the instr function is: instr(string1,string2,[start_position],[nth_ appearance]) string1 is the string to search. string2 is the substring to search for in string1. start_position is the position in string1 where the search will start. The first position in the string is 1. If the start_position is negative, the function counts back start_position number of characters from the end of string1 and then searches towards the beginning of string1. nth appearance is the nth appearance of string2. The substr function allows you to extract a substring from a string. The syntax for the substr function is: substr(string, start_position, length) string is the source string. start_position is the position for extraction. The first position in the string is always 1. length is the number of characters to extract. Enables you to extract the specified number of characters from a string, starting from the left. The syntax is

Instr('abcabcabc','a',2)

<?xdofx:Instr('abcabcabc','a',2)? >

substr('abcdefg',2,3)

<?xdofx:substr('abcdefg',2,3)?>

left

<?xdoxslt:left(abcdefg, 3)?>

left(string, Numchars) For example, <?xdoxslt:left(abcdefg, 3)?> returns abc right <?xdoxslt:right(abcdefg, 3)?> Enables you to extract the specified number of characters from a string, starting from the right. The syntax is right(string, Numchars) For example, <?xdoxslt:right(abcdefg, 3)?> returns efg The replace function replaces a sequence of characters in a string with another set of characters. The syntax for the replace function is: replace(string1,string_to_replace,[replac ement_string]) string1 is the string to replace a sequence of characters with another set of characters. string_to_replace is the string that will be searched for in string1. replacement_string is optional. All occurrences of string_to_replace will be replaced with replacement_string in string1. Function to_number converts char, a value of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype containing a number in the format specified by the optional format model fmt, to a value of NUMBER datatype.

replace(name,'John','Jo n')

<?xdofx:replace(name,'John','Jo n')?>

to_number('12345')

<?xdofx:to_number('12345')?>

format_number

<?xdoxslt:format_number(12345 Converts a number to a string and , n, $_XDOLOCALE)?> formats the number according to the locale specified in $_XDOLOCALE and to the number of decimal positions specified in n using Java's default symbols. For example: <?xdoxslt:format_number(-12345, 2, frFR)?> returns -12 345,00 <?xdoxslt:format_number(12345 Converts a number to a string and uses , n, s1, s2,$_XDOLOCALE)?> the specified separators: s1 for the thousand separator and s2 for the decimal separator. For example:

format_number

<?xdoxslt:format_number(12345, 2, 'g', 'd', $_XDOLOCALE)?> returns 12g345d00 pat_format_number <?xdoxslt:pat_format_number(1 2345, ##,##0.00, $_XDOLOCALE)?> Returns a number formatted with the specified pattern. For example: <?xdoxslt:pat_format_number(12345, ##,##0.00, $_XDOLOCALE)?> returns 12,345.00 Use the TO_CHAR function to translate a value of NUMBER datatype to VARCHAR2 datatype. TO_DATE converts char of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype to a value of DATE datatype. The fmt is a date format specifying the format of char. If you omit fmt, then char must be in the default date format. If fmt is 'J', for Julian, then char must be an integer. SYSDATE returns the current date and time. The datatype of the returned value is DATE. The function requires no arguments. Returns the current date in "yyyy-MMdd" format in the given locale and timezone. This function supports only the Gregorian calendar. Returns the current time in the given locale and timezone. This function supports only the Gregorian calendar.

to_char(12345)

<?xdofx:to_char('12345')?>

to_date

<?xdofx:to_date ( char [, fmt [, 'nlsparam']] )

sysdate()

<?xdofx:sysdate()?>

current_date()

<?xdoxslt:current_date($_XDOL OCALE, $_XDOTIMEZONE)?> Example: <?xdoxslt:current_date('ja-JP', 'Asia/Tokyo')?> <?xdoxslt:current_time($_XDOL OCALE, $_XDOTIMEZONE)?> Example: <?xdoxslt:current_time('ja-JP', 'Asia/Tokyo')?> <?xdoxslt:minimum(ELEMENT_ NAME)?> <?xdoxslt:date_diff(y', YYYYMM-DD, YYYY-MM-DD, $_XDOLOCALE, $_XDOTIMEZONE)?>

current_time()

minimum date_diff

Returns the minimum value of the element in the set. This function provides a method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only the Gregorian calendar. The syntax is as follows: <?xdoxslt:date_diff(format, YYYY-MMDD, YYYY-MM-DD, $_XDOLOCALE, $_XDOTIMEZONE)?> where

format is the time value for which the difference is to be calculated. Valid values are :
y y y y y y y y

y - for year m - for month w - for week d - for day h - for hour mi - for minute s - for seconds ms - for milliseconds

Example: <?xdoxslt:date_diff(y, 2000-04-08, 2001-05-01, $_XDOLOCALE, $_XDOTIMEZONE)?> returns 1 Example: <?xdoxslt:date_diff(m, 2001-04-08, 2000-02-01, $_XDOLOCALE, $_XDOTIMEZONE)?> returns -14 Example: <?xdoxslt:date_diff(d, 2006-04-08, 2006-04-01, $_XDOLOCALE, America/Los_Angeles)?> returns -7 sec_diff <?xdoxslt:sec_diff(2000-0408T20:00:00, 2000-0408T21:00:00, $_XDOLOCALE, $_XDOTIMEZONE?> This function provides a method to get the difference between two dates in seconds in the given locale. The dates need to be in "yyyy-MMdd'T'HH:mm:ss". This function supports only Gregorian calendar. Example: <?xdoxslt:sec_diff(2000-0408T20:00:00, 2000-04-08T21:00:00, $_XDOLOCALE, $_XDOTIMEZONE?> returns 3600 This function provides a method to get the day value of a date in "yyyy-MM-dd" format in the given locale. This function supports only the Gregorian calendar. Example: <?xdoxslt:get_day(2000-04-08,

get_day

<?xdoxslt:get_day(2000-04-08, $_XDOLOCALE)?>

$_XDOLOCALE)?> returns 8 get_month <?xdoxslt:get_month(2000-0408, $_XDOLOCALE)?> This function provides a method to get the month value of a date in "yyyy-MMdd" format in the given locale. This function supports only the Gregorian calendar. Example: <?xdoxslt:get_month(2000-04-08, $_XDOLOCALE)?> returns 4

get_year

<?xdoxslt:get_year(2000-04-08, This function provides a method to get $_XDOLOCALE)?> the year value of a date in "yyyy-MM-dd" format in the given locale. This function supports only the Gregorian calendar. Example: <?xdoxslt:get_year(2000-04-08, $_XDOLOCALE)?> returns 2000 <?xdoxslt:month_name(1, 0, $_XDOLOCALE)?> This function provides a method to get the name of the month in the given locale. This function supports only the Gregorian calendar. The syntax for this function is: <?xdoxslt:month_name(month, [abbreviate?], $_XDOLOCALE)?> where month is the numeric value of the month (Januany = 1) and [abbreviate?] is the value 0 for do not abbreviate or 1 for abbreviate. Example: <?xdoxslt:month_name(12, 1, fr-FR)?> returns dec. Example" <?xdoxslt:month_name(1, 0, $_XDOLOCALE)?> returns January

month_name

maximum abs

<?xdoxslt:maximum(ELEMENT_ Returns the maximum value of the NAME)?> element in the set. <?xdoxslt:abs(-123.45)?> Returns the absolute value of the number entered.

Example: <?xdoxslt:abs(-123.45)?> Returns: 123.45 chr <?xdofx:chr(n)?> CHR returns the character having the binary equivalent to n in either the database character set or the national character set. CEIL returns smallest integer greater than or equal to n. FLOOR returns largest integer equal to or less than n. ROUND returns number rounded to integer places right of the decimal point. If integer is omitted, then number is rounded to 0 places. integer can be negative to round off digits left of the decimal point. integer must be an integer. Example: <?xdofx:round (2.777)?> returns 3 Example: <?xdofx:round (2.777, 2)?> returns 2.78 ROUND returns number rounded to integer places right of the decimal point. If integer is omitted, then number is rounded to 0 places. integer can be negative to round off digits left of the decimal point. integer must be an integer. Example: <?xdoxslt:round (2.777)?> returns 3 Example: <?xdoxslt:round (2.777, 2)?> returns 2.78 LOWER returns char, with all letters lowercase. char can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The return value is the same datatype as char.

ceil floor round (SQL function)

<?xdofx:ceil(n)?> <?xdofx:floor(n)?> <?xdofx:round ( number [, integer ] )?>

round (XSLT function)

<?xdoxslt:round ( number [, integer ] )?>

lower

<?xdofx:lower (char)?>

upper

<?xdofx:upper(char)?>

UPPER returns char, with all letters uppercase. char can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The return value is the same datatype as char. The "length" function returns the length of char. LENGTH calculates length using characters as defined by the input character set.

length

<?xdofx:length(char)?>

greatest

<?xdofx:greatest ( expr [, expr]... GREATEST returns the greatest of the )?> list of exprs. All exprs after the first are implicitly converted to the datatype of the first expr before the comparison. <?xdofx:least ( expr [, expr]... )?> LEAST returns the least of the list of exprs. All exprs after the first are implicitly converted to the datatype of the first expr before the comparison. <?xdoxslt:next_element(current- Method to get the next element in the group(),.,'<element-name>')?> current group. Will return the element that occurs after the element named. For example: <?xdoxslt:next_element(currentgroup(),.,'employee')?> will return the element that occurs in the current group after "employee". <?xdoxslt:prev_element(current- Method to get the previous element in group(),..,'<element-name')?> the current group. Will return the element that occurs before the element named. For example: <?xdoxslt:prev_element(currentgroup(),.,'employee')?> will return the element that occurs in the current group before "employee". <?xdoxslt:set_array($_XDOCTX, Sets a value in a hash table. Syntax is <name of hash table>, n, <?xdoxslt:set_array($_XDOCTX, <value>)?> <name of hash table>, n, <value>)?> where $_XDOCTX is required to set the context, <name of hash table> is the name you supply for your table n is the index of the hash table <value> is the value to set in the hash table. For example: <?xdoxslt:set_array($_XDOCTX, Employee, 2, Jones)?>

least

next_element

prev_element

set_array

See get_array below. get_array <?xdoxslt:get_array($_XDOCTX, Returns the value at the specified index <name of hash table>, n)?> of the hash table. Syntax is <?xdoxslt:get_array($_XDOCTX, <name of hash table>, n)?> where $_XDOCTX is required to set the context, <name of hash table> is the name you supplied for your table in set_array n is the index value of the element you want returned. For example, used in conjunction with the set_array example above, <?xdoxslt:get_array($_XDOCTX, Employee, 2)?> returns Jones

The following table shows supported combination functions: SQL Statement (2+3/4-6*7)/8 lpad(substr('1234567890',5,3),10,'^') Usage <?xdofx:(2+3/4-6*7)/8?> <?xdofx:lpad(substr('1234567890',5,3),10,'^')?>

decode('a','b','c','d','e','1')||instr('321',1,1) <?xdofx:decode('a','b','c','d','e','1')||instr('321',1,1)?>

XSL Equivalents
The following table lists the BI Publisher simplified syntax with the XSL equivalents. Supported XSL Elements <xsl:value-of select= "name"> <xsl:apply-templates select="name"> <xsl:copy-of select="name"> <xsl:call-template name="name"> <xsl:sort select="name"> <xsl:for-each

Description Placeholder syntax Applies a template rule to the current element's child nodes. Creates a copy of the current node. Calls a named template to be inserted into/applied to the current template.

BI Publisher Syntax <?name?> <?apply:name?> <?copy-of:name?> <?call:name?>

Sorts a group of data based on an element in the <?sort:name?> dataset. Loops through the rows of data of a group, used <?for-each:name?>

select="name"> <xsl:choose> <xsl:when test="exp"> <xsl:otherwise> <xsl:if test="exp"> <xsl:template name="name"> <xsl:variable name="name"> <xsl:import href="url"> <xsl:include href="url"> <xsl:stylesheet xmlns:x="url">

to generate tabular output. Used in conjunction with when and otherwise to express multiple conditional tests. Used in conjunction with choose and otherwise to express multiple conditional tests Used in conjunction with choose and when to express multiple conditional tests Used for conditional formatting. Template declaration Local or global variable declaration Import the contents of one stylesheet into another Include one stylesheet in another Define the root element of a stylesheet <?choose?> <?when:expression?> <?otherwise?> <?if:expression?> <?template:name?> <?variable:name?> <?import:url?> <?include:url?> <?namespace:x=url?>

Using FO Elements
You can use most FO elements in an RTF template inside the Microsoft Word form fields. The following FO elements have been extended for use with BI Publisher RTF templates. The BI Publisher syntax can be used with either RTF template method. The full list of FO elements supported by BI Publisher can be found in the Appendix: Supported XSLFO Elements. FO Element <fo:page-number-citation ref-id="id"> <fo:page-number> BI Publisher Syntax <?fo:page-number-citation:id?> <?fo:page-number?> Contents | Previous | Top of Page | Next
Copyright 2003, 2008, Oracle and/or its affiliates. All rights reserved.

<fo:ANY NAME WITHOUT ATTRIBUTE> <?fo:ANY NAME WITHOUT ATTRIBUTE?>

Das könnte Ihnen auch gefallen