When to Use XML with Reports
XML is not always the proper choice in reporting systems. It must be understood that its use includes an extra layer of processing beyond just programmatically converting a database ResultSet into the output desired. The difference resides in the speed at which these systems can be built because, if carefully created, the stylesheets are reusable across datasets, and fewer stored procedures have to be created.
DOM document models consume memory proportional to the size and complexity of the datasets being modeled. Database data will maintain the same complexity across ResultSets, but can be extremely large. The size of the data sets being used to create JDOMs must be considered when creating these systems, or some troubles will result.
In the next chapter an example of a paging report will be demonstrated. This report will only display a set maximum number of records per page, but it will create links that enable the rest of the data to be seen on different "pages" of the same report. This is one method of handling potentially large data sets. Another method is writing JavaBeans that will iterate through the ResultSet to create the desired output. In this way, the memory limitations of DOM will be avoided.
While SAX can be very useful in some reporting situations where there is a large amount of similarly formatted data, we are not using it here. This is because we are using the XSL sorting capabilities instead of sorting the data at the database.