dbTalk Databases Forums  

CREATE XML SCHEMA COLLECTION - Expected XML schema document Error

microsoft.public.sqlserver.xml microsoft.public.sqlserver.xml


Discuss CREATE XML SCHEMA COLLECTION - Expected XML schema document Error in the microsoft.public.sqlserver.xml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
NMahmoud
 
Posts: n/a

Default CREATE XML SCHEMA COLLECTION - Expected XML schema document Error - 01-27-2010 , 06:31 PM






hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml, but I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthenticationHeader xmlns="http://tempuri.org/">
<Username>string</Username>
<Password>string</Password>
<Domain>string</Domain>
</AuthenticationHeader>
<RequestInfoParameters xmlns="http://tempuri.org/">
<ContentLanguage>int</ContentLanguage>
</RequestInfoParameters>
</soap:Header>
<soap:Body>
<DeleteUserByID xmlns="http://tempuri.org/">
<UserId>long</UserId>
</DeleteUserByID>
</soap:Body>
</soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr

Reply With Quote
  #2  
Old   
Bob
 
Posts: n/a

Default RE: CREATE XML SCHEMA COLLECTION - Expected XML schema document Error - 01-28-2010 , 05:45 AM






You need to pass it an XML Schema document, not just some XML, eg
example from BOL.

-- Create a sample database in which to load the XML schema collection.
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?>
<xsd:schema
targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns
="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

<xsd:complexType name="StepType" mixed="true" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="tool" type="xsd:string" />
<xsd:element name="material" type="xsd:string" />
<xsd:element name="blueprint" type="xsd:string" />
<xsd:element name="specs" type="xsd:string" />
<xsd:element name="diag" type="xsd:string" />
</xsd:choice>
</xsd:complexType>

<xsd:element name="root">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="Location" minOccurs="1"
maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="step" type="StepType"
minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="LocationID" type="xsd:integer"
use="required"/>
<xsd:attribute name="SetupHours" type="xsd:decimal"
use="optional"/>
<xsd:attribute name="MachineHours"
type="xsd:decimal" use="optional"/>
<xsd:attribute name="LaborHours" type="xsd:decimal"
use="optional"/>
<xsd:attribute name="LotSize" type="xsd:decimal"
use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces

-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- Clean up
DROP TABLE T
GO
DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
Go
USE Master
GO
DROP DATABASE SampleDB


Look at 'CREATE XML SCHEMA COLLECTION' in Books Online (BOL).

"NMahmoud" wrote:

Quote:
hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml, but I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?
soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:Header
AuthenticationHeader xmlns="http://tempuri.org/"
Username>string</Username
Password>string</Password
Domain>string</Domain
/AuthenticationHeader
RequestInfoParameters xmlns="http://tempuri.org/"
ContentLanguage>int</ContentLanguage
/RequestInfoParameters
/soap:Header
soap:Body
DeleteUserByID xmlns="http://tempuri.org/"
UserId>long</UserId
/DeleteUserByID
/soap:Body
/soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr





.

Reply With Quote
  #3  
Old   
NMahmoud
 
Posts: n/a

Default Re: CREATE XML SCHEMA COLLECTION - Expected XML schema document Error - 01-28-2010 , 11:33 AM



thanks Bob
your example worked perfectly fine,
but what I have is a soap message, and I am kind of new to xml, and not sure
if sql server would have a problem with that or not.
if I assign it to a xml variable, it will go through, so the server see it
as xml,
but can I create a schema collection for it or not, I am not sure.

thanks
Nabila



"Bob" <Bob (AT) discussions (DOT) microsoft.com> wrote

Quote:
You need to pass it an XML Schema document, not just some XML, eg
example from BOL.

-- Create a sample database in which to load the XML schema collection.
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?
xsd:schema
targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns
="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xsd:complexType name="StepType" mixed="true"
xsd:choice minOccurs="0" maxOccurs="unbounded"
xsd:element name="tool" type="xsd:string" /
xsd:element name="material" type="xsd:string" /
xsd:element name="blueprint" type="xsd:string" /
xsd:element name="specs" type="xsd:string" /
xsd:element name="diag" type="xsd:string" /
/xsd:choice
/xsd:complexType

