EBS_報表_開發:XML與RTF學習



1.for each后面跟的是組的名稱,然后下面羅列要顯示的名稱.

<?TITLE?> <?for-each:LINE_1?>
--可作為起始,用於表格 <?SC_ATTRIBUTE?> <?COMP_NAME?> <?Total_Score?> <?end for-each?>
--作為結束,用於表格

2.關於IF:

單元格加亮(字體加亮)--background-color

<?if:l_line_num_1>5?>
<xsl:attribute xdofo:ctx="block"name="background-color">red</xsl:attribute>
<?end if?>

根據條件要那個地方改變顏色 就把if放到哪個地方 比如單元格

單元格加亮(字體加粗)--font-weight

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

格式化行--incontext

n 當條件滿足的時候加亮行
n 設置行的背景顏色
n 滿足條件的時候才顯示行
根據條件來格式化表格的行
<?if:condition?> <?end if?>
<?if@row:condition?>
<xsl:attributename="background-color" xdofo:ctx="incontext">lightgray
</xsl:attribute>
<?end if?>

 格式化列

根據條件顯示或隱藏列
<?if@column:condition?>
……
<?end if?>
例子:
<?if@column:condition?>
<?quantity?>
<?end if?>
<?if@column:/items/@type="PRIVATE"?>
<?quantity?>
<?end if?>
 

if-then-else

<?xdofx:if element_condition then result1 elseresult2 end if?>
例子:
<?xdofx:if AMOUNT > 1000 then 'Higher‘
Else
if AMOUNT < 1000 then 'Lower‘
Else
'Equal‘
end if?>

樣板文本中加if

<?if@inlines:condition?>
……
<?end if?>
例子
1.The program was<?if:SUCCESS=’N’?>not<?end if?> successful
結果The program was
not 
successful
2.The program was<?if@inlines:SUCCESS=’N’?>not<?end if?> successful
結果: The program wassuccessful.

3.Choose 語句

<?choose:?>
<?when:expression?>
……
<?when:expression?>
……
<?otherwise?>
                             

4.分頁

<?if:l_line_num_1>5?>
<xsl:attribute name="break-before">page</xsl:attribute>
<?end if?>  

<?end for-each?>前加<xsl:attributename="break-after">page</xsl:attribute>,此法下RTF最后無空白頁,但PDF有空白頁。
<?end for-each?>前加<xsl:attributename="break-before">page</xsl:attribute>此法下RTF、PDF最后都有空白頁。
固定行分頁,需要借助IF+上面的break-after或者break-before,
在行<?end for-each?>前,如下語句控制每頁5行: <?if:position() mod 5 =0?> <xsl:attribute name="break-before">page</xsl:attribute> <?end if?>

 ps

 二.新組分頁
分頁是自然的,但如果想在某處強制分頁如新組新頁,那么可以使用Word的分頁符(CTRL+ENTER快捷鍵),但會導致最后出現空白頁;這樣只能使用如下幾種方式:
1、 分組聲明中加@section,如<?for-each@section:G_PO_HEADER?>。
2、 <?end for-each?>前加<?split-by-page-break:?>。這個翻譯后,實際上是:
<xsl:iftest="position()<last()">
< xsl:attribute name="break-before">page</xsl:attribute>
< /xsl:if>
3、 <?end for-each?>前加<xsl:attributename="break-after">page</xsl:attribute>,此法下RTF最后無空白頁,但PDF有空白頁。
4、 <?end for-each?>前加<xsl:attributename="break-before">page</xsl:attribute>此法下RTF、PDF最后都有空白頁。
 

 

十八. 計算合計值
1.  首先盡量用report生成總計,就不用寫總計,直接加個總計域就行
2.  如果report生成的數據沒有總計,那么可以使用固有函數實現
We have two choices when it comes tothe totals:
1.    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.
2.    Alternatively     we can use a native XSL SUM function to calculate the summary
<?sum(…..)?>例如<?sum(ENT_AMT)?> and<?sum(ACCTD_AMT)?>
This worksvery well but you should note that you are now performing calculations in themiddle tier which is not as performant as in the database. You should performas much of your business processing in the database as possible.
You also notice that we can give somecontext to the total by adding another form field to contain the supplier name,<?VENDOR_NAME?>, as we are in the invoices level we can simply referencethe parent vendor name value for the supplier.
可以對多個字段進行合計,由於頁合計在XML數據中是不存在的,所以需要定義一個變量,定義變量的同時將計算的字段關聯起來了
<?add-page-total:TotalFieldName;’element’?>
TotalFieldName:合計值對應的字段
’element’:被合計的XML元素名稱
<?add-page-total:dt;’debit’?>
<?add-page-total:ct;’credit’?>
<?add-page-total:net;’debit - credit’?>
 
