PRB: sp_xml_preparedocument Stored Procedure Fails with Error 6603 (279430)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q279430

SYMPTOMS

When you invoke the sp_xml_preparedocument stored procedure, the call fails with this error message:
Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedocument, Line 19 XML parsing error: A string literal was expected, but no opening quote character was found.

CAUSE

The sp_xml_preparedocument stored procedure was given an invalid XML document to process.

RESOLUTION

Correct the XML document passed into the sp_xml_preparedocument stored procedure for processing.

STATUS

The behavior is by design.

MORE INFORMATION

Users have requested that the program have the ability to provide the location within the XML document in which the error is located. Currently, this functionality does not exist. However, here is way you can determine where the error is occurring in your XML document:
  1. Save the XML document in a text file with an extension of .xml.
  2. Load that .xml document into Microsoft Internet Explorer 4.01 by browsing to the .xml file.

Steps to Reproduce Behavior

  1. Paste the following code into the SQL Server Query Analyzer, and then run the code:
    declare @hdoc int
    declare @doc varchar(1000)
    set @doc ='
    <ROOT>
    <Customers CustomerID="VINET" ContactName=123>
       <Orders CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
          <Order_0020_Details OrderID="10248" ProductID="11" Quantity="12"/>
          <Order_0020_Details OrderID="10248" ProductID="42" Quantity="10"/>
       </Orders>
    </Customers>
    <Customers CustomerID="LILAS" ContactName="Carlos Gonzlez">
       <Orders CustomerID="LILAS" EmployeeID="3"
    OrderDate="1996-08-16T00:00:00">
          <Order_0020_Details OrderID="10283" ProductID="72" Quantity="3"/>
       </Orders>
    </Customers>
    </ROOT>'
    --Create an internal representation of the XML document.
    exec sp_xml_preparedocument @hdoc OUTPUT, @doc
    exec sp_xml_removedocument @hDoc
    					


    This error message displays:
    Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedocument, Line 19 XML parsing error: A string literal was expected, but no opening quote character was found.
  2. Using the code in step 1, copy from the <ROOT> element to the </ROOT> element.
  3. Paste, and then save the text you copied from the XML document into a text file with an .xml extension.
  4. Open the .xml file you just saved by browsing the file with Internet Explorer. This error message occurs:
    A string literal was expected, but no opening quote character was found.
    Line 2, Position 43

    <Customers CustomerID="VINET" ContactName=123>

    ------------------------------------------^

Modification Type:MajorLast Reviewed:10/3/2003
Keywords:kbprb KB279430