How to validate SQL Server 2008 XML typed datatype using XML SCHEMA COLLECTION

Leprachaun

New Member
Still learning about using XML in SQL Server 2008. It seems many of the examples I've seen demonstrating how to validate XML data using XML Schema Collection are validating XML of a known size. My problem is that the XML data that I'm working with can have 'X' number of Kit elements. The validation works fine if there is just one kit, but if multiple \[code\]<xsd:element name="Kit">\[/code\] elements are in the XML then I get error:\[quote\] XML Validation: Unexpected element(s): Kit. Location: /:KitStatus[1]/:Kits[1]/:Kit[2]*\[/quote\]My code:\[code\]CREATE XML SCHEMA COLLECTION [dbo].[KitStatusSchema] AS N'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:element name="KitStatus" > <xsd:complexType> <xsd:sequence> <xsd:element name="ClientID"/> <xsd:element name="Kits"> <xsd:complexType> <xsd:sequence> <xsd:element name="NumberofKits"/> <xsd:element name="Kit"> <xsd:complexType> <xsd:sequence> <xsd:element name="PackageNumber"/> <xsd:element name="KitNumber"/> <xsd:element name="LocationNumber"/> <xsd:element name="Status"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType></xsd:element></xsd:schema>\[/code\]Is it possible for the validation to validate 1 or multiple Kits?
 
Back
Top