Search

sp_xml_preparedocument does not validate against DOCTYPE correctly. by Xnl28

Active

1
0
Sign in
to vote
Type: Bug
ID: 772233
Opened: 11/26/2012 7:59:23 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
SQL Server documentation on MSDN says that sp_xml_preparedocument validates against the DOCTYPE in an XML document (see example B at http://msdn.microsoft.com/en-us/library/ms187367(v=sql.105).aspx).

However, the example given in the Steps to Reproduce demonstrate sp_xml_preparedocument giving no error or message when pasing an invalid XML document.
Details (expand)

Product Language

English

Version

SQL Server 2008 R2 SP1

Category

XML Programmability

Operating System

Windows Server 2008 R2 Standard (SP1)

Operating System Language

English

Steps to Reproduce

Execute this T-SQL code.

DECLARE @hdoc int
DECLARE @doc varchar(2000)
SET @doc = '<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE root
[<!ELEMENT root (Customers)*>
<!ELEMENT Customers EMPTY>
<!ATTLIST Customers CustomerID CDATA #REQUIRED ContactName CDATA #IMPLIED>]>
<root>
<Customers ContactName="Maria Anders"/>
</root>'

EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc

SELECT    *
FROM     OPENXML (@hdoc, '/root/Customers',902384001)
            WITH (CustomerID varchar(10),
                 ContactName varchar(20))

EXEC sp_xml_removedocument @hdoc

Actual Results

CustomerID ContactName
---------- --------------------
NULL     Maria Anders

Expected Results

An error or warning message indicating that the DOCTYPE validation failed. The XML document is invalid because the required attribute CustomerID is missing.

Platform

X64

Virtualization

Hyper-V (On-Premise)
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.