xsd:element name="root"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="Location" minOccurs="1"
maxOccurs="unbounded"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="step" type="StepType"
minOccurs="1" maxOccurs="unbounded" /
/xsd:sequence
xsd:attribute name="LocationID" type="xsd:integer"
use="required"/
xsd:attribute name="SetupHours" type="xsd:decimal"
use="optional"/
xsd:attribute name="MachineHours"
type="xsd:decimal" use="optional"/
xsd:attribute name="LaborHours" type="xsd:decimal"
use="optional"/
xsd:attribute name="LotSize" type="xsd:decimal"
use="optional"/
/xsd:complexType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces

-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- Clean up
DROP TABLE T
GO
DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
Go
USE Master
GO
DROP DATABASE SampleDB


Look at 'CREATE XML SCHEMA COLLECTION' in Books Online (BOL).

"NMahmoud" wrote:

hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml, but
I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?
soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:Header
AuthenticationHeader xmlns="http://tempuri.org/"
Username>string</Username
Password>string</Password
Domain>string</Domain
/AuthenticationHeader
RequestInfoParameters xmlns="http://tempuri.org/"
ContentLanguage>int</ContentLanguage
/RequestInfoParameters
/soap:Header
soap:Body
DeleteUserByID xmlns="http://tempuri.org/"
UserId>long</UserId
/DeleteUserByID
/soap:Body
/soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr





.

Reply With Quote
  #4  
Old   
Bob
 
Posts: n/a

Default Re: CREATE XML SCHEMA COLLECTION - Expected XML schema document Er - 01-29-2010 , 04:16 AM



Open the XML file in Visual Studio and use the 'Create Schema' option from
the XML menu. Alternately cut the XSD by hand.

This will form the basis of your XML SCHEMA COLLECTION.

Use Books Online for further info:

http://msdn.microsoft.com/en-us/libr...6(SQL.90).aspx

"NMahmoud" wrote:

Quote:
thanks Bob
your example worked perfectly fine,
but what I have is a soap message, and I am kind of new to xml, and not sure
if sql server would have a problem with that or not.
if I assign it to a xml variable, it will go through, so the server see it
as xml,
but can I create a schema collection for it or not, I am not sure.

thanks
Nabila



"Bob" <Bob (AT) discussions (DOT) microsoft.com> wrote in message
news:8F76C336-15C5-4154-9418-EC99AF2F7467 (AT) microsoft (DOT) com...
You need to pass it an XML Schema document, not just some XML, eg
example from BOL.

-- Create a sample database in which to load the XML schema collection.
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?
xsd:schema
targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns
="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xsd:complexType name="StepType" mixed="true"
xsd:choice minOccurs="0" maxOccurs="unbounded"
xsd:element name="tool" type="xsd:string" /
xsd:element name="material" type="xsd:string" /
xsd:element name="blueprint" type="xsd:string" /
xsd:element name="specs" type="xsd:string" /
xsd:element name="diag" type="xsd:string" /
/xsd:choice
/xsd:complexType

xsd:element name="root"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="Location" minOccurs="1"
maxOccurs="unbounded"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="step" type="StepType"
minOccurs="1" maxOccurs="unbounded" /
/xsd:sequence
xsd:attribute name="LocationID" type="xsd:integer"
use="required"/
xsd:attribute name="SetupHours" type="xsd:decimal"
use="optional"/
xsd:attribute name="MachineHours"
type="xsd:decimal" use="optional"/
xsd:attribute name="LaborHours" type="xsd:decimal"
use="optional"/
xsd:attribute name="LotSize" type="xsd:decimal"
use="optional"/
/xsd:complexType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces

-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- Clean up
DROP TABLE T
GO
DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
Go
USE Master
GO
DROP DATABASE SampleDB


Look at 'CREATE XML SCHEMA COLLECTION' in Books Online (BOL).

"NMahmoud" wrote:

hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml, but
I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?
soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:Header
AuthenticationHeader xmlns="http://tempuri.org/"
Username>string</Username
Password>string</Password
Domain>string</Domain
/AuthenticationHeader
RequestInfoParameters xmlns="http://tempuri.org/"
ContentLanguage>int</ContentLanguage
/RequestInfoParameters
/soap:Header
soap:Body
DeleteUserByID xmlns="http://tempuri.org/"
UserId>long</UserId
/DeleteUserByID
/soap:Body
/soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr





.



.

Reply With Quote
  #5  
Old   
NMahmoud
 
Posts: n/a

Default Re: CREATE XML SCHEMA COLLECTION - Expected XML schema document Er - 02-04-2010 , 01:28 PM



than you Bob,
it worked

