I have a SQL table with a XML column defined as follows:
ID int
FooType nvarchar(255)
FooXML xml(CONTENT dbo.FooXMLSchemaCollection)
The schema (FooXMLSchemaCollection) is defined as:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://ift.tt/tphNwY"
xmlns:t="http://ift.tt/1uCoKyg"
targetNamespace="http://ift.tt/1uCoKyg"
elementFormDefault="qualified">
<xsd:element name="item">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="key">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="string" type="xsd:string" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="value">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="ArrayOfString">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="string" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
I'm trying to insert some test data into the table. The XML I'm trying to insert looks like this:
<item>
<key>
<string>Attributes</string>
</key>
<value>
<ArrayOfString xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY">
<string>fieldName1</string>
<string>fieldName2</string>
<string>fieldName3</string>
<string>fieldName4</string>
<string>fieldName5</string>
<string>fieldName6</string>
</ArrayOfString>
</value>
</item>}
I'm trying to the following into the database through SSMS:
INSERT INTO tblLabelInfo
([ID] ,[FooType],[FooXML])
VALUES
(1, 'SampleInstance',
N'<?xml version="1.0" encoding="utf-16"?><item><key><string>Attributes</string></key><value><ArrayOfString xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY"><string>fieldName1</string><string>fieldName2</string><string>fieldName3</string><string>fieldName4</string><string>fieldName5</string><string>fieldName6</string></ArrayOfString></value></item>')
I get the following error message in SSMS:
Msg 6913, Level 16, State 1, Line 1
XML Validation: Declaration not found for element 'item'. Location: /*:item[1]
What am I missing/doing wrong here?
Thanks, JohnB
No comments:
Post a Comment