![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 . |
#3
| |||
| |||
|
|
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 . |
#4
| |||
| |||
|
|
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 . . |
#5
| |||
| |||
|
|
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 . . |
#6
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |