Talking about the features of XML Reporting is one thing, but let's see what it takes to actually generate an XML report. We're going to exercise most of the basic features of the XML Report tool, including conditional and looping constructs.
Our goal with this report will be to show the shirts in stock. Throughout this entire stylesheet design process, notice we don't actually care whether the report will be going to become a web page in HTML or a PDF document. We actually don't have to decide that at all, until we need the actual output.
Here's a portion of our input data:
Assign an XML Data Source
There can be multiple data sources, with differing types. XML,
and flat file or text data can be mixed and merged
in any way. After doing
Build a List of XML Data
Just as a quick test, let's make sure that what we set up works. Drag the "item" from the tree over to the canvas, and choose "List" from the menu that pops up. Then drag "sku" from the tree over and plop it down next to the bullet. When that second menu appears, choose "Insert Value".
When you press the button, you should see:
Now, hit a couple of times to undo adding the list, and instead, let's start building our report.
Build a Table of XML Data
Let's start building out table. This is actually easier than building the list, since we can do it in one step. Drag "item" from the tree onto once-again blank canvas, and choose "Insert Table" and "Populate Columns" from the sub-menu. You will see something like this:
XML Report Headers and Footers
We should put headers on this report. So right-click anywhere in the table row and choose "Add Row Before". Notice that the repeat symbol does not expand to cover that row, showing that it won't be part of what repeats. Within each cell, type a description of the contents.
Something similar can be done for footers. And using the dynamic
property settings, the total can be expressed as an XPath expression, like
Changing XML Report Properties
Each object in the report has various properties associated with it. And for composite components, such as tables, there are tiers of properties. This lets you set properties for the whole table, and override them by row or column or even cell.
Just to see this, go to the value element and set its "Text" property for "Alignment" to read "Center". Now running the report will show the "S", "M" or "L" centered instead of left-aligned.
Insert Images into the XML Report
Let's show the viewers of this report what the actual polo shirt colors look like.
(If you are following along, you might have trouble since you don't have the shirt images locally.
Click on the canvas outside of the table, and set the "Base URL" property to
Filtering XML Report Data
Adding the equivalent of a SQL WHERE-clause is as simple as modifying the XPath expression for the repeater.
Change the property from the default
XML Report If-Then-Else
Any component, from text to list to table, can also be inserted into an if-then-else component. The if construct is a special component with two boxes. Anything placed in the "then" box gets displayed only when the associated XPath is true. Otherwise, what is placed in the "else" box gets displayed.
For our example, we'll show a "NEW" image next to all of the small shirts, since our store has just started carrying that size.
XML Report Summary
Generate XSL-FO and HTML+CSS
When you're ready to use this report in production, you can save it as XSLT 1.0, XSLT 2.0 or XQuery. And you can choose the output format to be either HTML+CSS, or XML-FO — the latter of which can be directly post-processed into PDF.
Here's a view of the dialog that appears when you press the button:
PURCHASE STYLUS STUDIO ONLINE TODAY!!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Try Stylus Powerful XML Publishing Tools
Build XML Publishing applications with Stylus Studio® — Download a free trial today!
Learn XQuery in 10 Minutes!
Say goodbye to 10-minute abs, and say Hello to "Learn XQuery in Ten Minutes!", the world's fastest and easiest XQuery primer, now available for free!
Top Ten XQuery Trends
Read about the top 10 XQuery Trends and how they will impact change the way enterprise software applications are built.