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
-- 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:
> .
>
thanks
Nabila
"Bob" <B...@discussions.microsoft.com> wrote in message
news:8F76C336-15C5-4154...@microsoft.com...
This will form the basis of your XML SCHEMA COLLECTION.
Use Books Online for further info:
http://msdn.microsoft.com/en-us/library/ms187856(SQL.90).aspx
"NMahmoud" wrote:
> .
>
Nabila
"Bob" <B...@discussions.microsoft.com> wrote in message
news:D86A86DA-4EB8-42AA...@microsoft.com...