Sei sulla pagina 1di 31

IBM India

Oracle XML Publisher


An Overview
By Rashmi Kumari

Copyright IBM Corporation 2005

IBM India

To Discuss on
XML Publisher What and Why Requirements Development Approach
-

Steps Overview Develop Report Template RTF template and Register

- Some Frequently Used Tags


-

Data Definition Design

- Development Steps using PL/SQL - Different PL/SQL Approaches - Development steps using data template

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

XML Publisher What and Why

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Classic Reporting Tool Issue

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Classic Reporting Tools Issue

Data logic

Layout

Report file

Translation

Less flexibility High Development Cost High Customization Cost Difficult Upgrade

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

XML Publisher Concept

Separate data / layout / translation

Data Logic Layout


XML Publisher

Translation

Report output

More flexibility Reduced maintenance


6 | Oct 20, 2012 | Copyright IBM Corporation 2005

IBM India

Extract Once Publish Multiple Times

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Requirements..
Creating reports using XML Publisher can be divided into two components: Report Query (XML) and Template (Layout). XML Publisher Administrator Responsibility Report Query can be developed using:
-

Reporting tool like Oracle Reports6i PLSQL program (Packaged procedure) Data Template (Also Known as XDO Reporting) Template Builder provided by Oracle

Template (RTF) can be developed using:


-

(The tool needs to be installed on your desktop, which provides add-on toolbar in MSWord.)

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Development Approach

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Development Steps
Here it is assumed that report query will be developed using Oracle reporting tool and layout is RTF template
1. 2. 3. 4. 5. Create and register report as concurrent program Generate the XML file and download it in development work space Design the template Map the template with XML file tag Register the data definition and template

10

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Create Concurrent Program Prepare Data in XML


Copy any existing report or create a new one with output type XML Copy To IMPORTANT The Concurrent Program Short Name must match the Source Code of the Data Definition

11

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Generate XML Output

12

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

The XML Output

13

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Design Template

14

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Identify Placeholders & Groups

Placeholders
Individual Fields, e.g. PO Number Vendor Name Product Description

Groups
Repeating Elements, e.g. PO Lines Purchase Orders

15

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Map Template

16

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Basic RTF

17

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Form Field Method

18

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Register Data Definition

1.

2.

3.

The Application must match that of the report The Code must match the Short Name of the report Attach a sample of your XML output to preview and test your template

19

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Register Template
1. The Application must match that of the report The Type must match the file type of your design A Data Definition is Required, but it may simply be a placeholder However, by loading sample XML, you can preview the template You can add different templates for each language and region

2.

3.

4.

5.

20

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Print Report

21

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Finished Result

22

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Some Frequently Used Tags


For defining Elements
<?XML element tag name?> e.g. <?FIRST_NAME?>

For defining Groups <?for-each:XML group element tag name?> <?end for-each?> e.g. <?for-each:G_DEPT?> end for-each?> <?

For Header and Footer <?start:body?> and <?end body?> For Conditional Formatting <?if:condition?> <?end if?> e.g. <?if:cs_no_data_found=1?>*** NO DATA*** <?end if?> <?xdofx:if element_condition then result1 else result2 end if?> e.g. <?xdofx:if AMOUNT > 1000 then High else if AMOUNT < 1000 then Low else Equal end if?> For Page Totals <?add-page-total:TotalFieldName;element?> <?show-page-total:TotalFieldName;number-format?> For Defining Variable <?xdoxslt:set_variable($_XDOCTX, RTotalVar, 0)?> <?xdoxslt:get_variable($_XDOCTX, RTotalVar)?>

23

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Some Frequently Used Tags Contd.