十九. 顯示頁合計
<?show-page-total:TotalFieldName;’number-format’?>
TotalFieldName:合計值對應的字段
number-format:合計值顯示的格式
例子:
<?show-page-total:dt;$#,##0.00; ($#,##0.00)’?>
<?show-page-total:ct;$#,##0.00; ($#,##0.00)’?>
<?show-page-total:net;$#,##0.00; ($#,##0.00)’?>
<?show-page-total:pt;'#,##0.00'?>

 

 結轉合計

二十.結轉合計
某些報表要求將頁的合計顯示在頁尾和下一頁的頁頭,這種合計叫做結轉合計。下面是結
轉合計的例子:
在第一頁的尾部顯示了頁的合計;在第二頁的頂部結轉顯示了第一頁的合計,依次類推
需要在頁碼的頂部實現結轉合計,只要在每頁的(除了第一頁)頂部使用如下的語句:
<xdofo:inline-total displaycondition="exceptfirst" name="InvAmt">
Brought Forward:
<xdofo:show-brought-forwardname="InvAmt"
format="99G999G999D00"/>
</xdofo:inline-total>
舉例:
<?template:header?>
                 Invoice Listing Report
 
1000    1000
<?end template ?>
<?template:footer?>
Page Total:         1000    1000
     1000         1000
<?endtemplate?>
 
Init PTs
 
Invoice
Type    Invoice
Number    Invoice
Date    Invoice
Currency    Entered   Amount    Accounted
Amount
FEINV_TYPE    132342    10-May-07    USD    1,000.00    1,000.00 EG
End PTs
二十一. 連續合計(同參數高級應用)
報表實現如下的累積合計值
1. 定義變量
<?xdoxslt:set_variable($_XDOCTX, ’VariableName’,0)?>
<?xdoxslt:set_variable($_XDOCTX, ’RTotalVar’,0)?>
2. 添加每行值
<?xdoxslt:set_variable($_XDOCTX, ’Var’,xdoxslt:get_variable($_XDOCTX,’Var’) +tag name)?>
<?xdoxslt:set_variable($_XDOCTX, ’RTotalVar’,xdoxslt:get_variable($_XDOCTX,’RTotalVar’) + INVAMT)?>
3. 顯示累積合計值
xdoxslt:get_variable($_XDOCTX, ’VariableName’)?>
xdoxslt:get_variable($_XDOCTX, ’RTotalVar’)?>
二十二. 排序
可以使用組中的字段對組進行排序,在組標記內插入如下的命令標記:
<?sort:element name?>
<?sort: VENDOR_NAME?>
也可以對組中的多個字段進行排序:
<?sort:element name?><?sort:elementname?>……
<?sort:VENDOR_NAME?> <?sort:INVOICE_NUM?>
重新分組

二十三. 對XML數據從新分組
Youmay need to further group your data in addition to the existing grouping, inthis case we have:
SUPPLIERS
INVOICES
Ratherthan update the XML extraction, we can actually introduce a new group to thehierarchy in the template layer so we have:
SUPPLIERS
CURRENCY
INVOICES
Wecan use a new function, ‘for-each-group’ to effectively regroup the data in thetemplate to show the invoices by currency code, we can then show summary totalsat the current level too. In the template below you notice that it has beenrestructured from the previous version. There is now a new table:
TheReGrp:Curr field has the following:
for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE
Thisis specifying that we want to create a new group ‘INVOICE_CURRENCY_CODE’ based onthe original ‘G_INVOICE_NUM’ group.We then have the currency label/value pair, the invoice table then follows,inside the Grp:Invoice field we now have ‘for-each:current-group()’  torefer to the new INVOICE_CURRENCY_CODE group we have just created. Note: wecannot refer to the group as INVOICE_CURRENCY_CODE as this group is onlycreated at runtime.
Sonow we have a new grouping we can create summary totals at this level togenerate totals per currency, inside the new fields we havesum (current-group()/ENT_AMT) for the enteredamount, again we use the current-group() tag to refer to the new ‘INVOICE_CURRENCY_CODE’ group.
I 
Grp:SupplierDecimal Format
Supplier    Supplier 1
Address    1 Long   Avenue
 
