Initialize
variable to Y where Found is the name of the variable
<?xdoxslt:set_variable($_XDOCTX,
‘Found’, ‘Y’)?>
Print
the Variable value
<?xdoxslt:get_variable($_XDOCTX,’Found’)?>
Compare
two variables
<?if:xdoxslt:get_variable($_XDOCTX,’counter’)
= xdoxslt:get_variable($_XDOCTX,’tot_lines’)?>
Conditions
Matched, You may proceed
<?end
if?>
Conditional text using ‘if’ statement
Use “if” statements to customize text in your
report. As an example, for the sentence ‘The document is reviewed’, we can
add the word ‘not’ depending on the value of a field named STATUS.
Sample: The document is <?if@inlines:STATUS='Overdue'?>not<?end
if?> reviewed.
Result: If the STATUS is ‘Overdue’ the text will read ‘The document is not
reviewed’. Otherwise, it will read ‘The document is reviewed
We
can use the @inlines command to force the template to lay the text out
horizontally across the page rather than down the page.
<ROOT>
<ROW><name>Mike</name>
</ROW>
<ROW><name>Max</name></ROW>
<ROW><name>Nick</name></ROW>
</ROOT>
<?for-each@inlines:/ROOT/ROW?><?name?>
<?end for-each?>
Output
: Mike Max Nick
Adding
@inlines makes the elements to be displayed without line break.
?for-each:/ROOT/ROW?><?name?>
<?end for-each?>
Output
: Mike
Max
Nick
BI Publisher: Conditional Format
This example will set the row background to red and font
color to white for records where Status is equal to ‘Quote_Received’.
<?if@row:STATUS=’Quote_Received’?>
<?attribute@incontext:background-color;’Red’?>
<?attribute@incontext:color;’White’?>
<?end if?>
ifelse
<?xdoxslt:ifelse(condition,true,false)?>
<?xdoxslt:ifelse(A.DESCRSHORT = 'CNG', 'two', 'one')?>
If Then Else
The following statement tests the AMOUNT element value. If the value is greater than 1000, show the word "Higher"; if it is less
than 1000, show the word "Lower"; if it is equal to 1000, show "Equal":
<?xdofx:if AMOUNT > 1000 then 'Higher'
else
if AMOUNT < 1000 then 'Lower'
else
'Equal'
end if?>
<?xdofx:if CB_INV_TRNSTYP='D' then
<?xdoxslt:set_variable($_XDOCTX,'DB',CB_INV_AMOUNT)?>
else
<?xdoxslt:set_variable($_XDOCTX,'DB',0.00)?>endif?>
OR
<?if:CB_INV_TRNSTYP=’D’?><?xdoxslt:set_variable($_XDOCTX,’DB’,CB_INV_AMOUNT)?><?end
if?><?if:CB_INV_TRNSTYP!=’D’?><?xdoxslt:set_variable($_XDOCTX,’DB’,0.00)?><?end
if?>
No comments:
Post a Comment