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 (firstname.lastname@example.org) 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.
'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. )lternatively you can do nload %rom the Oracle *tore site by searchin! %or XML Publisher.xml. <?xml version="1.6 and can be %ound by do nloadin! patch 7689:. Preliminary !etup To aid in the buildin! o% 4T5 templates XML Publisher provides the XML Publisher Template /uilder %or M*&ord.6. <ou associated ill also need to do nload and unpac" the +ip %ile ith this article. This is available %rom metalin"$ the latest version is 6. There are options to deploy datasources and templates to either the %ilesystem or the database. ill %ind a ne tool bar Once you have sucess%ully installed the plu!in you and menu entry in your M*&ord install. Deployin! 1 hether you2re usin! 3/* or Online or you have plu!!ed XML Publisher into your o n application deployment is simple. Prior to startin! the examples you should do nload this plu!in and install it. Background / Overvie This article ill introduce the 4T5 template %ormats that can be used ith XML Publisher.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> 2 . )ll o% the %ollo in! report %ormats are based on 3mployeeListin!.
(o option$ this use the 'nsert > 5ield ill open a dialo! box sho in! the available %ields %rom the data. </ROWSET> )s you can see the data is sho in! employee details and the department they in.. <ou con%irmation that the data has loaded success%ully.xml.. *o open M*&ord and use the Data > Load XML data option on the Template /uilder toolbar and select the XML %ile . or" "our #irst Template $ !imple Employee %etail The simplest output e could !enerate ould be to sho an employee and their ill !et details. #igure &' (nsert )ield dialog 3 .3mployeeListin!.<ENAME> +ne &oe</ENAME> < O!>#$ER%</ O!> <SA$>100</SA$> </ROW> . There is no master1detail relationship in the data$ it is completely =%lat2.
*elect the insertion point in the &ord document and then clic" on a %ield and then use the 'nsert button. 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. Double clic" on a %ield clic" on the @elp button and you2ll see the method XML Publisher uses to map to the data elements. #igure +' #orm #ield %ialog 4 . ?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. This is the ob0ect that XML Publisher uses to store the mappin! to the XML element in the data.(otice the list o% available %ields in the dialo!. &e can use this dialo! to enter these %ields into our report.
Le%t Pane .this sho s the source XML tree Eenter Pane . <ou2ll be presented %ollo in! dialo!$ notice it is made up o% three re!ions. #igure . <ou2ll !et somethin! li"e. (3mployeeListin!9.' !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.(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!.this is the tar!et or document pane 4i!ht Pane . (o the toolbar and select 'nsert > TableD5orm. Once this is done the template be applied to the data. This template lac"s the commands to loop over the employees and it there%ore only sho s the %irst record.this has the Property palette and Previe re!ion ith the 5 . (ext those commands. (o select Previe > PD5 %rom the toolbar$ the template builder ill prompt ill you to save template as an 4T5 %ormat.rt%) -et your employees listing *o e ant to loop over the employees and !et all o% their data into the use output. 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.
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. *elect this node see the properties palette and previe re!ion %ill.' (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. see a ne ith your mouse and you 6 . ) popup ill as" i% you ant to drop a =*in!le tree structure (ode2 or =)ll (odes2$ select =)ll (odes2. <ou2ll no ith the =4o 2 element at the top.#igure .
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. The template ill then insert the necessary structures into your template.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. #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. 7 . <ou2ll see the previe and use the delete "ey to remove it %rom the tree. The ill also notice t o extra %ields =52 and =32. (o builder re!ion update based on your choices. 5 1 AB%or1each.
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. 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. This %eature is extremely po er%ul$ a !eneric =%lat2 extract can support many layout %ormats allo in! users to decide ho the data. @i!hli!ht the 4O& node and then on the Croupin! property drop do n select =D()M32 i. &e are !oin! to ill use the they ant to see create a report that sho s the employees by department. &e center pane i% needed. the department name. (o on the 4O& node and you2ll see the tree has been updated.e. *o no e are seein! all o% the employees details in a table. 3ither create a ne document or delete the existin! content. clic" bac" 8 . *o e e no have a basic listin! report but lets say anted to !roup the employees by their department or 0ob.(o previe this template in the %ormat o% your choice$ you2ll see the %ollo in!. (3mployeeListin!I.
D()M3FJascendin!JFdata1 typeKJtextJB> 1 this command is speci%yin! that the 4O& !roup should be then !rouped by D()M3. C 1 AB%or1each1!roup. the 9 . 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.#igure 2' 1egrouping dialog <ou2ll notice that the document tree has been updated to sho e have created. The sort criteria can be chan!ed usin! the property palette.current1!roup()B>$ this is sayin! loop over the current !roup i. (o you should !et template li"e.DD()M3B>ABsort. The template ill no loop over this ne ly created !roup. D()M3 !roup.4O&F. #igure 3' 1egrouping template <ou can see the %amiliar table and its %ields but e no have t o extra %ields. '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. *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.e. There is also a sort command to sort by the D()M3 as ell.
e created above. &e could easily !roup them by their 0ob titles$ or even !roup by department and then by 0ob title. 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. Lets insert the employee count %irst$ move the cursor to 0ust a%ter the D()M3 %ield$ then use the toolbar 'nsert > 5ield.D()M3 !roup somethin! li"e. *elect the 3MP(O %ield and then select =count2 %rom the Ealculation drop do n box. These values are not in e can create them in the template. 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. 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 10 . 5inally insert. 5or this to !o bac" to the insert %ield dialo!.
(o create a ne ro in the employee table and move the cursor to the cell ith a under the *)L %ield. #igure &*' !ummary column template (o previe your template and you2ll !et the %ollo in!. 11 . <ou should end up template li"e this. ?se the dialo! a!ain$ this time create a =sum2 on the *)L element$ don2t %or!et the Croupin! chec"box.#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 can achieve this #uite simply e are !oin! to have to &e need to add a ne in M*&ord. <our template should loo" 12 . 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 i% the =i%2 statement is evaluated to true then the content bet een the =i%2 and =end i%2 statement i. (o ith an =i%2 statement. <ou can create complex calculations in the template$ its up to you. Let2s assume employees that do not have a department.#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 the department and employee data in the %irst set o% data then it somethin! li"e this. This command is basically chec"in! i% the D()M3 element has a value. ill be displayedF i% evaluated to %alse as ill not be sho .D()M3LKMMB >2. %orm%ield$ you may need to enable the =5orm2 toolbar place the cursor 0ust a%ter the =C2 %ield and insert a %orm %ield. 5onditional #ormatting <ou2ll probably have noticed that the report output has some employees that do not belon! to any department. Open the properties and then the help text and enter$ =ABi%. (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.
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. 5or number %ormattin!$ a!ain e use M*&ord %unctionality.#igure &. %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. <ou could e#ually exclude employees salary !reater than 6NNN. 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!. 5or this %unctionality. 'ts up to you and your users. 13 .' 5onditional template The output hen you run this template ill not contain those employees that ith a do not belon! to a department.
#igure &. ill respect this at runtime. ABD()M3B>. <ou can also add pa!e numbers usin! the native M*&ord method. #igure &/' #ormatted report output O% course i% you or your users template and update the layout. This <ou can update the header and %ooter tooF add boiler plate$ ima!es$ etc.(o clic" OG. M*&ord ill not allo you to enter %orm %ields in the header or %ooter but you can enter the command strin! e. ant to ma"e a chan!e then 0ust reopen the 14 .' #ormatted template This template ill no !enerate the %ollo in! output. XML Publisher or" %or date %ormattin!. <ou2ll see the %ield value is no %ormatted accordin! to the ill also %ormat you speci%ied.!. <ou can very #uic"ly build a report layout similar to.
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. 15 . 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.%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$ People*o%t$ OD 3d ards or XML Publisher 3nterprise.
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 listening from where you left off, or restart the preview.