Error message when you try to browse a report in SQL Server 2005 Reporting Services: "The input XML is not well-formed" (914159)
The information in this article applies to:
- Microsoft SQL Server 2005 Reporting Services
SYMPTOMSWhen you try to browse a report in Microsoft SQL Server 2005 Reporting Services, you may receive an error message that is similar to the following: The input XML is not well-formed. One or more elements is missing a closing tag or has mismatched tags. (rsMalformedXml) Char, hexadecimal value AscCode, is an invalid character. Line 20, position 18. Note In this error message, Char is a placeholder for a nonprintable character. Additionally, AscCode is a placeholder for the character code of the nonprintable character. CAUSEThis problem occurs because a nonprintable character is populated into a report parameter that you define in the report.WORKAROUNDTo work around this problem, use one of the following methods: - Remove the nonprintable character from the available values for the report parameter.
- Convert the nonprintable character to the printable character in the available values for the report parameter. Then, convert the printable character back to the nonprintable character in the values for the query parameter.
Example workaroundThe following example shows how to work around this problem. In this example, the following assumptions are made: - The DEP report parameter is defined and is populated with nonprintable characters.
- The FirstName column contains nonprintable characters. The FirstName column is in both the Dataset1 dataset and the Dataset2 dataset.
- The available value for the DEP report parameter is from a query on the Dataset1 dataset.
- The value for the DEP report parameter is passed to the Dataset2 dataset as the @DEP parameter in the query string of the Dataset2 dataset.
- The range of character codes of the nonprintable characters that you experience is from 2 to 8.
- The MyEncodingFunc function and the MyDecodingFunc function are defined. The MyEncodingFunc function analyzes the input string. Based on the Strip parameter, the MyEncodingFunc function either converts the nonprintable characters to the <<Char(N)>> string or strips the nonprintable characters. The MyDecodingFunc function does the opposite.
Notes- A code example for the MyEncodingFunc function and for the MyDecodingFunc function is provided later in this article.
- N is a placeholder for the character code of the nonprintable character.
To work around this problem, follow these steps: - Put the code for the MyEncodingFunc function and for the MyDecodingFunc function in the Custom code box. A code example is provided later in this article. To access the Custom code box, follow these steps:
- On the Report menu, click Report Properties.
- Click the Code tab.
- Add a calculated field to the Dataset1 dataset. To do this, follow these steps:
- In the Datasets window, right-click the dataset, and then click Add.
- In the Name box, type a name. In this example, type the name MyCalculatedField.
- Click Calculated field, and then type = code.MyEncodingFunc(Fields!FirstName.Value,False).
- Click OK.
- Add another calculated field to the Dataset1 dataset. To do this, follow these steps:
- In the Datasets window, right-click the dataset, and then click Add.
- In the Name box, type a name. In this example, type the name MyDisplayField.
- Click Calculated field, and then type = code.MyEncodingFunc(Fields!ColumnName.Value,True).
- Click OK.
- On the Report menu, click Report Parameter.
- In the left pane, click the DEP report parameter.
- In the right pane, click MyCalculatedField in the value field list, and then click MyDisplayField in the label field list.
- Click OK.
- In Report Designer, click the Data tab, and then click Dataset2 in the Dataset list.
- Click the ellipsis button, and then click the Parameter tab.
- Define a new query parameter by specifying the name. In this example, type the name MyQParam. For the value of the MyQParam query parameter, type =Code.MyDecodingFunc(Parameters!DEP.Value).
- In the query string of the Dataset2 dataset, replace the @DEP parameter with the @MyQParam query parameter.
This example removes the nonprintable characters from the DEP report parameter. The DEP report parameter is displayed as a list. You can still see the nonprintable characters in the report for the FirstName column. To remove the nonprintable characters from the report for the FirstName column, follow these steps: - In Report Designer, click the Layout tab.
- Change the content of the detail row of the FirstName column from =Fields!FirstName.Value to =code.MyEncodingFunc(Fields!FirstName.Value,True).
The following code example is the code for the MyEncodingFunc function and for the MyDecodingFunc function. Public Function MyEncodingFunc(ByVal strIn, ByVal Strip) As String
'The value of the Strip parameter determines whether the nonprintable character is stripped from the input string.
Dim n As Integer
Dim resStr As String
Dim tempStr As String
resStr = ""
For n = 1 To Strings.Len(strIn)
tempStr = Mid(strIn, n, 1)
If ((Asc(tempStr) >= 2) And (Asc(tempStr) <= 8)) Then
If Strip = False Then
resStr = resStr + "<<Char(" + Convert.ToString(Asc(tempStr)) + ")>>"
End If
Else
resStr = resStr + tempStr
End If
Next
Return resStr
End Function
Public Function MyDecodingFunc(ByVal strIn) As String
Dim n As Integer
Dim resStr As String
Dim tempStr As String
resStr = ""
For n = 1 To Strings.Len(strIn)
If Mid(strIn, n, 7) = "<<Char(" Then
tempStr = ""
n = n + 7
Do Until Mid(strIn, n, 1) = ")"
tempStr = tempStr + Mid(strIn, n, 1)
n = n + 1
Loop
n = n + 2
resStr = resStr + Chr(Convert.ToInt32(tempStr))
Else
resStr = resStr + Mid(strIn, n, 1)
End If
Next
Return resStr
End Function
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 2/27/2006 |
---|
Keywords: | kbSqlClient kbsql2005rs kbExpertiseAdvanced kbtshoot kbprb KB914159 kbAudDeveloper kbAudITPRO |
---|
|