SQL Server Reporting Services (SSRS) is a server based scalable and extensible platform for authoring, deploying, executing and managing reports based on a variety of data sources. SSRS allows us to create interactive, tabular, graphical (using data visualization controls) or free from reports from relational, multidimensional (using MDX or DMX) or XML data sources. Furthermore it allows you to view/export your reports in a variety of formats. You can set it to create report snapshots, which show data at a point of time or you can even subscribe to your published reports.
The scalability part of the platform comes from the fact that you can have multiple report servers for scale out deployment, set up in the Network Load Balancing (NLB) or some hardware based load balancing infrastructure for load balancing, whereas the extensibility comes from the fact that SSRS provides web services (APIs) for authoring, managing and customizing report processing and rendering programmatically. Apart from that, SSRS reports are defined in Report Definition Language (RDL), which is nothing but Extensible Markup Language (XML) adhering to a defined report definition language schema. In this article we are going to dive into this RDL and see some of the elements that you will notice in your report's RDL.
Report Definition Language (RDL)
When we use Report Designer or Report Builder to create reports, it defines the report in Report Definition Language (RDL), which is an XML representation adhering to a defined report definition language schema (defines where an RDL element should exist). For your reference, this RDL schema definition file is available on the installation media with the ReportDefinition.xsd file name or you can use http://<your report server name>/reportserver/reportdefinition.xsd link to view the schema definition. The schema is open and anyone can extend its capabilities. To learn more about the RDL schema, see Report Definition Language XML Schema.
The generated RDL has information such as data retrieval and report layout information. RDL is composed of XML elements, which could be either a simple or complex element. A simple element does not have attributes or child elements whereas a complex element does have child elements or might have attributes as well.
Apart from using existing the Report Designer or Report Builder tool for report authoring, you can even create your own custom tool to programmatically generate report's RDL based on its schema. To learn more about Report Definition Language, see Report Definition Language Reference.
Dissecting Report's RDL File
In this section, I am going to show you some of the elements from a report's RDL file for your understanding. We will not cover all elements that might appear in the RDL file as a report definition file is really huge and can be extended as well.
To the view RDL (or report XML), go to Solution Explorer, right click on the report and click on the View Code menu item as shown below:
Figure 1 - Viewing RDL
Report is the top most element or root element, which has all of the child elements or elements required for processing of the reports, elements required to define the layout of the report, etc. as you can see below:
Figure 2 - RDL - Report Element
Inside the DataSources element you will have multiple DataSource elements for each data source you have defined in the report. Each DataSource element contains DataProvider, ConnectionString, SecurityType, etc. as you can see below:
Figure 3 - RDL - DataSources Element
Inside the DataSets element you will have multiple Dataset elements for each data set you have defined in the report. Each Dataset element contains Query and Fields element. Inside the Fields element you will have multiple field elements, which maps the database field as you can see below:
Figure 4 - RDL - DataSets Element
If you have specified any filter in your dataset, you will notice the Filters element inside the DataSet element. Inside the Filters element, there would be multiple Filter elements for each filter defined in the dataset and inside each Filter element, there would FilterExpression, Operator, and FilterValues as you can see below:
Figure 5 - RDL - Filters Element
As you might be aware, you can even have shared dataset in your reports and hence a SharedDataSet element will appear for each shared dataset in your report RDL referencing the shared dataset as you can see below:
Figure 6 - RDL - SharedDataSet Element
The Page element inside the Report root element dictates the layout of the report page. Some of the elements that it contains are PageHeader, PageFooter, PageHeight, PageWidth etc. as you can see below:
Figure 7 - RDL - Page Element
Inside the Report element you will notice the Body element, which contains ReportItems, Height and Style elements. The ReportItems actually specifies the content of the report. ReportItem contains data region like Tablix, Image, SubReport, Line, Chart, Gauge, Rectangle etc. You'll even notice a report item is available inside another one if you have nested controls on the report. In the image below you can see the Tablix report item as I have added a tablix on the report and Tablix row for tablix header.
Figure 8 - RDL - ReportItems Element
In the image below you can see a Tablix row for tablix detail row. You'll also notice the mapping of column of the tablix row with dataset column value.
Figure 9 - RDL - ReportItems Element mapping with DataSet
As you might have guessed, you can edit the RDL file directly as per your need but it's not recommended practice because it (changed RDL file) might not get validated against the RDL schema (during report processing and will fail) because of any inadvertent manual change in the RDL file. Hence, you should either use the Report Designer or Report Builder tool or create your own custom tool for generating RDL files.
In this article I talked about the Report Definition Language architecture of SSRS, how to view it and about some of the elements from this RDL file. I also talked about RDL schema file against which RDL files are validated.