ReGrp:Curr Currency: USD
  
Invoice Number    Type    Invoice     Date    GL     Date    Entered     Amount    Accounted     Amount
Grp:Invoice1134922    Standard    01-Jan-2007    01-Jan-2007    $100.00    $100.00End Invoice    
          Total     for USD         $100.00    $100.00
End Curr
結果:多加了個分組Currency
XML Publisher提供了對XML數據從新分組的功能,這樣報表可以根據需要隨意進行層次結構的從新組織,無需按照原有的結構顯示
<?for-each-group:BASE-GROUP;GROUPING-ELEMENT?>       <?end for-each-group?>
為了在已定義的分組中再進行分組,使用如下的命令標記實現嵌套分組:
<?for-each:current-group();GROUPING-ELEMENT?>
在運行時,XML Publisher根據新的分組規則,循環顯示模板中定義的字段值,
使用如下的命令標記顯示顯示的信息:
<?for-each:currentgroup()?> <?endfor-each?>
使用上述的語法方式,可以通過表達式來進行分組:
<?for-each:BASE-GROUP; GROUPING-EXPRESSION?>
<?for-each-group:temp;floor(degree div 10?>

變量與參數

二十四. 使用變量
變量使用“set get”的方式來分配、更新和取得變量的值
<?xdoxslt:set_variable($_XDOCTX,’variablename’, value)?>
<?xdoxslt:get_variable($_XDOCTX, ’variablename’)?>
<?xdoxslt:set_variable($_XDOCTX, ’x’,xdoxslt:get_variable($_XDOCTX, ’x’ + 1)?>
舉例
This template contains a variable called 'x'
Let’s initialize X to 1
<?xdoxslt:set_variable($_XDOCTX,'x', 1)?> <?xdoxslt:get_variable($_XDOCTX, 'x')?>
X= ?
Lets add 10 to X
X = X+10
<?xdoxslt:set_variable($_XDOCTX,'x',xdoxslt:get_variable($_XDOCTX,'x')+10)?><?xdoxslt:get_variable($_XDOCTX, 'x')?>  
高級應用Running Total
RTotVar<?xdoxslt:set_variable($_XDOCTX, 'RTotVar', 0)?>
 
Invoice
Number    Invoice Amount    Running 
Total
Grp: Invoice13222-2    $100.00    $100.00
<?xdoxslt:set_variable($_XDOCTX,'RTotVar', xdoxslt:get_variable($_XDOCTX, 'RTotVar') +ACCTD_AMT)?><?xdoxslt:get_variable($_XDOCTX, 'RTotVar')?>
結果(思考這里為什么可以不用for-each)
 
 
二十五.參數
1.      定義參數
可以傳遞運行時參數給模板,但是Oracle Application並發管理器不支持傳參數給模板,只能在程序中通過API傳遞參數
<xsl:paramname="PARAMETERNAME" select="DEFAULT"xdofo:ctx="begin"/>
PARAMETERNAME:參數的名稱
DEFAULT:參數的默認值,select可以省略
xdofo:ctx=“begin“是必須的,它代表了在模板開始的時候就聲明變量
這個語法必須在窗體域幫助文字中使用,窗體域可以放到模板中的任意位置
2.      應用參數
模板中使用參數的方法是在參數名稱前添加$字符,
如:聲明了參數“InvThresh”,則通過”$InvThresh”來引用它
也可以在API中通過程序來引用參數值
Properties prop = newProperties();
prop.put("xslt.InvThresh","1000");
舉例
Name: xslt. InvThresh
Value: 1000
Template Builder
In the config file, under<<TEMPLATE_BUILDER_HOME>>/config, under the Properties section,enter the following:
<propertyname="xslt.InvThresh">1000</property>
 
InvThresh Declaration
 
Invoice
Number    Invoice  Amount
Grp: Invoice13222-2    $100.00EFE
 
二十六.數字日期
1.      數字格式化
XML Publisher支持兩種數字格式化方式
Word本身的數字格式掩碼
Oracle的format-number功能
<?format-number:fieldname;’999G999D99’?>
2.      日期格式化
XML Publisher支持三種日期格式化方式
Word本身的日期格式掩碼
Oracle的format-date功能
<?format-date:date_string; ’FORMAT_MASK’;?>
<?format-date:hiredate;’YYYY-MM-DD’?>
 
二十七. 抽象日期格式化
Oracle的抽象日期格式掩碼語法
<?format-date:fieldname;’MASK’?>
<?format-date:hiredate;’SHORT’?>
<?format-date:hiredate;’LONG_TIME_TZ’?>

 

 

5.頁眉頁腳

1、 標准的頁眉頁腳,即單個頁眉頁腳,使用Word的功能即可。

2、 擴展的頁眉頁腳,可使用<?start:body?><?endbody?>把主體部分“框”起來,凡是在這兩個標記之外的東西,都將被當作頁眉頁腳。

6.頁碼和頁數

1、 可以用Word的“自動圖文集”,在任意地方插入頁碼,這個是“自然頁碼”。

2、 如果在某種情況下想讓頁碼從特定值開始,比如新的組頁碼重新編號,則需要借助命令,如在for-each后寫:<?initial-page-number:1?>。這里的“1”,實際上也可以用數據文件中的XML元素來替換。

 

7.末頁、奇偶頁不同

1、  Word可在頁眉頁腳部分實現首頁不同或奇偶頁不同,沒法實現末頁不同,即使借助代碼控制,實際實現的也是末頁布局不同,而非“頁眉頁腳”不同。

<?start@last-page:body?><?end body?>

報表本身僅有一頁時,則用<?start@last-page-first:body?><?endbody?>

例子“Advanced/LastPage”,注意布局需要獨立成頁,即之前需要加分頁符。

2、 以偶數頁結束,主要目的是顯示偶數頁頁眉頁腳

<?section:force-page-count;’end-on-even-layout’?>

如果僅顯示空白頁,則用<?section:force-page-count;’end-on-even’?>

3、 以奇數頁結束,主要目的是顯示奇數頁頁眉頁腳

<?section:force-page-count;’end-on-odd-layout’?>

如果僅顯示空白頁,則用<?section:force-page-count;’end-on-odd’?>

 

.嵌套模板

由於在頁眉和頁腳中不允許使用窗體域,而當報表頁眉頁腳中希望插入XML數據的時候,可以考慮使用嵌套模板。

嵌套模板是在模板中定義一個子模板,然后在需要的地方調用它,如在頁眉頁腳中調用它。

定義子模板

子模板標記之間可以使用任何的標記和內容,和模板的主體部分沒有任何區別

<?template:internaltemplate name?>

……

<?end template?>

. 調用子模板

<?call:internaltemplate name?>

 

.圖片插入

接插入圖片

可以直接在模板中插入jpg、gif或png格式圖片

URL鏈接圖片

•在模板中隨意插入一張圖片

•在設置圖片對話框中的網站標簽頁中,在可選文字中輸入如下的URL格式鏈接

url:{’http://image location’}

url:{’http://www.oracle.com/images/ora_log.gif’}

OA Media 庫圖片

•在模板中隨意插入一張圖片

•在設置圖片對話框中的網站標簽頁中,在可選文字中輸入如下的URL格式鏈接

url:{’${OA_MEDIA}/image name’}

url:{’${OA_MEDIA}/ORACLE_LOGO.gif’}

. 超鏈接

•使用word中的插入超鏈接功能來插入靜態鏈接

•如果超鏈接包括了模板中的數據元素,可以在運行時動態的創建超鏈接,在鏈接地址中按如下格式輸入:

{URL_LINK}

URL_LINK可以是一個完整的URL地址,也可以使URL地址中的一部分。

它是動態傳入的數據元素,如下傳入URL的參數:

http://www.oracle.com?product={PRODUCT_NAME}

PRODUCT_NAME是運行時傳入值的數據元素名稱

如下是一個完整的URL地止

{SUPPLIER_URL}

SUPPLIER_URL 是運行時傳入值的數據元素名稱

 

.表格

XML Publisher 支持通過XML數據來動態創建表格內容和題頭

動態創建題頭的步驟:

n à使用<?tagname?>標記的方式來插入題頭,並將其格式化為題頭。這里不能使用表單

域的功能。

例如報表要求將公司名稱顯示為題頭,XML數據標記名為<COMPANY_NAME>,在

報表模板中需要顯示標題的地方輸入<?COMPANY_NAME?>即可

n à通過word的內置功能創建表格的其他內容

在運行的時候,系統自動替換表格中和題頭標記的值

 

十一. n 復選框

可以在模板中定義復選框,並根據傳入的值來決定是否被選中

定義復選框的步驟:

使用word中的復選框型窗體域功能添加復選框

n 打開復選框型窗體域選項窗口

n 設置默認值:未選中或選中

n 在窗體域幫助文字中輸入復選框選中的條件表達式,它必須是一個布爾表達式,只能返回true或false

如:XML數據中包括了<population>的元素,如果<population>的值大於10000

則復選框被選中,則在窗體域幫助文字中輸入如下的條件表達式:

<?population>10000?>

 

十八. 計算合計值

1.                  首先盡量用report生成總計,就不用寫總計,直接加個總計域就行

2.                  如果report生成的數據沒有總計,那么可以使用固有函數實現

We have two choices when it comes tothe totals:

  1. 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.
  2. Alternatively     we can use a native XSL SUM function to calculate the summary

<?sum(…..)?>例如<?sum(ENT_AMT)?> and<?sum(ACCTD_AMT)?>

This worksvery well but you should note that you are now performing calculations in themiddle tier which is not as performant as in the database. You should performas much of your business processing in the database as possible.

You also notice that we can give somecontext to the total by adding another form field to contain the supplier name,<?VENDOR_NAME?>, as we are in the invoices level we can simply referencethe parent vendor name value for the supplier.

可以對多個字段進行合計,由於頁合計在XML數據中是不存在的,所以需要定義一個變量,定義變量的同時將計算的字段關聯起來了

<?add-page-total:TotalFieldName;’element’?>

TotalFieldName:合計值對應的字段

’element’:被合計的XML元素名稱

<?add-page-total:dt;’debit’?>

<?add-page-total:ct;’credit’?>

<?add-page-total:net;’debit - credit’?>

 

十九. 顯示頁合計

<?show-page-total:TotalFieldName;’number-format’?>

TotalFieldName:合計值對應的字段

number-format:合計值顯示的格式

例子:

<?show-page-total:dt;$#,##0.00; ($#,##0.00)’?>

<?show-page-total:ct;$#,##0.00; ($#,##0.00)’?>

<?show-page-total:net;$#,##0.00; ($#,##0.00)’?>

<?show-page-total:pt;'#,##0.00'?>

二十.結轉合計

某些報表要求將頁的合計顯示在頁尾和下一頁的頁頭,這種合計叫做結轉合計。下面是結

轉合計的例子:

在第一頁的尾部顯示了頁的合計;在第二頁的頂部結轉顯示了第一頁的合計,依次類推

需要在頁碼的頂部實現結轉合計,只要在每頁的(除了第一頁)頂部使用如下的語句:

<xdofo:inline-total displaycondition="exceptfirst" name="InvAmt">

Brought Forward:

<xdofo:show-brought-forwardname="InvAmt"

format="99G999G999D00"/>

</xdofo:inline-total>

舉例:

<?template:header?>

                 Invoice Listing Report

 

1000

1000

<?end template ?>

<?template:footer?>

Page   Total:

 

1000

1000

 

1000

 

1000

<?endtemplate?>

 

Init PTs

 

Invoice

Type

Invoice

Number

Invoice

Date

Invoice

Currency

Entered     Amount

Accounted

Amount

FEINV_TYPE

132342

10-May-07

USD

1,000.00

1,000.00   EG

End PTs

 

二十一. 連續合計(同參數高級應用)

報表實現如下的累積合計值

1. 定義變量

<?xdoxslt:set_variable($_XDOCTX, ’VariableName’, 0)?>

<?xdoxslt:set_variable($_XDOCTX, ’RTotalVar’,0)?>

2. 添加每行值

<?xdoxslt:set_variable($_XDOCTX, ’Var’,xdoxslt:get_variable($_XDOCTX,’Var’) +tag name)?>

<?xdoxslt:set_variable($_XDOCTX, ’RTotalVar’,xdoxslt:get_variable($_XDOCTX,’RTotalVar’) + INVAMT)?>

3. 顯示累積合計值

xdoxslt:get_variable($_XDOCTX, ’VariableName’)?>

xdoxslt:get_variable($_XDOCTX, ’RTotalVar’)?>

 

二十二. 排序

可以使用組中的字段對組進行排序,在組標記內插入如下的命令標記:

<?sort:element name?>

<?sort: VENDOR_NAME?>

也可以對組中的多個字段進行排序:

<?sort:element name?><?sort:elementname?>……

<?sort:VENDOR_NAME?> <?sort:INVOICE_NUM?>

 

二十三. XML數據從新分組

Youmay need to further group your data in addition to the existing grouping, inthis case we have:

SUPPLIERS

INVOICES

Ratherthan update the XML extraction, we can actually introduce a new group to thehierarchy in the template layer so we have:

SUPPLIERS

CURRENCY

INVOICES

Wecan use a new function, ‘for-each-group’ to effectively regroup the data in thetemplate to show the invoices by currency code, we can then show summary totalsat the current level too. In the template below you notice that it has beenrestructured from the previous version. There is now a new table:

TheReGrp:Curr field has the following:

for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE

Thisis specifying that we want to create a new group ‘INVOICE_CURRENCY_CODE’ based onthe original ‘G_INVOICE_NUM’ group.We then have the currency label/value pair, the invoice table then follows,inside the Grp:Invoice field we now have ‘for-each:current-group()’  torefer to the new INVOICE_CURRENCY_CODE group we have just created. Note: wecannot refer to the group as INVOICE_CURRENCY_CODE as this group is onlycreated at runtime.

Sonow we have a new grouping we can create summary totals at this level togenerate totals per currency, inside the new fields we havesum (current-group()/ENT_AMT) for the enteredamount, again we use the current-group() tag to refer to the new ‘INVOICE_CURRENCY_CODE’ group.

I

Grp:SupplierDecimal Format

Supplier

Supplier   1

Address

1   Long   Avenue

 

ReGrp:Curr Currency: USD

 

Invoice   Number

Type

Invoice       Date

GL       Date

Entered       Amount

Accounted       Amount

Grp:Invoice1134922

Standard

01-Jan-2007

01-Jan-2007

$100.00

$100.00End   Invoice    

 

 

Total       for USD

 

$100.00

$100.00

End Curr

結果:多加了個分組Currency

XML Publisher提供了對XML數據從新分組的功能,這樣報表可以根據需要隨意進行層次結構的從新組織,無需按照原有的結構顯示

<?for-each-group:BASE-GROUP;GROUPING-ELEMENT?>       <?end for-each-group?>

為了在已定義的分組中再進行分組,使用如下的命令標記實現嵌套分組:

<?for-each:current-group();GROUPING-ELEMENT?>

在運行時,XML Publisher根據新的分組規則,循環顯示模板中定義的字段值,

使用如下的命令標記顯示顯示的信息:

<?for-each:currentgroup()?> <?endfor-each?>

使用上述的語法方式,可以通過表達式來進行分組:

<?for-each:BASE-GROUP; GROUPING-EXPRESSION?>

<?for-each-group:temp;floor(degree div 10?>

 

二十四. 使用變量

變量使用“set get”的方式來分配、更新和取得變量的值

<?xdoxslt:set_variable($_XDOCTX,’variablename’, value)?>

<?xdoxslt:get_variable($_XDOCTX, ’variablename’)?>

<?xdoxslt:set_variable($_XDOCTX, ’x’,xdoxslt:get_variable($_XDOCTX, ’x’ + 1)?>

舉例

This template contains a variable called 'x'

Let’s initialize X to 1

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

X= ?

Lets add 10 to X

X = X+10

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

高級應用Running Total

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

 

Invoice

Number

Invoice   Amount

Running  

Total

Grp: Invoice13222-2

$100.00

$100.00

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

結果(思考這里為什么可以不用for-each)

 

 

二十五.參數

1.      定義參數

可以傳遞運行時參數給模板,但是Oracle Application並發管理器不支持傳參數給模板,只能在程序中通過API傳遞參數

<xsl:paramname="PARAMETERNAME" select="DEFAULT"xdofo:ctx="begin"/>

PARAMETERNAME:參數的名稱

DEFAULT:參數的默認值,select可以省略

xdofo:ctx=“begin“是必須的,它代表了在模板開始的時候就聲明變量

這個語法必須在窗體域幫助文字中使用,窗體域可以放到模板中的任意位置

2.      應用參數

模板中使用參數的方法是在參數名稱前添加$字符,

如:聲明了參數“InvThresh”,則通過”$InvThresh”來引用它

也可以在API中通過程序來引用參數值

Properties prop = newProperties();

prop.put("xslt.InvThresh","1000");

舉例

Name: xslt. InvThresh

Value: 1000

Template Builder

In the config file, under<<TEMPLATE_BUILDER_HOME>>/config, under the Properties section,enter the following:

<propertyname="xslt.InvThresh">1000</property>

 

InvThresh Declaration

 

Invoice

Number

Invoice    Amount

Grp: Invoice13222-2

$100.00EFE

 

 

二十六.數字日期

1.      數字格式化

XML Publisher支持兩種數字格式化方式

Word本身的數字格式掩碼

Oracle的format-number功能

<?format-number:fieldname;’999G999D99’?>

2.      日期格式化

XML Publisher支持三種日期格式化方式

Word本身的日期格式掩碼

Oracle的format-date功能

<?format-date:date_string; ’FORMAT_MASK’;?>

<?format-date:hiredate;’YYYY-MM-DD’?>

 

二十七. 抽象日期格式化

Oracle的抽象日期格式掩碼語法

<?format-date:fieldname;’MASK’?>

<?format-date:hiredate;’SHORT’?>

<?format-date:hiredate;’LONG_TIME_TZ’?>

 

二十八. 成批打印報表

很多需求需要成批打印報表到一個PDF文檔,如發票或者采購訂單。由於單據是針對不同的客戶或者供應商,每個文檔都需要進行必要的頁碼重置和文檔頁碼合計等。如果頁頭和頁眉的數據從XML數據得到(如客戶名稱)也需要重置

XMLP通過使用上下文命令來支持這個需求,它允許指定段對應的元素,當斷發生變化的時候,相關的文檔內容也會被重置,使用如下的標記命令:

<?for-each@section:group name?>

Group name 是需要開始一個新的段對應元素的名稱,使用如下的數據說明如何在一個PDF文檔輸出中重置頁眉和頁腳。

以上的數據中,每個G_INVLOICE包括了一個發票信息,為了讓XMLP實現一個發票作為一段的功能,只要在for-each標記中添加如下的命令

<?for-each@section:G_INVLOICE?>

Group name 是需要開始一個新的段對應元素的名稱

上面是針對上一頁數據設計的一個模版,打印報表的時候,只要遇到一個G_INVOICE就

會產生一個新的段。頁碼就會被重置,從數據過來的頁眉和頁腳信息也被更新。注意

<?TRX_NUMBER?>標記,它是屬於G_INVOICE組下的,只要一個新的段產生,它將會

顯示新的值

 

二十九. 交叉表

交叉表的報表在設計時是無法知道列的數目,也不知道列的題頭是,這些都是需要根據數據來決定的。

<?for-each@section:group name?>

 

三十. 動態數據列

使用動態數據列功能可以實現根據某種條件來動態的顯示報表的列數

<?for-each@section:group name?>

 

三十一.重復標題行實現(重復表頭)

Repeatable RowHeaders

If your invoices break across a pageand you want to repeat the column header row, this can be achieved usingMSWord’s functionality.

  1. Highlight     the header row高亮直接用word設置
  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 apage the header row will be repeated.

 

Splitting Rows acrosspages

You can prevent rows splitting acrossa page break by using MSWord’s 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 splitacross two pages are now moved to the second page to preserve the row data.

 I

 

在word中設置

 

舉例

IFUse thefor-each@section to repeat the header information across pages of the outputdocument. In this case, the Customer Name will be repeated if the lineinformation runs across more than one page, the page numbering will also bereset.EI

for-each@section G_CUSTOMER

CUSTOMER_NAME

ADDRESS_LINE1

ADDRESS_LINE2

CITY, STATE ZIP

 

DearSir or Madam:

 

for-each G_CURRENCY

 

Your TRX_CURRENCY_CODE defers from the following invoices:

 

 

Transaction     Number

Transaction     Date

Transaction     Amount

Transaction     Amount Remaining

for-each G_INVOICESTRX_NUMBER

01-Jan-2007

$   100.00

$   100.00 end for-each

 

 

 

end for-each

end for-each

 

三十二. 頁眉頁腳logo,時間等

  1. There is one     caveat to this, you cannot use form fields in the header so you’ll need to     use the full placeholder text if you want to use data in the header.
  2. It is good     practice to use tables in the header and footer area to organize data and     objects.

Youcan see in the header and footer of this report that we have several reportobjects embedded:

a)    Logos: The Oracle logo is a straightforwardjpg image that has been embedded into the document. XML Publisher also supportsbmp, gif and png. We do not currently support wmf formats. Tip: Try and get alarger image than you need and shrink it in the template, this will improve thequality of the image at runtime.

b)   Boilerplate – you can insert any text youwish in the header/footer and it will be repeated on each page (i.e. the reporttitle above, and the company address in the footer).

c)    Data – as mentioned above you cannot use formfields in the header/footer area but this does not stop you adding data tothese areas. You just need to use the full placeholder text, this can beformatted just like the form fields and the incoming data will take on the sameproperties.

d)   Page numbering – you can insert pagenumbering just as you would in a regular Word document, at runtime XMLPublisher will paginate the output and insert the correct page numbers. Thisuses the word merge fields for page number and total page number so we canbuild up text such as ‘Page X of Y’ in the template and final output.

e)    Run Date – similar to the page numbering wecan also use the date merge field to insert the run date for the report. Itshould be noted that this is the publishing date and not necessarily the datethe data was generated.

注意時間和頁數是會自己變化的

創建時

運行時

三十三.數字格式numberformatting

  1. XSL natively     supports number formatting using its format-number function, it returns a     formatted string and takes the form:

 

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

 

Parameter              Description

Number                   Required.  Specifies the number to be formatted

Format                    Required.  Specifies the format pattern. Here are some ofthe characters used in the formatting pattern:

Ø # (Denotes a digit. Example:####)

Ø 0 (Denotes leading and followingzeros. Example: 0000.00)

Ø . (The position of the decimalpoint Example: ###.##)

Ø , (The group separator forthousands. Example: ###,###.##)

Ø % (Displays the number as apercentage. Example: ##%)

Ø ; (Pattern separator. The firstpattern will be used for positive numbers and the second for negative numbers)

 Decimalformat              Optional.

 

So forexample to format the entered amount for thousands and 2 decimal places wewould use the following in the formfield:

format-number(ENT_AMT, "###,###.00") whichwould convert 1234.5 to1,234.50

If you have negativenumbers these are supported too in the format:

format-number(ENT_AMT,"###,###.00";"(###,###.00)") thesecond format denotes how the negative number should be displayed (note thesemi colon separating the formats).So -1234.5 would become (1,234,50)

To handlethousand/decimal delimiter formatting you need to do a little work on yourtemplate. XSL supports any delimiters but it needs to be told what to use. Youdo this by declaring the decimal format in your template thus:

<xsl:decimal-formatname="Euro" decimal-separator="," grouping-separator="."xdofo:ctx="begin"/>

Name – is the nameyou 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 character you wish to use to denote the thousand separator.

There are severalother options that can be set but these are the basic two.

Please note the useof the xdofo:ctx=”begin” – this is an advanced feature which forces the decimalformat declaration to the root of the template no matter where it is put in thephysical RTF.

So when we call theformat function this time we use:

<?format-number(ACCTD_AMT,'#.###,00', 'Euro')?>

This time 1234.5 willbecome 1.234,50 asexpected. Note the format string has changed this time.

  1. The other     alternative is to use MSWord’s native field formatting. If you open one of     the fields below you’ll notice that there is a field type drop down list     that includes ‘Number’ as an option. You can select this, and then select     the number format you require.
  2. XDO Formatting –     once finalized XDO will format the numbers and dates according to runtime     locale settings. Details to follow.

In this template the

Entered Amt uses <?format-number(ENT_AMT,"#,###.00")?>

Accounted Amtuses  <?format-number(ACCTD_AMT,"#.###,00","Euro")?>

Supplier totals usethe MSWord formatting

 

三十四:BIPUBLISHER

1, 導入數據

2, 插入BIPUBLISHER圖

3, 選擇分組的數據拖入框內

4, 選擇類型(會根據數據提供可供選擇的類型)

5, 設置相關參數就OK

 

三十五.加密,字體

<?PASSWORD?>

舉例

This document issecured with a password - *********

This is a barcodefont: 12132435353

Thisis a MICR font: 121313&33433

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM