예제 #1
0
        internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError)
        {
            if (this == baseParticle)
            {
                return(true);
            }
            XmlSchemaElement xmlSchemaElement = baseParticle as XmlSchemaElement;

            if (xmlSchemaElement != null)
            {
                if (raiseError)
                {
                    base.error(h, "Invalid sequence paricle derivation.");
                }
                return(false);
            }
            XmlSchemaSequence xmlSchemaSequence = baseParticle as XmlSchemaSequence;

            if (xmlSchemaSequence != null)
            {
                return(this.ValidateOccurenceRangeOK(xmlSchemaSequence, h, schema, raiseError) && ((xmlSchemaSequence.ValidatedMinOccurs == 0m && xmlSchemaSequence.ValidatedMaxOccurs == 0m && base.ValidatedMinOccurs == 0m && base.ValidatedMaxOccurs == 0m) || base.ValidateRecurse(xmlSchemaSequence, h, schema, raiseError)));
            }
            XmlSchemaAll xmlSchemaAll = baseParticle as XmlSchemaAll;

            if (xmlSchemaAll != null)
            {
                XmlSchemaObjectCollection xmlSchemaObjectCollection = new XmlSchemaObjectCollection();
                for (int i = 0; i < this.Items.Count; i++)
                {
                    XmlSchemaElement xmlSchemaElement2 = this.Items[i] as XmlSchemaElement;
                    if (xmlSchemaElement2 == null)
                    {
                        if (raiseError)
                        {
                            base.error(h, "Invalid sequence particle derivation by restriction from all.");
                        }
                        return(false);
                    }
                    foreach (XmlSchemaObject xmlSchemaObject in xmlSchemaAll.Items)
                    {
                        XmlSchemaElement xmlSchemaElement3 = (XmlSchemaElement)xmlSchemaObject;
                        if (xmlSchemaElement3.QualifiedName == xmlSchemaElement2.QualifiedName)
                        {
                            if (xmlSchemaObjectCollection.Contains(xmlSchemaElement3))
                            {
                                if (raiseError)
                                {
                                    base.error(h, "Base element particle is mapped to the derived element particle in a sequence two or more times.");
                                }
                                return(false);
                            }
                            xmlSchemaObjectCollection.Add(xmlSchemaElement3);
                            if (!xmlSchemaElement2.ValidateDerivationByRestriction(xmlSchemaElement3, h, schema, raiseError))
                            {
                                return(false);
                            }
                        }
                    }
                }
                foreach (XmlSchemaObject xmlSchemaObject2 in xmlSchemaAll.Items)
                {
                    XmlSchemaElement xmlSchemaElement4 = (XmlSchemaElement)xmlSchemaObject2;
                    if (!xmlSchemaObjectCollection.Contains(xmlSchemaElement4) && !xmlSchemaElement4.ValidateIsEmptiable())
                    {
                        if (raiseError)
                        {
                            base.error(h, "In base -all- particle, mapping-skipped base element which is not emptiable was found.");
                        }
                        return(false);
                    }
                }
                return(true);
            }
            XmlSchemaAny xmlSchemaAny = baseParticle as XmlSchemaAny;

            if (xmlSchemaAny != null)
            {
                return(base.ValidateNSRecurseCheckCardinality(xmlSchemaAny, h, schema, raiseError));
            }
            XmlSchemaChoice xmlSchemaChoice = baseParticle as XmlSchemaChoice;

            return(xmlSchemaChoice == null || base.ValidateSeqRecurseMapSumCommon(xmlSchemaChoice, h, schema, false, true, raiseError));
        }