For Sorting <?sort:element name?> e.g. <?sort:FIRST_NAME?> For Checking Nulls <?if:element_name!=?> <?end if?> <?if:element_name and element_name="?> <?if:not(element_name)?> For arithmetic and string operations <?xdofx:2+3?>, <?xdofx:2-3?>, <?xdofx:2*3?>, <?xdofx:2/3?>, <?xdofx:2**3?>, <?xdofx:3||2?> <?xdofx:lpad(aaa,10,.)?>, <?xdofx:rpad(aaa,10,.)?>, <?xdofx:decode(xxx,bbb,ccc, xxx,ddd)?>, <?xdofx:Instr(abcabcabc,a,2)?>, <?xdofx:substr(abcdefg,2,3)?>, <? xdofx:sysdate()?>, <?xdofx:to_number(12345)?>, <?xdofx:replace(name,John, Jon)?>, <?xdoxslt:minimum(ELEMENT_NAME)?>, <?xdoxslt:maximum(ELEMENT_NAME)?>

24

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Data Definition Design

25

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Development Steps using PL/SQL


Create a Packaged Procedure which will generate output in XML Format Register the executable as PL SQL Stored procedure Register the Concurrent Program Set the Output as XML Create the template Defining the Data definition and Template registration is same as Oracle Reports steps mentioned in the earlier slides

26

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Ways to Generate XML From PL/SQL DBMS_XMLGEN


it has a number of function to support xml development. Some Important Functions newContext(queryString IN VARCHAR2) setRowTag(ctx IN ctxHandle,rowTag IN VARCHAR2) setRowSetTag(ctx IN ctxHandle, rowSetTag IN VARCHAR2) getXML(ctx IN ctxHandle, dtdOrSchema IN number:= NONE) RETURN clob getXML(sqlQuery IN VARCHAR2, dtdOrSchema IN NUMBER := NONE) RETURN CLOB; closeContext(ctx IN ctxHandle); getNumRowsProcessed(ctx IN ctxHandle) RETURN number; setNullHandling(ctx IN ctxHandle, flag IN NUMBER) where flag values can be DROP_NULLS CONSTANT NUMBER := 0 ; NULL_ATTR CONSTANT NUMBER := 1 and EMPTY_TAG CONSTANT NUMBER := 2; This sets, for example, <foo/>.
Example 1 O utput o Ex ple f am 1 null_handling_xampl e null_hand_output

27

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Ways to Generate XML From PL/SQL Contd DBMS_XMLGEN Contd.


can be used in sql querry directly to generate the xml. e.g. SELECT DBMS_XMLGEN.getxml ('select empno, ename, job from emp where rownum < 6' ) xml FROM DUAL;
Text Document

For nesting of tags there is a cursor function available e.g. SELECT DBMS_XMLGEN.getxml ('select deptno, dname, cursor(select ename, job
from emp e where e.deptno = d.deptno) emp_row from dept d where rownum < 4' ) xml FROM DUAL ;
Text Document

28

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Ways to Generate XML From PL/SQL Contd XMLDOM Package.


Some Important Functions xmldom.newDOMDocument - used to create a new document handle xmldom.makeNode Makes a Node. xmldom.createElement Creates an Element xmldom.appendChild Appends a Child to a parent node. xmldom.setAttribute- Sets the attribute of an element node. Xmldom.createTextNode- Creates the Text Node. xmldom.writeToFile Writes the xml tags to a file. xmldom.writeToClob - Writes the xml tags to a CLOB Object.

XMLDOM single Query

s le q ry o t u ing _ ue _ u p t

mu ltiple qu erry

m ultiple que ry o utput

29

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Development Steps using Data Template


Here we can define the Query in XML format using any text editor, sample Data Template is attached below After Defining the query, define a concurrent program. We need to use the executable XML Publisher Data Template Executable (short name XDODTEXE) for this concurrent program Data definition short name must be same as concurrent program short name After creation of the Data definition, add the Data Template xml file using Data Template - Add File Button. The RTF template creation and registration is same as other two methods described earlier

Sample Data Template

30

| Oct 20, 2012 |

Copyright IBM Corporation 2005

IBM India

Thank You

31

| Oct 20, 2012 |

Copyright IBM Corporation 2005

Potrebbero piacerti anche