XML Validation: Declaration not found for element

  • 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

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply