SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


XML Validation: Declaration not found for element


XML Validation: Declaration not found for element

Author
Message
vox_cine
vox_cine
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 3
I am working with SQL Server 2008 and I am having issues with inserting xml data to a table.the error is:
Msg 6913, Level 16, State 1, Line 17
XML Validation: Declaration not found for element 'items'. Location: /*:items[1]

here is the query:
-- 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"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.openehr.org/v1"
targetNamespace="http://schemas.openehr.org/v1" elementFormDefault="qualified" version="v1.0.2"
id="BaseTypes.xsd">
<xs:complexType name="DATA_VALUE" abstract="true">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="DV_BOOLEAN">
<xs:complexContent>
<xs:extension base="DATA_VALUE">
<xs:sequence>
<xs:element name="value" type="xs:boolean"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DV_IDENTIFIER">
<xs:complexContent>
<xs:extension base="DATA_VALUE">
<xs:sequence>
<xs:element name="issuer" type="xs:string"/>
<xs:element name="assigner" type="xs:string"/>
<xs:element name="id" type="xs:string"/>
<xs:element name="type" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>' ;
GO


-- 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
DECLARE @data XML;

-- Element-centered XML
SET @data =
N'<items xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:type="ELEMENT" archetype_node_id=" at0000">
<name>
<value>id</value>
</name>
<value xsi:type="DV_IDENTIFIER">
<issuer>An ISSUER</issuer>
<assigner>An Assigner</assigner>
<id>0495557225</id>
<type>National Code</type>
</value>
</items>';

INSERT INTO T
VALUES (1000,@data );
-- Clean up
DROP TABLE T
GO
DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
Go
USE Master
GO
DROP DATABASE SampleDB


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search