加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

BI Publisher(rtf)模板开发语法大全(转)

发布时间:2021-01-17 16:36:30 所属栏目:大数据 来源:网络整理
导读:Rtf 模板开拓譬喻配景,纹理分栏等等成果都能用 word 器材实现不再详细总结各人可以参考 word 教程。。。。。 ? 一 . 组 界说一个组的目标是汇报 XMLPublisher 对一再的数据行举办轮回表现,也就是说必要行使 for-each 举办数据记录的轮回表现 ?for-each:XML

Rtf模板开拓譬喻配景,纹理分栏等等成果都能用word器材实现不再详细总结各人可以参考word教程。。。。。

?

一.组

界说一个组的目标是汇报XMLPublisher对一再的数据行举办轮回表现,也就是说必要行使for-each举办数据记录的轮回表现

<?for-each:XML group element tag name?>

……

<?endfor-each?>

?

?二.新组分页

分页是天然的,但假如想在某处逼迫分页如新组新页,那么可以行使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、?恣意前提分页,必要借助IF+上面的break-after可能break-before,如:

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

2、?牢靠行分页,必要借助IF+上面的break-after可能break-before,在行<?end for-each?>前,如下语句节制每页5行:

<?if:position() mod 5 =0?>
< xsl:attribute name="break-before">page</xsl:attribute>
< ?end if?>

四.页眉页脚

1、?尺度的页眉页脚,即单个页眉页脚,行使Word的成果即可。

2、?扩展的页眉页脚,可行使<?start:body?><?endbody?>把主体部门“框”起来,往往在这两个标志之外的对象,都将被看成页眉页脚。

五.页码和页数

1、?可以用Word的“自动图文集”,在恣意处所插入页码,这个是“天然页码”。

2、?假如在某种环境下想让页码从特定值开始,好比新的组页码从头编号,则必要借助呼吁,如在for-each后写:<?initial-page-number:1?>。这里的“1”,现实上也可以用数据文件中的XML元向来替代。

