Tuesday, March 17, 2009

XSL-FO for BI Publisher

What is XSL-FO?

XSL-FO stands for Extensible Stylesheet Language Formatting Objects. It is a XML-based markup language for formatting XML data.

How does it look?

fo_sample

How is it defined?

Typically FO template has two sections. One is ‘fo:layout-master-set’ and another is ‘fo:page-sequence master-reference=”main-template”’

fo_sample_detail

The ‘layout-master-set’ section can contain multiple templates and each template is defined with ‘fo:simple-page-master master-name=”main_template”’. And this is where you can define your report output page size, margin, etc.

The ‘page-sequence’ section references to a particular template that is defined in the ‘simple-page-master’ and this is where you can define the page content’s formatting and layout.

There are more detail in the XSL-FO language, but I’m not covering the detail since we don’t really need the detail for BI Publisher. If you are interested more in detail please take a look at w3school’s site. They have pretty good contents not only this XSL-FO but any other XML related.

Why this is for BI Publisher?

With a typical BI publisher report development I have seen only a few times where I needed to use XSL-FO codes. Of course you can enhance your BI Publisher reports by using the XSL-FO codes, but most of things can be done by using a combination of the BI Publisher tags, MS-Word native functions, and XSL/XPath.

Only place I see where it used to be very convenient to use XSL-FO codes is a conditional formatting. But the recent versions of BI Publisher Template Builder provide a conditional formatting UI and use predefined attributes. So really we don’t need the XSL-FO code anymore.

BI Publisher Conditional Formatting Menue

Image and video hosting by TinyPic

BI Publisher Conditional Formatting Dialog

Image and video hosting by TinyPic

Good understanding of XSL-FO allows you to do the RTF Template development much more flexible. Also, you can start developing with a XSL-FO template rather than RTF Template and do any type of custom formatting by using the XSLT, XPATH, and XSL-FO. But I’d recommend you start developing with RTF Template with MS-Word/Template Builder because it’s much simple and easy and more importantly much more productive. You can always generate a XSL-FO template from your existing RTF template by using a Template Builder’s export function.

Image and video hosting by TinyPic

Ok, with this post I’ve covered pretty much the basic of XML that you need to know for your BI Publisher template development. From the next post I’ll start covering more on the BI Publisher Enterprise server side such as Custom deployment, JDBC management, report access monitoring, performance tuning, etc. So stay tuned!

