For those interested in generating an xml document from Oracle that can then be used by a Windward template, here is a simple example. listed below is the syntax to created a sorted xml document two levels deep. You can create further levels of nested tags via more sub-selects. Note that the sort order is established as part of the XMLAGG function, not by the usual method of including the "order by" clause after the "where" clause in the SQL. Extend as appropriate. There is also a decent beginers guide at http://www.oracle-base.com/articles/9i/SQLXML9i.php
/* begin XML document */
select xmlelement("MyReportDataRoot", xmlelement("FlagsLvl1",
/* First Level Customer flags root */
(select xmlagg(xmlelement("CustFlag",XMLATTRIBUTEs(cf.flag_id),xmlforest(
cf.flag_id,
cf.flag_value
))order by cf.flag_id desc)
from packinglist pl
join customerflag cf on cf.company_code = pl.company_code
and cf.customer_number = pl.customer_number
and cf.category_id = '11'
where pl.company_code = &Company
and pl.site_code = &Site
and pl.packing_list_number = &PackingList
))
/* end of XML document */
).getCLOBVal() MyReportDataXML
from dual;