六.末页、奇偶页差异

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:{’${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数据来动态建设表格内容和题头

动态建设题头的步调:

??à行使<?tagname?>标志的方法来插入题头,并将其名目化为题头。这里不能行使表单

域的成果。

譬喻报表要求将公司名称表现为题头,XML数据标志名为<COMPANY_NAME>,在

报表模板中必要表现问题的处所输入<?COMPANY_NAME?>即可

??à通过word的内置成果建设表格的其他内容

在运行的时辰,体系自动替代表格中和题头标志的值

十一. ??复选框

可以在模板中界说复选框,并按照传入的值来抉择是否被选中

界说复选框的步调:

行使word中的复选框型窗体域成果添加复选框

??打开复选框型窗体域选项窗口

??配置默认值:未选中或选中

??在窗体域辅佐笔墨中输入复选框选中的前提表达式,它必需是一个布尔表达式,只能返回true或false

如:XML数据中包罗了<population>的元素,假如<population>的值大于10000

则复选框被选中,则在窗体域辅佐笔墨中输入如下的前提表达式:

<?population>10000?>

十二.IF语句

<?if:condition?>

<?end if?>

例子

<?if:VENDOR_NAME=’COMPANYA’?>

样板文本中行使IF语句

<?if@inlines:condition?>

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.

十三.If-then-Else?语句

<?xdofx:if element_condition then result1 elseresult2 end if?>

例子:

<?xdofx:if AMOUNT > 1000 then 'Higher‘

Else

if AMOUNT < 1000 then 'Lower‘

'Equal‘

end if?>

十四. Choose?语句

<?choose:?>

<?when:expression?>

<?otherwise?>

?????????????????????????????

十五.?名目化列

按照前提表现或潜匿列

<?if@column:condition?>

<?if@column:condition?>

<?quantity?>

<?end if?>

<?if@column: /items/@type="PRIVATE"?>

<?end if?>

十六.?名目化行

??当前提满意的时辰加亮行

??配置行的配景颜色

??满意前提的时辰才表现行

按照前提来名目化表格的行

<?if:condition?> <?end if?>

<?if@row:condition?>

<xsl:attributename="background-color"

xdofo:ctx="incontext">lightgray

</xsl:attribute>

十七.?单位格加亮(字体加亮)

可以按照前提来加亮单位格

<?if:condition>

<xsl:attribute xdofo:ctx="block"name="background-color">

red

<?if:debit>1000?>

<xsl:attribute xdofo:ctx="block"name="background-color">

red

</xsl:attribute>

举例

Settingfont to?bold?if invoice amount isgreater than $1,000.

?

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

Settingbackground color to?greenif invoice amount is greater than $1,000.

<?if:ACCTD_AMT>1000?><xsl:attributexdofo:ctx="block" name="background-color">green</xsl:attribute><?endif?>

?

十八.?计较合计值

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’?>

number-format:合计值表现的名目

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

<?show-page-total:ct;$#,85); font-family:"microsoft yahei"; font-size:15px'> <?show-page-total:net;$#,85); font-family:"microsoft yahei"; font-size:15px'>

<?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?>

?

<?end template??>

<?template:footer?>

<?endtemplate?>

?

Init PTs

?

End PTs

二十一.?持续合计(同参数高级应用)

报表实现如下的累积合计值

1.?界说变量

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

<?xdoxslt:set_variable($_XDOCTX,’RTotalVar’,85); font-family:"microsoft yahei"; font-size:15px'> 2.?添加每行值

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:

CURRENCY

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

?

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’)?>

This template contains a variable called 'x'

Let’s initialize X to 1

X= ?

Lets add 10 to X

X =?X+10

高级应用Running Total

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

?

<?xdoxslt:set_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

?

二十六.数字日期

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组下的,只要一个新的段发生,它将会

表现新的值

二十九.?交错表

交错表的报表在计划时是无法知道列的数量,也不知道列的题头是,这些都是必要按照数据来抉择的。

三十.?动态数据列

行使动态数据列成果可以实现按照某种前提来动态的表现报表的列数

三十一.一再问题行实现(一再表头)

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:

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:

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

Template Level Property Support

You can now embed any of the XML Publisherproperties into your RTF template <<reference to property lists>>These would then be resolved at runtime by the XML Publisher engine; you caneither use hard coded values or embed the values inside the incoming XML data.For example you might use a non standard font in your template and you wouldnormally have to use a configuration file to specify the font location atruntime for XML Publisher to use. Embedding the font property inside thetemplate you can avoid the use of the configuration file.

If you wanted to secure PDF outputgenerated from a template you can use the XML Publisher pdf security propertiesand obtain the password value from the incoming XML data.

To add an XML Publisher property to atemplate,use the Properties dialog (File -> Properties):

??

The XML Publisher properties need to have'xdo-' as a prefix to their regular names so 'pdf-open-password' becomes'xdo-pdf-open-password'. Just add the XML Publisher properties and their valueto the document using the dialog. If you want to reference a data element inthe XML,a password for instance then use the curly braces in enclose the pathto the XML element.

WorkedExample I – Embedding a font reference

Let’s assume you want to use a font in yourtemplate called 'XMLP Script',this is not available as a regular font on yourserver so XML Publisher requires that you tell it where the font is at runtime.If this location is known and fixed for wherever the template might bedeployed,let’s assume '/tmp/fonts' then you can set the font and its locationinto the template and XML Publisher will use it at runtime. In the propertiesdialog you would enter:

Name :xdo-font.XMLPScript.normal.normal

Type?? :Text

Value? :truetype./tmp/fonts/XMLPScript.ttf

When the template is applied to the XMLdata on the server,XML Publisher will look for the font in the /tmp/fontsdirectory.

WorkedExample II – Securing a PDF output

Let’s assume that the XML data you areusing will contain a specific password that needs to be used to secure theoutput document. Again we can use the document properties to set the PDFsecurity password and reference a value in the XML. Assuming the following XMLdata:

<PO>

?<security>true</security>

?<password>welcome</password>

?<PO_DETAILS>

? ..

<PO>??

In the properties dialog we would enter twoproperties:

Name : xdo-pdf-security – this property sets whetherthe security feature is enabled or not

Value? :{/PO/security}

Name : xdo-pdf-open-password – this property setsthe password

Value? :{/PO/password}

Storing the password in the XML data couldbe a security problem if the XML is going to persist in the system for anylength of time. To avoid this you could achieve the same using a templateparameter value that is generated and passed into the template at runtime.Assuming your parameters were called 'PDFSec' and 'PDFPWD' you would enter thefollowing in the properties dialog:

Value? :{$PDFSec}

Value? :{$PDFPWD}

Both of thesemethods would then secure the output PDF document with a password that wouldonly be known to the user.

三十六.动态列(Dynamic Columns)

Dynamic Data Columns

When the XML columns in thedata are dynamic (that is,the number of columns can vary) the following fourtags can be used in a template to accommodate the dynamic formatting requiredto render the data correctly.

Usethis tag to define which group to split for the column headers of a table.

Usethis tag to define which group to split for the column data of a table.

Usethis tag to define the width of the column,if you have an element storing thespecific width for a column use this tag to define it.

Usethis tag to define a multiplier for the column width i.e. if your column widthare defined in character cells then you will need a multiplier value ~6 torender the columns to the correct width in points. If the multiplier is notdefined,the widths of the columns are calculated as a percentage of the totalwidth of the table. See the following example:

Horizontal table break withrow header number<?horizontal–break–table:number?>

Worked Example

<?xmlversion="1.0" encoding="utf-8" ?>

>0-20</TestScoreRange>30</NumOfStudents>?

  • The first column contains the row heading (<TestCategory>) i.e. ‘Mathematics’
  • The second column is the one to be split???? dynamically,the width you specify will be divided by the number of???? columns of data i.e. 5.
  • The second column will contain the dynamic???? ‘range’ data,the width of the column will be divided up according to the???? split column width and because there is no ‘multiplier’ present in this???? example the column will be split on a percentage basis. Wrapping of the???? data will occur if required.
  • If the multiplier was present then the columns???? would have a specific width in ‘points’. If the total column widths were???? wider than the allotted space on the page then the table would break on to???? another page. The ‘horizontal–break–table’ tag could then be used to???? specify how many columns should be repeated on the subsequent page,with a???? value of ‘1’ the ‘TestScore’ column will be repeated then the additional???? columns that did not fit on the first page.
  • ?

    ?

    ?

    Theabove template will render the following result in the output:

    举例

    别人总结

    1.1.?机关名目化

    1.1.1.??????????????????????????????????????????????????????????????????????????提议做法

    充实操作Word的名目化成果:纸张自界说、颜色、字号、字体、问题样式、配景、水印、对齐、表格、分栏、模版日期、窗体域的数字/日期名目、文件图片、页眉页脚、自动图文集。

    固然可以代码节制,但既然依托Word作为可视化计划器材,我们就只管行使Word成果来计划报表吧!

    1.1.2.??????????????????????????????????????????????????????????????????????????Word表格

    和做网页一样,表格在报表机关中的职位至关重要,要纯熟把握,尤其是:

    1、问题行一再,可以实现新页一再问题。

    2、嵌套表格、队列归并、边框、底纹,可以实现非凡的机关。

    3、牢靠列宽、自动调解、榨取跨页断行,可以实现一些严酷的机关节制。

    1.1.3.??????????????????????????????????????????????????????????????????????????行截断与榨取折行

    单子打印中对名目标要求较量高,假如某一行过长可能呈现多次折行,就会粉碎版面,尤其是套打等要求较高的场所,这里把各类要领作个小结。

    1、Word成果,不抱负

    牢靠列宽成果可以用,但牢靠行高不可,固然计划时看到“牢靠”了,假如不加节制,运行后多出列宽的数据会自动折行。

    2、单行+截断,即节制只有以行,多余截断,榨取折行

    在字段后,再加两个呼吁:

    <xsl:attribute xdofo:ctx="block"name="wrap-option">no-wrap</xsl:attribute>

    3、多行+截断,难

    如牢靠表现3行,多余部门截断,今朝通过模版无法实现,只有在数据源中先将数据制止恰恰3行的字符数,然后操作自动折行成果。这里还要留意空格,假如碰着空格,后头的单词又表现不下,将会提前自动折行。

    1.1.4.??????????????????????????????????????????????????????????????????????????前提名目化

    在差异的前提下表现差异的颜色、差异的列数、差异的问题、差异的机关气魄威风凛凛等等,这些都属于前提名目化,必要借助IF呼吁。

    1、好比差异笨酥凭据打印名目差异

    <?if:CURRENCY_CODE="CNY"?>任何机关<?endif?>

    <?if@column:CURRENCY_CODE="CNY"?>字段值和名目 注:这还不是真正的动态列。

    3、好比偶数行底色为灰色,在行的任何单位格内写如下语句

    4、好比高出100单位格呈赤色,在方针单位格内写如下语句

    ?

    1.2.?字段计较能力

    1.2.1.??????????????????????????????????????????????????????????????????????????提议做法

    1、计较字段可以在SQL中先完成。

    2、假如行使Oracle Reports做数据源,那么计较字段、统计字段也可以先完成。

    3、在SQL中的数据,都不带名目,名目在模版中配置;必要在模版中完成计较的字段,必需不带名目,首要指数字不能带千位标记。

    1.2.2.??????????????????????????????????????????????????????????????????????????组内合计

    N: Template Builder/插入/字段

    领导可以完成根基的统计,今朝支持分组内的:Sum、Count、Min、Max、Avarage。

    自动天生的代码示例:<?sum (QUANTITY)?>。

    1.2.3.??????????????????????????????????????????????????????????????????????????页内合计

    要实现本页合计数,需分两步:声明合计变量、表现合计变量(可带名目)。

    1、对QUANTITY举办本页合计,声明变量QTYTOTAL,留意写在QUANTITY对应的组内,否则引用不到

    2、可在恣意处所表现合计数

    那么怎样实现组内+页内合计呢?

    1.2.4.??????????????????????????????????????????????????????????????????????????结转合计

    把上页的合计数表现到下页,与“页内合计”相同,需分两步:声明合计变量、表现合计变量。

    用得少,可参考User Guide“Brought Forward/Carried Forward Totals”部门。

    1.2.5.??????????????????????????????????????????????????????????????????????????累计数Running Totals

    累计每行数字,现实上是这样完成的:先声明一个变量,初始化为0;累加;在必要的处所表现累计。

    1、在分组标志前初始化,Set变量

    2、计较累计值,凡是写在欲累计的字段统一单位格内,好比下面的QUANTITY

    3、恣意处所表现累计值,Get变量

    1.3.?任何Page相干题目

    1.3.1.??????????????????????????????????????????????????????????????????????????新组分页

    分页是天然的,但假如想在某处逼迫分页如新组新页,那么可以行使Word的分页符(CTRL+ENTER快捷键),但会导致最后呈现空缺页;这样只能行使如下几种方法:

    1、分组声明中加@section,如<?for-each@section:G_PO_HEADER?>。

    2、<?end for-each?>前加<?split-by-page-break:?>。这个翻译后,现实上是:

    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.3.2.??????????????????????????????????????????????????????????????????????????前提分页、牢靠行分页

    1、 恣意前提分页,必要借助IF + 上面的break-after可能break-before,如:

    2、 牢靠行分页,必要借助IF + 上面的break-after可能break-before,在行<?end for-each?>前,如下语句节制每页5行:

    1、尺度的页眉页脚,即单个页眉页脚,行使Word的成果即可。

    2、扩展的页眉页脚,可行使<?start:body?><?endbody?>把主体部门“框”起来,往往在这两个标志之外的对象,都将被看成页眉页脚。

    1.3.4.??????????????????????????????????????????????????????????????????????????页码和页数

    1、可以用Word的“自动图文集”,在恣意处所插入页码,这个是“天然页码”。

    2、假如在某种环境下想让页码从特定值开始,好比新的组页码从头编号,则必要借助呼吁,如在for-each后写:<?initial-page-number:1?>。这里的“1”,现实上也可以用数据文件中的XML元向来替代。

    1.3.5.??????????????????????????????????????????????????????????????????????????末页、奇偶页差异

    1、Word可在页眉页脚部门实现首页差异或奇偶页差异,没法实现末页差异,纵然借助代码节制,现实实现的也是末页机关差异,而非“页眉页脚”差异。

    报表自己仅有一页时,则用<?start@last-page-first:body?><?endbody?>

    例子“AdvancedLast Page”,留意机关必要独立成页,即之前必要加分页符。

    2、以偶数页竣事,首要目标是表现偶数页页眉页脚

    假如仅表现空缺页,则用<?section:force-page-count;’end-on-even’?>

    3、以奇数页竣事,首要目标是表现奇数页页眉页脚

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

    1.4.?行使多媒体元素

    1.4.1.??????????????????????????????????????????????????????????????????????????Word成果

    可以行使公式、画图(如组织布局图、线条等)、艺术字、剪贴画。

    假如想通过代码在有限范畴内节制这些工具,好比表现笔墨、缩放、旋转、移动、复制,可参考User Guide中的“Drawing,Shape and Clip ArtSupport”。

    1.4.2.??????????????????????????????????????????????????????????????????????????复选框

    插入复选框窗体域,因其选中代表True,不选代表False,必要我们输入前提表达式,如:。不外运行后示意为菱形。

    1.4.3.??????????????????????????????????????????????????????????????????????????下拉框

    插入下拉框窗体域,界说下拉框的元素,并同样在“本身键入”内输入必要引用的XML标志如<%AREA_INDEX%>。这里要留意元素的次序,由于是用次序号和运行时的值举办匹配的,也就是XML数据中,AREA_INDEX是天然数1、2……。

    1.4.4.??????????????????????????????????????????????????????????????????????????超链接

    可以直接操作Word成果配置超链接,也可以在链接地点中,所有或部门引用XML数据文件中的标志,做到动态超链接:

    http://huajhua.leiko.com:8000/OA_MEDIA/{CURRENCY_CODE}.gif

    1.4.5.??????????????????????????????????????????????????????????????????????????图片

    可以直接操作Word成果插入图片,也可以仅将该图片看成占位图,在图片的“配置图片名目”的网站标签页内的“可选笔墨”,输入真正的图片地点:

    1、来自网站的图片:url:{‘http://localhost:8000/OA_MEDIA/forms_logo.gif’}。

    2、来自EBS的图片:url:{‘${OA_MEDIA}/forms_logo.gif’}。

    3、动态指定地点:url:{IMAGE_URL}。

    4、动态拼接的地点:url:{concat(SERVER,’/’,IMAGE_DIR,IMAGE_FILE)}。

    5、直接来自内容为BLOB的XML元素,仅用于“DataTemplates”:

    可行使Template Builder领导插入图表,范例有:条形图-垂直、条形图-程度、饼图、线形图。

    领导天生的代码,可在图片的“配置图片名目”网站标签页内的“可选笔墨”里看到,我们可以做进一步修改。

    1.5.?其余常用语法

    1.5.1.??????????????????????????????????????????????????????????????????????????字段引用

    在前面的窗体域中,我们直接引用XML文件中的Tag标志,如<?QUANTITY?>。这种对XML元素的引用,是相对当前条理的组来说;假如上层组中,有个同名Tag,就要通过相同“相对路径”的方法引用,如<?../QUANTITY?>。这里的“../”个数,不是机关中的相对层测个数,而是XML数据文件中的相对条理!

    转换为XSL-FO后,真正的语法别离是:

    <xsl:value-ofselect="../../QUANTITY" xdofo:field-name="../../QUANTITY"/>

    1.5.2.??????????????????????????????????????????????????????????????????????????函数引用

    1、行号,精确讲是分组中记录次序号:<xsl:value-ofselect="position()"/>

    2、总行号:<xsl:value-of select="last()"/>

    更多函数请参考XSL手册。

    1.5.3.??????????????????????????????????????????????????????????????????????????分组、排序、从头分组

    1、可以通过领导完因素组、排序:

    2、数据从头分组,不再限定于原始XML数据文件的条理相关

    数据为“Sales Report”,从头按年、月分组,领略如下实例,必要一点“想象力”:

    EE

    1.5.4.??????????????????????????????????????????????????????????????????????????变量、参数

    1、模版变量

    和平凡的编程说话相同,模版中也可以行使变量,参考“累计数”部门。

    2、模版参数,只能通过API挪用传入,不能用于EBS并发哀求

    声明参数:<xsl:param name="P_NAME"xdofo:ctx="begin"/>

    用$引用参数:<?if:AMOUNT>$P_NAME?>

    传入参数:参考API部门。

    1.5.5.??????????????????????????????????????????????????????????????????????????空值判定

    1、有标志,值不空

    2、有标志,值空

    <?if:not(Element_Name)?>Somethine Here<?end if?>

    1.5.6.??????????????????????????????????????????????????????????????????????????数字和日期名目

    可以行使Word窗体域中的名目化成果,也可以在窗体域中输入XMLP的名目化呼吁,这两者不能同时行使,提议行使前者;后者语法参考User Guide“Number and Date Formatting”。

    1.5.7.??????????????????????????????????????????????????????????????????????????领略上下文

    上下文代表XMLP语句的浸染域,好比一个If语句,到底是针对一个单位格、一行、照旧一列。在前面的先容中,我们已经用过section、column、row,下面列出XMLP的全部上下文及其寄义:

    1.6.?高级机关

    1.6.1.??????????????????????????????????????????????????????????????????????????动态列

    动态列的寄义是:计划时不知道有几多列,运行时XML数据文件中有确切的列数。如例子“AdvancedDynamic ColumnsTestScore”:

    HEADER:<?horizontal-break-table:1?>

    YEAR:<?for-each-group@column:ROW;YEAR?><?YEAR?><?endfor-each-group?>

    for:<?for-each-group:ROW;INDUSTRY?>

    INDUSTRY:<?INDUSTRY?>

    sum(sales):<?for-each-group@cell:current-group();YEAR?><?sum(current-group()//SALES)?><?endfor-each-group?>

    end:<?endfor-each-group?>

    5.6.3之后,可以在TemplateBuilder中通过领导完成,不必要手工写代码。

    1.6.3.??????????????????????????????????????????????????????????????????????????属性节制

    对文档的节制,可以在处事器端同一设置,拜见“处事器端设置”,也可以在模版级别举办节制,好比节制天生的PDF文件暗码、字体路径,可以通过Word的“文件/属性”配置相干参数:

    1.6.4.??????????????????????????????????????????????????????????????????????????嵌套模板/子模板

    嵌套模板是在模板中界说一个子模板,然后在必要的处所挪用它,如在页眉页脚中挪用它,这样也可以打破页眉和页脚中不应承行使窗体域的限定。

    1、界说子模板

    子模板标志之间可以行使任何的标志和内容,和模板的主体部门没有任何区别。

    ……

    2、挪用子模板

    Word有自动发生目次的成果,那么在模版中怎样实现呢?凭证User Guide中的声名,TOC照旧没法测试乐成。

    1.6.6.??????????????????????????????????????????????????????????????????????????PDF标签(Bookmarks)

    在TOC的基本上实现PDF标签:

    1、静态TOC

    1、动态TOC

    热点阅读