Why does this XDocument fail validation?

freak104

New Member
Given the schema (anonymised, the key points of interest are renamed and the rest omitted):\[code\]<?xml version="1.0" encoding="utf-8"?><xs:schema id="inspec" targetNamespace="the_right_namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="inspec"> <xs:complexType> <xs:all> <xs:element name="a_scalar_property" type="xs:int"/> <xs:element name="a_collection_property"> <xs:complexType> <snip> </xs:complexType> </xs:element> <xs:element name="another_collection_property"> <xs:complexType> <snip> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element></xs:schema>\[/code\]and the instance (declared using VB xml literals):\[code\]Dim xDocument = <x:inspec xmlns:x='the_right_namespace'><a_collection_property/><another_collection_property/></x:inspec>\[/code\]validation fails with the message \[code\]The element 'inspec' in namespace 'the_right_namespace' has incomplete content. List of possible elements expected: 'a_scalar_property'.\[/code\]Why? The \[code\]all\[/code\] element, according to W3Schools:"The all element specifies that the child elements can appear in any order and that each child element can occur zero or one time."Omitting \[code\]a_scalar_property\[/code\] is the same as including it zero times. Why does this document fail to validate?And don't say things like 'post the full code' - this is not my IP and I have anonymised it for a good reason. There is very little else to it, and I have tested with this minimal example, it gives the same result.
 
Back
Top