2011/03/09

ハイパーリンク (Hyperlink)

出力結果にハイパーリンクを埋め込むには、MS-Wordのダイアログから埋め込む方法と、フィールドにコードを記述する方法の2種類があります。


【MS-Wordのダイアログを利用する方法】
MS-Wordのメニューから新規にハイパーリンクを挿入します。


データ項目の指定方法が、表示文字列とアドレスの設定で異なります。
表示文字列: <?EMPNO?>
アドレス: http://empsrv.company.com/emp.jsp?empnumber={EMPNO}
※もちろん、固定文字列でもOKです。


【フィールドにする方法】
フィールドのプロパティに以下のコードを記述します。


<fo:basic-link>
<xsl:attribute name="external-destination">http://empsrv.company.com/emp.jsp?empnumber=<xsl:value-of select="EMPNO"/>
</xsl:attribute>
<xsl:value-of select="EMPNO"/>
</fo:basic-link>



[ Summary ]
There are two ways to embed hyperlinks in RTF template.  The examples above results in same output.  You can set URL text on runtime.
1) Use MS-Word dialog (the first figure)
2) Write basic-link tags in field property (the second figure)

2011/03/08

日付の書式とタイムゾーン (Timezone)

BI Publisher で日付型を出力する際には、タイムゾーンの注意が必要です。
今回は時刻部分をtruncした日付をテンプレートで書式設定すると、日付に誤差が生じる例を説明します。

データソースに以下のSQLを設定します。
select sysdate as col_sysdate,
       trunc(sysdate) as col_sysdate_trunc
 from dual


このデータソースから得られる実データは以下の様になります。
<DATA_DS>
<G_1>
  <COL_SYSDATE>2011-03-07T21:31:59.000+09:00</COL_SYSDATE> 
  <COL_SYSDATE_TRUNC>2011-03-07T00:00:00.000+09:00</COL_SYSDATE_TRUNC>
</G_1>
</DATA_DS>


これらのデータをテンプレート上でyyyy/MM/ddに書式設定してプレビュー表示します。



col_sysdate_truncの値が1日ずれます。



これはレポートタイムゾーンがデフォルトでUTCと認識されるために発生します。表示形式をyyyy/MM/dd  hh:mm:ssに設定した実行結果を以下に示します。実際には、タイムゾーンの時差、9時間前の値として認識されていることが確認できます。



参考URLでは「RTFテンプレートでの日付書式設定は使用しないこと」という身も蓋もない回避策と、format-dateにてタイムゾーンを設定する方法が紹介されています。format-dateの書式は以下の通りです。なお、format-dateにおけるタイムゾーンはJavaタイムゾーン書式ですが、日付書式はオラクル書式ですので注意してください。
<?format-date:HIREDATE;'yyyy-mm-dd';'Asia/Tokyo'?>

参考URL:
http://blogs.oracle.com/xmlpublisher/2009/06/how_to_keep_your_dates_from_go.html



[ Summary ]
Date value in BI Publisher is Timezone sensitive.  With format-date, you can settle the date value in certain timezone.  Note that while the timezone parameter is based on Java formula, date format parameter is based on Oracle formula.
For more details, refer the URL above.

2011/03/07

罫線でrowspanを表現する (Drawing rowspan)

rowspanを簡易的に表現する方法を説明します。要件となる出力結果は以下の通りです。deptnoをグループと見なし、罫線の表示を切り替えます。



連続するdeptnoの値の出力を抑制する方法については、「連続する値の表示を抑制する方法」を参照して下さい。

設定は罫線の正業を行うセル(deptno)にて行います。以下の図の[F]が該当します。


[F]には以下の2つの設定を記述します。
1) 次の行のdeptnoが同じであれば、border-bottomを白で描画
2) 前の行のdeptnoが同じであれば、border-topを白で描画

<?if:following-sibling::ROW[1]/DEPTNO=DEPTNO?><?attribute@incontext:border-bottom;'0.5px solid #ffffff'?><?end if?>
<?if:preceding-sibling::ROW[1]/DEPTNO=DEPTNO?><?attribute@incontext:border-top;'0.5px solid #ffffff'?><?end if?>


レンダリング時、隣接する行で罫線が上書きされるため、これら2つの設定はどちらか片方ではなく、両方記述する必要があります。
罫線の設定書式はxsl-foの書式に従い、「太さ スタイル 色」の順に設定を記載します。

