sequence minOccurs="0"

Jan 8, 2012 at 11:15 PM

hi,

i have a schema which contains a construct with <sequence minOccurs="0">. For elements with minOccurs="0" there is additional field "<elementname>Specified" available but there is nothing similar for a sequence.

Is there a way to find out if such a sequence is present in deserialized document?

In my concrete example, I am unable to figure out if NewAbstract is part of the document.

--pawel

 

Schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="example.com" targetNamespace="example.com" elementFormDefault="qualified">
  <xs:complexType name="snipped">
    <xs:sequence minOccurs="0">
      <xs:element name="NewAbstract" type="xs:boolean">
        <xs:annotation>
          <xs:documentation>If true, the class is considered abstract.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="OldAbstract" type="xs:boolean" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

 Generated:

    public partial class snipped {
        private bool newAbstractField;
        private bool oldAbstractField;
        private bool oldAbstractFieldSpecified;
        public bool NewAbstract {
            get {
                return this.newAbstractField;
            }
            set {
                this.newAbstractField = value;
            }
        }
        public bool OldAbstract {
            get {
                return this.oldAbstractField;
            }
            set {
                this.oldAbstractField = value;
            }
        }
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public bool OldAbstractSpecified {
            get {
                return this.oldAbstractFieldSpecified;
            }
            set {
                this.oldAbstractFieldSpecified = value;
            }
        }
    }