This action might not be possible to undo. Are you sure you want to continue?
Learn how to create reporting layout formats easily and simply using Oracle XML Publisher. by Tim Dexter (email@example.com) Oracle XML Publisher provides a ne reportin! paradi!m in the mar"et
place. Traditional reportin! tools hold the datasource (#uery)$ layout and translation in a sin!le executable %ile. XML Publisher ta"es the approach o% splittin! the three components apart. This ma"es reportin! much more %lexible and easier to maintain. &ith the layout no independent o% the data this allo s 'T departments to
start consolidatin! their datsources into %e er extraction pro!rams. (o lon!er do they have to have one #uery$ one layout. ) sin!le data extraction can no support multiple layouts allo in! users to apply various layouts to a sin!le datasource and !enerate completely di%%erent report outputs. The 'T department can also %ree itsel% %rom the perrenial problem o% havin! to build and maintain layouts %ormats. The layout templates can be built usin! %amiliar des"top tools such as M*&ord or )dobe )crobat. These can be built by %unctional users process is %aster, Developin! data extraction pro!rams - the 'T department can use various methods %or extractin! data one o% the %astest bein! the XML Publisher data en!ine. )t its most basic$ !ive it *.L and it ill return XML data. ith a little practice. Or!ani+ations can see hu!e savin!s in time and e%%ort in !ettin! reports to their end users. )t every sta!e the
/uildin! Layouts - no lon!er a tedious thread o% email bet een business analyst and developer to !et the layout 0ust ri!ht. The analyst "no s the re#uirements intimately and can build the layout him or hersel% and !et it ri!ht %irst time. Then pass to the developer %or deployment to the server.
xml. <?xml version="1. )lternatively you can do nload %rom the Oracle *tore site by searchin! %or XML Publisher. ill %ind a ne tool bar Once you have sucess%ully installed the plu!in you and menu entry in your M*&ord install. Prior to startin! the examples you should do nload this plu!in and install it. <ou associated ill also need to do nload and unpac" the +ip %ile ith this article. 't ill ta"e you %rom a simple listin! report to a complete report layout inlcudin! headers$ %ooters$ ima!es$ master1detail relationships and conditional %ormattin! all %rom the com%ort o% an M*&ord inter%ace. Deployin! 1 hether you2re usin! 3/* or Online or you have plu!!ed XML Publisher into your o n application deployment is simple.6 and can be %ound by do nloadin! patch 7689:.0"?> <ROWSET> <ROW num="1"> <EMPNO>100</EMPNO> <ENAME> o !lo""s</ENAME> < O!>#$ER%</ O!> <SA$>100</SA$> <&NAME>A##O'NT(N)</&NAME> </ROW> <ROW num="*"> <EMPNO>100</EMPNO> . )ll o% the %ollo in! report %ormats are based on 3mployeeListin!. There are options to deploy datasources and templates to either the %ilesystem or the database.6. This is available %rom metalin"$ the latest version is 6. Preliminary !etup To aid in the buildin! o% 4T5 templates XML Publisher provides the XML Publisher Template /uilder %or M*&ord. Background / Overvie This article ill introduce the 4T5 template %ormats that can be used ith XML Publisher.
3mployeeListin!. </ROWSET> )s you can see the data is sho in! employee details and the department they in..<ENAME> +ne &oe</ENAME> < O!>#$ER%</ O!> <SA$>100</SA$> </ROW> . #igure &' (nsert )ield dialog . (o option$ this use the 'nsert > 5ield ill open a dialo! box sho in! the available %ields %rom the data. <ou con%irmation that the data has loaded success%ully..xml. or" "our #irst Template $ !imple Employee %etail The simplest output e could !enerate ould be to sho an employee and their ill !et details. *o open M*&ord and use the Data > Load XML data option on the Template /uilder toolbar and select the XML %ile . There is no master1detail relationship in the data$ it is completely =%lat2.
This is done so that a user can easily dra! and drop report ob0ects around the document havin! to and you2ll !et the 5ield Property dialo!$ no ithout orry about the =nuts and bolts2 o% the report. *elect the insertion point in the &ord document and then clic" on a %ield and then use the 'nsert button.(otice the list o% available %ields in the dialo!. #igure +' #orm #ield %ialog . This is the ob0ect that XML Publisher uses to store the mappin! to the XML element in the data. Double clic" on a %ield clic" on the @elp button and you2ll see the method XML Publisher uses to map to the data elements. &e can use this dialo! to enter these %ields into our report. ?sin! this method build a layout similar to the one belo add the boiler plate text as you !o. #igure *' !imple Employee %etail Template <ou2ll notice that as you use the insert button that Microso%t 5orm 5ields are bein! inserted into the document.
Le%t Pane . (3mployeeListin!9. This template lac"s the commands to loop over the employees and it there%ore only sho s the %irst record.' !imple Employee %etail Output Creat$ so no you have the %irst employee and their details but here are the e2ll add others %rom the XML data. <ou2ll !et somethin! li"e.rt%) -et your employees listing *o e ant to loop over the employees and !et all o% their data into the use output. (o select Previe > PD5 %rom the toolbar$ the template builder ill prompt ill you to save template as an 4T5 %ormat. (o the toolbar and select 'nsert > TableD5orm.this is the tar!et or document pane 4i!ht Pane .this has the Property palette and Previe re!ion ith the . Once this is done the template be applied to the data. (ext those commands. #igure . <ou2ll be presented %ollo in! dialo!$ notice it is made up o% three re!ions.this sho s the source XML tree Eenter Pane . Co bac" to M* &ord close your ori!inal document and create a ne one and load the data a!ain$ alternatively 0ust delete the content.(otice in this case e see AB3MP(OB>$ this tells the XML Publisher template parser that the 3MP(O element value should be inserted into the %inal document usin! =AB2 and =B>2 to delimit the element mappin!.
<ou2ll no ith the =4o 2 element at the top.#igure . To create the loopin! structure use your mouse and clic" on the =4o 2 node$ hold it do n and dra! it to the center pane and let !o.' (nsert Table/#orm dialog This dialo! is very po er%ul and allo s you to build either small parts o% a report layout or the complete report structure in one !o. *elect this node see the properties palette and previe re!ion %ill. ) popup ill as" i% you ant to drop a =*in!le tree structure (ode2 or =)ll (odes2$ select =)ll (odes2. see a ne ith your mouse and you .
The ill also notice t o extra %ields =52 and =32.4O&B> 1 4O& is the !roup in the XML and this command is sayin!$ H%or each member o% the 4O& !roup carry out the %ollo in! ie enter the %ields 3MP(O$ 3()M3$ etc 3 1 ABend %or1eachB> 1 this command closes the loop. The builder re!ular %orm %ields are still there but you put in some de%ault boilerplate based on the XML data element names. <ou2ll see the previe and use the delete "ey to remove it %rom the tree. The template ill then insert the necessary structures into your template. 5 1 AB%or1each. #igure 0' (nserted table structure (otice the data is no presented in a table$ there are t o ro s created$ one ill %or the column headers and the second %or the %orm %ields. These contain the loopin! commands. .#igure /' Properties and Previe Try chan!in! the =*tyle2 property and then clic"in! on the treeF you can speci%y =Table2$ =5orm2 and =5ree 5orm2. *elect =Table2 and then hi!hli!ht the =@num2 value hit OG. (o builder re!ion update based on your choices.
the department name.e. (3mployeeListin!I. 3ither create a ne document or delete the existin! content. @i!hli!ht the 4O& node and then on the Croupin! property drop do n select =D()M32 i. clic" bac" . *o e e no have a basic listin! report but lets say anted to !roup the employees by their department or 0ob. &e center pane i% needed.rt%) 1egroup your employees Our data does not re%lect this !roupin! but the template builder can help us to !roup the data in the template despite not havin! the supportin! structure in the data. This %eature is extremely po er%ul$ a !eneric =%lat2 extract can support many layout %ormats allo in! users to decide ho the data. *o no e are seein! all o% the employees details in a table. (o on the 4O& node and you2ll see the tree has been updated. &e are !oin! to ill use the they ant to see create a report that sho s the employees by department.(o previe this template in the %ormat o% your choice$ you2ll see the %ollo in!. same dialo! as be%ore$ so open it up$ 'nsert > TableD5orm and clear the Elic" and hold on the 4O& node and dra! to the center pane and =Drop )ll2$ remove the @num node.
e. #igure 3' 1egrouping template <ou can see the %amiliar table and its %ields but e no have t o extra %ields.#igure 2' 1egrouping dialog <ou2ll notice that the document tree has been updated to sho e have created. the . 3 1 ABend %or1each1!roupB> 1 this closes out the ne There has been another update$ the ori!inal =52 %ield no contains$ AB%or1 each. &e are node and chan!e the *tyle clic" OG and !oin! to have a simpler %ormat. The template ill no loop over this ne ly created !roup. C 1 AB%or1each1!roup. There is also a sort command to sort by the D()M3 as ell. 'n its current state the employee data e ill be a nested table the !roupin! ill have a Table in Table report ie ithin a department table.DD()M3B>ABsort. D()M3 !roup.current1!roup()B>$ this is sayin! loop over the current !roup i.4O&F. The sort criteria can be chan!ed usin! the property palette.D()M3FJascendin!JFdata1 typeKJtextJB> 1 this command is speci%yin! that the 4O& !roup should be then !rouped by D()M3. *elect the 4o clue as to the nature o% ho that node property to =5ree 5orm2$ notice the icon next to the node is updated to !ive a ill be rendered. (o you should !et template li"e.
5inally insert. Totals and tallies *o no e have imposed some !roupin! on our data e ant to "no ho e ant to add some sub totals$ lets say department and ho the XML data but much the salary cost is in each e are !oin! many employees are in each. Try previe in! this template and you2ll !et #igure &4' -rouping by department output &e have no created a report that sho s our employees by their department. e need to chec" the Croupin! box to let the builder "no e are creatin! a summary %ield on top o% the !rouped data and then clic" on . 5or this to !o bac" to the insert %ield dialo!. Lets insert the employee count %irst$ move the cursor to 0ust a%ter the D()M3 %ield$ then use the toolbar 'nsert > 5ield. &e could easily !roup them by their 0ob titles$ or even !roup by department and then by 0ob title.D()M3 !roup somethin! li"e. These values are not in e can create them in the template. e created above. *elect the 3MP(O %ield and then select =count2 %rom the Ealculation drop do n box.
(o create a ne ro in the employee table and move the cursor to the cell ith a under the *)L %ield. ?se the dialo! a!ain$ this time create a =sum2 on the *)L element$ don2t %or!et the Croupin! chec"box. #igure &*' !ummary column template (o previe your template and you2ll !et the %ollo in!. <ou should end up template li"e this.#igure &&' (nsert summary )ield <ou2ll see a ne %ield created$ =count3MP(O2$ this %ield contains the code to calculate the number o% employees$ ABcount(current1!roup()D3()M3)B>. .
e the department and employee data in the %irst set o% data then it somethin! li"e this. (o place the cursor 0ust be%ore the last =32 %ield and create another %ield$ this time enter =ABend i%B>2$ this closes the i% statement. %orm%ield$ you may need to enable the =5orm2 toolbar place the cursor 0ust a%ter the =C2 %ield and insert a %orm %ield. This command is basically chec"in! i% the D()M3 element has a value. 5onditional #ormatting <ou2ll probably have noticed that the report output has some employees that do not belon! to any department. *o i% the =i%2 statement is evaluated to true then the content bet een the =i%2 and =end i%2 statement i.D()M3LKMMB >2. <our template should loo" . <ou can create complex calculations in the template$ its up to you. Open the properties and then the help text and enter$ =ABi%. Let2s assume employees that do not have a department. ill be displayedF i% evaluated to %alse as ill not be sho .#igure &+' !ummary output <ou2ll notice e no have an employee number a%ter the department name and a total salary amount %or each department. &e can achieve this #uite simply e are !oin! to have to &e need to add a ne in M*&ord. The current release o% e ant to hide those the Template /uilder does not support insertin! conditional statements so rite some code by hand. (o ith an =i%2 statement.
' 5onditional template The output hen you run this template ill not contain those employees that ith a do not belon! to a department. %ressing 6p *o e no have the basic structure o% the report e ant$ e no need to add %ormattin! to ma"e it more readable.#igure &. 5or number %ormattin!$ a!ain e use M*&ord %unctionality. 5or this %unctionality. . 'ts up to you and your users. Double clic" on the *)L %ield to !et the %ield speci%y the %ield type to be =(umber2 and then pic" a 5ormat %rom the drop list$ you can enter a de%ault number in the =De%ault (umber2 %ield. e2ll use M*&ord <ou can update colors$ %onts$ styles hi!hli!htin! plain boiler plate and %ields$ XML Publisher dialo!$ no ill respect the %ormattin!. <ou could e#ually exclude employees salary !reater than 6NNN.
ABD()M3B>. #igure &. <ou can very #uic"ly build a report layout similar to.' #ormatted template This template ill no !enerate the %ollo in! output. #igure &/' #ormatted report output O% course i% you or your users template and update the layout. ill respect this at runtime. M*&ord ill not allo you to enter %orm %ields in the header or %ooter but you can enter the command strin! e.!. <ou2ll see the %ield value is no %ormatted accordin! to the ill also %ormat you speci%ied. <ou can also add pa!e numbers usin! the native M*&ord method. XML Publisher or" %or date %ormattin!. This <ou can update the header and %ooter tooF add boiler plate$ ima!es$ etc. ant to ma"e a chan!e then 0ust reopen the .(o clic" OG.
. 5onclusion This document has !iven you brie% introduction to the orld o% XML Publisher 4T5 templates$ it has hope%ully provided you a !limpse o% the po er o% XML Publisher and the %lexibility it provides to you and your users.%eployment Once you are happy the server ith your template its then a #uestion o% deployin! it to hether that be %or the 3 /usiness *uite$ Peopleso%t$ OD 3d ards or XML Publisher 3nterprise. There are many sample templates delivered ith the Template builder install and the ?ser to create other report ob0ects such as Cuide documentation covers ho charts$ shapes$ pa!e totals$ conditional %ormattin! ob0ects etc.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.