XML Publisher PPT
Transcript of XML Publisher PPT
IBM India
© Copyright IBM Corporation 2005
Oracle XML PublisherOracle XML Publisher
An OverviewBy Rashmi Kumari
| Apr 11, 2023 | 2
IBM India
© Copyright IBM Corporation 2005
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
| Apr 11, 2023 | 3
IBM India
© Copyright IBM Corporation 2005
XML Publisher What and Why
| Apr 11, 2023 | 4
IBM India
© Copyright IBM Corporation 2005
Classic Reporting Tool Issue
| Apr 11, 2023 | 5
IBM India
© Copyright IBM Corporation 2005
Classic Reporting Tools Issue
Data logic Layout
TranslationReport file
• Less flexibility
• High Development Cost
• High Customization Cost
• Difficult Upgrade
| Apr 11, 2023 | 6
IBM India
© Copyright IBM Corporation 2005
XML Publisher Concept
Separate data / layout / translation
Reportoutput
More flexibilityReduced maintenance
Data Logic
Layout
TranslationXML Publisher
| Apr 11, 2023 | 7
IBM India
© Copyright IBM Corporation 2005
Extract Once – Publish Multiple Times
| Apr 11, 2023 | 8
IBM India
© Copyright IBM Corporation 2005
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 (RTF) can be developed using:- Template Builder provided by Oracle
(The tool needs to be installed on your desktop, which provides add-on toolbar in MSWord.)
| Apr 11, 2023 | 9
IBM India
© Copyright IBM Corporation 2005
Development Approach
| Apr 11, 2023 | 10
IBM India
© Copyright IBM Corporation 2005
Development Steps
1. Create and register report as concurrent program2. Generate the XML file and download it in development work space3. Design the template4. Map the template with XML file tag5. Register the data definition and template
Here it is assumed that report query will be developed using Oracle reporting tool and layout is RTF template
| Apr 11, 2023 | 11
IBM India
© Copyright IBM Corporation 2005
Create Concurrent Program – Prepare Data in XML
Copy To…
IMPORTANTThe Concurrent Program “Short Name” must match the “Source Code” of the Data Definition
Copy any existing report or create a new one with output type XML
| Apr 11, 2023 | 12
IBM India
© Copyright IBM Corporation 2005
Generate XML Output
| Apr 11, 2023 | 13
IBM India
© Copyright IBM Corporation 2005
The XML Output
| Apr 11, 2023 | 14
IBM India
© Copyright IBM Corporation 2005
Design Template
| Apr 11, 2023 | 15
IBM India
© Copyright IBM Corporation 2005
Identify Placeholders & Groups
PlaceholdersIndividual Fields, e.g.
- PO Number- Vendor Name- Product Description
GroupsRepeating Elements, e.g.
- PO Lines- Purchase Orders
| Apr 11, 2023 | 16
IBM India
© Copyright IBM Corporation 2005
Map Template
| Apr 11, 2023 | 17
IBM India
© Copyright IBM Corporation 2005
Basic RTF
| Apr 11, 2023 | 18
IBM India
© Copyright IBM Corporation 2005
Form Field Method
| Apr 11, 2023 | 19
IBM India
© Copyright IBM Corporation 2005
Register Data Definition
1. The Application mustmatch that of thereport
2. The “Code”must match the“Short Name” of thereport
3. Attach a sample ofyour XML output topreview and test yourtemplate
| Apr 11, 2023 | 20
IBM India
© Copyright IBM Corporation 2005
Register Template
1. The Application mustmatch that of thereport
2. The Type must matchthe file type of yourdesign
3. A Data Definition is“Required”, but it maysimply be a place-holder
4. However, by loadingsample XML, you canpreview the template
5. You can add differenttemplates for eachlanguage and region
| Apr 11, 2023 | 21
IBM India
© Copyright IBM Corporation 2005
Print Report
| Apr 11, 2023 | 22
IBM India
© Copyright IBM Corporation 2005
Finished Result
| Apr 11, 2023 | 23
IBM India
© Copyright IBM Corporation 2005
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’)?>
| Apr 11, 2023 | 24
IBM India
© Copyright IBM Corporation 2005
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)?>
| Apr 11, 2023 | 25
IBM India
© Copyright IBM Corporation 2005
Data Definition Design
| Apr 11, 2023 | 26
IBM India
© Copyright IBM Corporation 2005
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
| Apr 11, 2023 | 27
IBM India
© Copyright IBM Corporation 2005
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 Output of Example1 null_handling_xample
null_hand_output
| Apr 11, 2023 | 28
IBM India
© Copyright IBM Corporation 2005
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;
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
Text Document
| Apr 11, 2023 | 29
IBM India
© Copyright IBM Corporation 2005
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
single_query_output
multiple querry multiple query output
| Apr 11, 2023 | 30
IBM India
© Copyright IBM Corporation 2005
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
| Apr 11, 2023 | 31
IBM India
© Copyright IBM Corporation 2005
Thank You