15 comments:

  1. Hi Kanichiro, I'm facing some problems regarding to and if condition, If I have a field that doesn't have value It has to write ND however when I do some code like this.
    <?if:Patient and Patient="?> ND <?end
    if?>, I got the next error:

    ConfFile: C:\Archivos de programa\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Archivos de programa\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: C:\Documents and Settings\Administrador\Escritorio\Stendhal\BIPUBLISHER\V2\CIOMS FORM.rtf
    RTFProcessor setLocale: es-es
    FOProcessor setData: C:\Documents and Settings\Administrador\ConfiguraciĆ³n local\Datos de programa\Oracle\BIPublisher\TemplateBuilderforWord\tmp\4\download_data.xml
    FOProcessor setLocale: es-es
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
    at RTF2PDF.runRTFto(RTF2PDF.java:629)
    at RTF2PDF.runXDO(RTF2PDF.java:439)
    at RTF2PDF.main(RTF2PDF.java:289)
    Caused by: oracle.xdo.parser.v2.XPathException: Literal Mismatch.
    at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
    at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
    ... 14 more}

    Can you help me please and tell me what I'm doing wrong??

    ReplyDelete
  2. In XML there is no space allowed in an element name. Since your condition has the element name 'Patient and Patient' this is not valid. You should change the XML element name first. Take a look at one of my other posts that talks about the basic XML rule.
    http://bipconsulting.blogspot.com/2009/03/xml-basic-you-need-to-know.html

    ReplyDelete
  3. getting error when I am trying to Export RTF to XSL-FO Style sheet and the error is "File does not have program associated with it for performing this action. Create an association in the folder Option Control panel.

    ReplyDelete
  4. What's in your RTF template ? Which version of Template Builder (MS-Wrod addin) are you using ?

    ReplyDelete
  5. Hi Kanichiro! We are defining a main template as follows and then calling it in the subtemplate.


    rep_heading 10/6/2010 16:10



    1 of 1



    We are managing to generate an XSL-FO from BIP Desktop. Using 10.1.3.3.3 version of desktop.

    Calling the above template into a template:



    group ROW by DEPARTMENT_NAME
    DEPARTMENT_NAME
    Name First Name Last Name Salary Annual Salary Fed Withheld Job Title Manager
    F NAME
    FIRST_NAME
    LAST_NAME
    SALARY
    ANNUAL_SALARY
    FED_WITHHELD
    JOB_TITLE
    MANAGER E


    end ROW by DEPARTMENT_NAME


    Then when trying to generate PDF, we get the following error message:

    ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: C:\DevSuiteHome_1\j2ee\home\default-web-app\check.rtf
    RTFProcessor setLocale: en-us
    FOProcessor setData: dummy data
    FOProcessor setLocale: en-us
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
    at RTF2PDF.runRTFto(RTF2PDF.java:629)
    at RTF2PDF.runXDO(RTF2PDF.java:439)
    at RTF2PDF.main(RTF2PDF.java:289)
    Caused by: oracle.xdo.parser.v2.XPathException: Variable not defined: '_MR'.
    at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    ... 15 more

    What are we doing wrong?

    Thanks and kind regards,
    Aparna

    ReplyDelete
  6. When I run the my xmlp report (for a connected query) from the reporting console, my template does not launch...all I get is xml? ie,..

    -
    -
    -
    -
    Any ideas

    ReplyDelete
  7. Hi Kanichiro,

    I Saw your blogs for XMLP it so helful thanQ for posting such a valueableinformation.
    I have some queries ..

    Now am developing BI Publisher reports and we are getting xml output,But now we got requirement like we have multiple Legal Entity and other data also now we need to show the output in xml with different sheets ..Sheet A,Sheet B...(each sheet for each legal entity).

    Kindly provide any solution for this problem.

    Regards,
    Nirmala

    ReplyDelete
  8. Thanks for all your tips, it was nice to find another source of rare XMLP information. Have been having a good time with XMLP in Tool 8.48 over the last month, but my biggest challenge at the moment is to produce an XLS output with some 40 columns without the columns being so narrow. RTF allows a max width document of 22 inches. As the output is XLS, is there a way to get past this physical limitation? Also, do XSL template definitions actually work? :)

    ReplyDelete
  9. When I am trying to run custom xml publisher report , it throws error msg as

    Caused by: oracle.xdo.parser.v2.XPathException: Variable not defined: '_MR'.

    Can any one lz look on this

    Thanks in Advance

    ReplyDelete
  10. i have developed a report(like pivot table), created an rtf and registered the rtf, the status getting from this is completed warning.

    if i register that as xsl it executed successfully.

    when we have to go for rtf registration and when we have to go for xsl(xsl-fo) registration?

    if this is cleared, in future we can go for the required option..

    can any one please tell me, when we have to register as rtf and when we have to register as xsl(xsl-fo)..

    ReplyDelete
  11. I have a Clob html report made with pl/sql, is complex and nice and with graphics.
    I want to use this same clob/html text and using a query in publisher generate a pdf file.

    Is this posible, someone in otn say yes, but I can do it.

    Thanks in advance.
    atn javier (jviquez@yahoo.com)

    ReplyDelete
  12. The latest BIP 11.1.1.6, which should be GA today or tomorrow, has this support that it respects the HTML formatting tags stored in the CLOB.

    ReplyDelete
  13. Excuse me, can you send me more details (some link on oracle or something) where mention it?

    Thanks

    ReplyDelete
  14. If your clob is in xsl-fo format you can use the following:



    I'm assuming HTML_COLUMN looks like:

    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" white-space-collapse="false" padding-bottom="3pt" linefeed-treatment="preserve">
    <fo:inline font-weight="bold">hello world</fo:inline>how are you
    <fo:inline font-style="italic">hos</fo:inline>
    <fo:inline font-weight="bold">
    <fo:inline text-decoration="underline">world</fo:inline>
    </fo:inline>
    </fo:block>

    ReplyDelete
  15. Hi,

    how to display images in Excel output and using xsl code.

    thanks!!

    ReplyDelete