border-leftまたはborder-rightに同様の設定を行うことで、colspanの表現も可能です。



[ Summary ]
The example above draws rowspan look by controling border color.  [F] in the second figure contains two settings.  They are for border-bottom and border-top.  Because top / bottom borders are overwritten by the neighboring rows, you need to write these two settings, not one of them only.
The formula of border setting is 'weight style color', separated by space.


Refer the past entry "Suppress duplicated values" also.



2011/03/04

ロゴの変更 (Replace the header image)

画面上部のORACLEのロゴを(自社/自社製品のロゴなどに)変更する場合は、以下のファイルを置き換えます(標準構成の場合)。置き換えるイメージのサイズは、オリジナルに合致させて下さい。

【10.1.3】
bi_home\bi\oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver\xdo\images\oracle.gif
(155px * 20px)

【11.1.1】
middleware_home\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\bipublisher_11.1.1.3.0\rww81x\war\resource\blafplus\branding\oracleLogo.png
(119px * 25px)

11gでロゴを入れ替えた結果は以下の通りです。




また、BI Publisher 10.1.3.4.1では、ヘッダ部をユーザから完全に隠蔽する機能が追加されています。
手順は、ファイル<BI Publisher repository>/Admin/Configuration/xmlp-server-config.xml に以下の設定を追加し、再起動するだけです。

<property name="DISPLAY_HEADER_LOGO_MENU" value="false"/>

※なお、画像の差し替えに際しては著作権およびサポート上の問題がない旨をSRにて都度、確認して下さい。

参考URL: (マニュアル(新機能ガイド))

http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e14667/toc.htm#BABEHCCG




[ Summary ]
To change ORACLE logo image, replace the image files listed above.  The pixel size of new image should be same as the original.


If you use 10.1.3.4, you can remove the whole header region.  Add following setting on <BI Publisher repository>/Admin/Configuration/xmlp-server-config.xml
<property name="DISPLAY_HEADER_LOGO_MENU" value="false"/>


Note: Before you replace the image, you should better ask Oracle Support about copyright and support issue always.

Refer the url below for more details. (BI Publisher New Features Guide)
http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e14667/toc.htm#BABEHCCG

2011/03/03

関数とフィルタ (Filter with functions)

テンプレート上でsumを使用した場合、当該列にNULLが含まれると集計結果に "NaN" が表示されてしまいます。これを避けるためには、以下の様にsumのフィルタに .!="" を記述します。
<?sum(COMM[. != ""])?>

同様に、特定の値のカウントなども可能です。以下の例ではSALが3000以上の値のみをカウントします。
<?count(SAL[. >= 3000])?>

参考URL:
http://blogs.oracle.com/xmlpublisher/2008/02/summing_nulls.html


[ Summary]
When sum function encounters null value, it shows NaN.  To skip null values, set filter [ . != "" ] .
Also, filter is available with count function.

2011/03/02

日付の計算 (Adding days to a date)

日付に加算・減算を行うには xdoxslt:ora_format_date_offset を使用します。書式は以下の通りです。
<?xdoxslt:ora_format_date_offset(date, offset, 'operator')?>

前日の日付を表示する場合は以下のように offset に1、operator にマイナス記号を設定します。
<?xdoxslt:ora_format_date_offset(HIREDATE, 1, '-')?>


また、参考URLで紹介されているように、offset に列名を指定することもできます。以下の例では INVOICE_DATE の INVOICE_TERM 日後の日付が取得できます。
<?xdoxslt:ora_format_date_offset(INVOICE_DATE, INVOICE_TERMS, '+')?>


参考URL:



[ Summary ]
xdoxslt:ora_format_date_offset provides date value addition and subtraction.  See the formula above.


Refer the URL above for more details.

2011/03/01

rpad関数で簡易グラフを表現する (Simple chart with RPAD function)

一覧表に簡単なグラフを表現するサンプルです。RPAD関数で”|” (0x7c) を並べて出力します。




設定は以下の通りです。テンプレートの文字色を変えることで目盛を表現します。



<?xdoxslt:rpad('', floor(SAL div 250), '|')?><?xdoxslt:rpad('', 20-floor(SAL div 250), '|')?>


[ Summary ]
With '|' (0x7c), you can show simple chart.  On the RTF template, use RPAD function with two colors.