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

 

 

posted @ 2016-08-19 17:39  BIT10  阅读(5448)  评论(0编辑  收藏  举报