Reputation: 5493
I'm looking into exporting SSRS reports in XML format for someone and we've encountered a situation where the rendered table XML contains an element for every instance of the Details row but where any cell is empty, the attribute is not added to the element.
I'd much prefer to use the ATOM data feed output instead, as this is much more robust, however they're adamant about using the XML output.
Example output:
<Details DateStamp="2012-01-01" Customers="56703" Sales="624" />
<Details DateStamp="2012-02-01" />
<Details DateStamp="2012-03-01" Customers="107271" Sales="3195" />
Does anyone know of any way to force the output attributes to display, even if they have no value? Or is this not possible in the XML format?
Ideally something like:
<Details DateStamp="2012-01-01" Customers="56703" Sales="624" />
<Details DateStamp="2012-02-01" Customer="" Sales="" />
<Details DateStamp="2012-03-01" Customers="107271" Sales="3195" />
Try this example query for a DataSet:
SELECT
'2012-01-01' as [DateStamp]
,56703 as [Customers]
,624 as [Sales]
UNION ALL
SELECT
'2012-02-01' as [DateStamp]
,NULL as [Customers]
,NULL as [Sales]
UNION ALL
SELECT
'2012-03-01' as [DateStamp]
,107271 as [Customers]
,3195 as [Sales]
Upvotes: 3
Views: 3416
Reputation: 1186
For each field in the Details row, set the property "DataElementOutput" to "Output." (This property is available in the properties pane when the field is selected.)
Rendering Data in Report Builder and SSRS
In the dataset query, if you substitute the NULL value using ISNULL([ColName],0) or ISNULL([ColName],'') and combine this with DataElementOutput=Output, this would include all attributes for all rows in the xml. It seems that the renderer treats NULLs as non-existant elements, rather than empty elements.
Upvotes: 2