Under the Hood

We talked early on in this book about the fact that the report definitions are stored using the Report Definition Language (RDL). RDL was created by Microsoft specifically for Reporting Services. Two things set this file structure apart from other Microsoft file structures, such as a Word document or an Excel spreadsheet. First, RDL is a published standard. Second, RDL is an Extensible Markup Language (XML) document.

Microsoft has gone public with the specifications for RDL. Third parties can create their own authoring environments for creating report definitions. If the RDL from these third-party tools conforms to the RDL standard, the reports created by these tools can be managed and distributed by Reporting Services.

The fact that RDL is an XML document means that you can actually look at a report definition in its raw form. If you try that with a Word document or an Excel spreadsheet, you will see nothing but gibberish. If you were so inclined, you could use Notepad to open an RDL file and look at its contents. In fact, you don’t even need Notepad. You can look at the contents of an RDL file right in Visual Studio.

Viewing the RDL

Right-click the entry for Overtime.rdl in the Solution Explorer and then select View Code from the context menu. You will see a new tab in the layout area called “Overtime.rdl [XML].” This tab contains the actual RDL of the report, as shown in Figure 7-14.

click to expand
Figure 7-14: The RDL for the Overtime Report

XML Structure

Because the RDL is an XML document, it is made up of pairs of tags. There is a begin tag at the beginning of an item and an end tag at the end of the item. A begin tag is simply a string of text, the tag name, with “<” at the front and “>” at the back. An end tag is the same string of text with “</” at the front and “>” at the back. This pair of tags creates an XML element. The information in between the two tags is the value for that element. In the following example, the Height element has a value of 0.625in:


There can never be a begin tag without an end tag, and vice versa. In fact, it can be said that XML is the Noah’s Ark of data structures, because everything must go two by two.

In addition to simple strings of text, XML elements can contain other elements. In fact, a number of elements can nest one inside the other to form complex structures. Here’s an example:

<Textbox>   <Style>     <Color>DarkBlue</Color>   </Style> </Textbox>

In some cases, begin tags contain additional information in the form of attributes. An attribute comes in the form of an attribute name, immediately following the tag name, followed by an equal sign (=) and the value of the attribute. In this example, the Textbox element has an attribute called Name with a value of “tmpl_Name”:

<Textbox Name="tmpl_Name">…</Textbox> 

The RDL contains several sections: the page header, the body, the data sources, the datasets, the embedded images, the page footer, and the report parameters. Each section starts with a begin tag and is terminated by an end tag. For example, the page header section of the RDL starts with <PageHeader> and is terminated by </PageHeader>.

In Figure 7-14, you can see the entire XML structure for the text box we placed in the page header. The begin tag of the text box includes a Name attribute. This corresponds to the Name property of the text box. In between the begin and end tags of the text box element are additional elements, such as FontSize, Color, and Width. These elements correspond to the other properties of this text box. Only those properties that have been changed from their default values are stored in the RDL.

Editing the RDL

One other interesting thing about viewing the RDL in Visual Studio is the fact that you can make changes to the RDL and have them affect the report design. Find the Color element within the tmpl_Name Textbox element, as shown in Figure 7-15. Replace DarkBlue with Red. Right-click the entry for Overtime.rdl in the Solution Explorer and then select View Designer from the context menu. You will notice that the text in the page header is now red. (It is pretty hard to miss!) You will probably want to change this back to dark blue, although if you like red, you can leave it as is.

click to expand
Figure 7-15: The Color element within the tmpl_Name Textbox element

If you do find a reason to make modifications directly to the RDL, do so with care. If you break up a begin/end pair or enter an invalid value for a property element (such as puce for a color), you can end up with a report that will not load in the report designer. Save your work immediately before making changes directly to the RDL. In just about every case, however, the designer works better for making changes to a report layout, so do your editing there.

Microsoft SQL Server 2000 Reporting Services
Microsoft SQL Server 2000 Reporting Services Step by Step (Pro-Step by Step Developer)
ISBN: 0735621063
EAN: 2147483647
Year: 2003
Pages: 109

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net