%@ page language="C#" masterpagefile="~/templates/Master1.master" inherits="Page"
keywords="XML Report, Report XML,XML Reporting, XML Report Generation, XML Report Generator,
XML Report Tutorial, XML Report Demo,XML Report Demonstration, XML Report Sample,Sample XML Report" %>
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: (For those of you who are more comfortable reading a schema, see shirts.dtd or shirts.xsd.) There can be multiple data sources, with differing types. XML,
EDI, relational
and flat file or text data can be mixed and merged
in any way. After doing 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 Now, hit 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: The symbol XML Reports
<inventory>
...
<item>
<name>polo shirt</name>
<size>S</size>
<color>green</color>
<sku>S004</sku>
<avail>199</avail>
</item>
Assign an XML Data Source
File|New|XML Report, we're going to click on
the
icon and choose
shirts.xml.Build a List of XML Data
button, you should see:
a couple of times
to undo adding the list, and instead, let's start building our report.Build a Table of XML Data

means
that the section its right will iterate, or repeat, for all values matching some XPath expression. This is used
for tables,
lists, and a special raw
repeater construct.
to see how things
are going.
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 sum(/inventory/item/avail).
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.

Let's show the viewers of this report what the actual polo shirt colors look like.
$itemconcat('shirt-', substring(sku, 2), '.gif')(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
http://www.stylusstudio.com/images/publish.)
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 /inventory/item to /inventory/item[avail > 0].
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.
size = "S"new.gifHere's how it will all look, after we've created a report, set filtering, and added images and conditional. A copy of the completed XML report called shirts.report is here.
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:

For more on this, see Single Source Publishing and the follow-on Multi-Channel Publishing.
Build XML Publishing applications with <%= ConfigurationManager.AppSettings["SS"] %> — Download a free trial today!
Read about the top 10 XQuery Trends and how they will impact change the way enterprise software applications are built.