Nabila

"Bob" <Bob (AT) discussions (DOT) microsoft.com> wrote

Quote:
Open the XML file in Visual Studio and use the 'Create Schema' option from
the XML menu. Alternately cut the XSD by hand.

This will form the basis of your XML SCHEMA COLLECTION.

Use Books Online for further info:

http://msdn.microsoft.com/en-us/libr...6(SQL.90).aspx

"NMahmoud" wrote:

thanks Bob
your example worked perfectly fine,
but what I have is a soap message, and I am kind of new to xml, and not
sure
if sql server would have a problem with that or not.
if I assign it to a xml variable, it will go through, so the server see
it
as xml,
but can I create a schema collection for it or not, I am not sure.

thanks
Nabila



"Bob" <Bob (AT) discussions (DOT) microsoft.com> wrote in message
news:8F76C336-15C5-4154-9418-EC99AF2F7467 (AT) microsoft (DOT) com...
You need to pass it an XML Schema document, not just some XML, eg
example from BOL.

-- Create a sample database in which to load the XML schema collection.
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?
xsd:schema
targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns
="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xsd:complexType name="StepType" mixed="true"
xsd:choice minOccurs="0" maxOccurs="unbounded"
xsd:element name="tool" type="xsd:string" /
xsd:element name="material" type="xsd:string" /
xsd:element name="blueprint" type="xsd:string" /
xsd:element name="specs" type="xsd:string" /
xsd:element name="diag" type="xsd:string" /
/xsd:choice
/xsd:complexType

xsd:element name="root"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="Location" minOccurs="1"
maxOccurs="unbounded"
xsd:complexType mixed="true"
xsd:sequence
xsd:element name="step" type="StepType"
minOccurs="1" maxOccurs="unbounded" /
/xsd:sequence
xsd:attribute name="LocationID"
type="xsd:integer"
use="required"/
xsd:attribute name="SetupHours"
type="xsd:decimal"
use="optional"/
xsd:attribute name="MachineHours"
type="xsd:decimal" use="optional"/
xsd:attribute name="LaborHours"
type="xsd:decimal"
use="optional"/
xsd:attribute name="LotSize" type="xsd:decimal"
use="optional"/
/xsd:complexType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces

-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- Clean up
DROP TABLE T
GO
DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
Go
USE Master
GO
DROP DATABASE SampleDB


Look at 'CREATE XML SCHEMA COLLECTION' in Books Online (BOL).

"NMahmoud" wrote:

hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml,
but
I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?
soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:Header
AuthenticationHeader xmlns="http://tempuri.org/"
Username>string</Username
Password>string</Password
Domain>string</Domain
/AuthenticationHeader
RequestInfoParameters xmlns="http://tempuri.org/"
ContentLanguage>int</ContentLanguage
/RequestInfoParameters
/soap:Header
soap:Body
DeleteUserByID xmlns="http://tempuri.org/"
UserId>long</UserId
/DeleteUserByID
/soap:Body
/soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr





.



.

Reply With Quote
  #6  
Old   
jacobsebastian
 
Posts: n/a

Default Re: CREATE XML SCHEMA COLLECTION - Expected XML schema document Error - 02-19-2010 , 10:24 PM



NMahmoud wrote on 01/27/2010 19:31 ET :
Quote:
hi,

in SQL Server 2008,

I am trying to create a XML SCHEMA COLLECTION for the following xml, but I
am getting the error

Msg 2378, Level 16, State 1, Line 23
Expected XML schema document

any idea how can I do that!

thank you
Nabila


declare
@xmlStr xml

set @xmlStr = '<?xml version="1.0" encoding="utf-8"?
soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:Header
AuthenticationHeader xmlns="http://tempuri.org/"
Username>string</Username
Password>string</Password
Domain>string</Domain
/AuthenticationHeader
RequestInfoParameters xmlns="http://tempuri.org/"
ContentLanguage>int</ContentLanguage
/RequestInfoParameters
/soap:Header
soap:Body
DeleteUserByID xmlns="http://tempuri.org/"
UserId>long</UserId
/DeleteUserByID
/soap:Body
/soap:Envelope>'

CREATE XML SCHEMA COLLECTION Ekt_UserCreate AS @xmlStr
The XML you posted is not a valid XML Schema Document. I would suggest reading
this introductory article that explains how to create XML Schema Collections:
http://beyondrelational.com/xml/Type...llections.aspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.