Contains() 공개 메소드

public Contains ( XmlSchemaObject item ) : bool
item XmlSchemaObject
리턴 bool
예제 #1
0
 void AddExternalComponentsTo(XmlSchema s, XmlSchemaObjectCollection items, ValidationEventHandler handler, List <CompiledSchemaMemo> handledUris, XmlResolver resolver, XmlSchemaSet col)
 {
     foreach (XmlSchemaExternal ext in s.Includes)
     {
         s.ProcessExternal(handler, handledUris, resolver, ext, col);
     }
     foreach (XmlSchemaObject obj in s.compilationItems)
     {
         items.Add(obj);
     }
     // Items might be already resolved (recursive schema imports), or might not be (other cases), so we add items only when appropriate here. (duplicate check is anyways done elsewhere)
     foreach (XmlSchemaObject obj in s.Items)
     {
         if (!items.Contains(obj))
         {
             items.Add(obj);
         }
     }
 }
예제 #2
0
        internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle,
                                                               ValidationEventHandler h, XmlSchema schema, bool raiseError)
        {
            if (this == baseParticle)             // quick check
            {
                return(true);
            }

            XmlSchemaElement el = baseParticle as XmlSchemaElement;

            if (el != null)
            {
                // Forbidden
                if (raiseError)
                {
                    error(h, "Invalid sequence paricle derivation.");
                }
                return(false);
            }

            XmlSchemaSequence seq = baseParticle as XmlSchemaSequence;

            if (seq != null)
            {
                // Recurse
                if (!ValidateOccurenceRangeOK(seq, h, schema, raiseError))
                {
                    return(false);
                }

                // If it is totally optional, then ignore their contents.
                if (seq.ValidatedMinOccurs == 0 && seq.ValidatedMaxOccurs == 0 &&
                    this.ValidatedMinOccurs == 0 && this.ValidatedMaxOccurs == 0)
                {
                    return(true);
                }
                return(ValidateRecurse(seq, h, schema, raiseError));
            }

            XmlSchemaAll all = baseParticle as XmlSchemaAll;

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

            if (any != null)
            {
                // NSRecurseCheckCardinality
                return(ValidateNSRecurseCheckCardinality(any, h, schema, raiseError));
            }
            XmlSchemaChoice choice = baseParticle as XmlSchemaChoice;

            if (choice != null)
            {
                // MapAndSum
                // In fact it is not Recurse, but it looks almost common.
                return(ValidateSeqRecurseMapSumCommon(choice, h, schema, false, true, raiseError));
            }
            return(true);
        }
예제 #3
0
파일: XmlSchema.cs 프로젝트: nestalk/mono
		void AddExternalComponentsTo (XmlSchema s, XmlSchemaObjectCollection items, ValidationEventHandler handler, List<CompiledSchemaMemo> handledUris, XmlResolver resolver, XmlSchemaSet col)
		{
			foreach (XmlSchemaExternal ext in s.Includes)
				s.ProcessExternal (handler, handledUris, resolver, ext, col);
			foreach (XmlSchemaObject obj in s.compilationItems)
				items.Add (obj);
			// Items might be already resolved (recursive schema imports), or might not be (other cases), so we add items only when appropriate here. (duplicate check is anyways done elsewhere)
			foreach (XmlSchemaObject obj in s.Items)
				if (!items.Contains (obj))
					items.Add (obj);
		}
예제 #4
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));
        }
예제 #5
0
		private void AddSubstElementRecursively (XmlSchemaObjectCollection col, XmlSchemaElement el)
		{
			if (el.SubstitutingElements != null)
				for (int i = 0; i < el.SubstitutingElements.Count; i++)
					this.AddSubstElementRecursively (col, el.SubstitutingElements [i] as XmlSchemaElement);
			if (!col.Contains (el))
				col.Add (el);
		}
예제 #6
0
		internal override bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
			ValidationEventHandler h, XmlSchema schema, bool raiseError)
		{
			if (this == baseParticle) // quick check
				return true;

			XmlSchemaElement el = baseParticle as XmlSchemaElement;
			if (el != null) {
				// Forbidden
				if (raiseError)
					error (h, "Invalid sequence paricle derivation.");
				return false;
			}

			XmlSchemaSequence seq = baseParticle as XmlSchemaSequence;
			if (seq != null) {
				// Recurse
				if (!ValidateOccurenceRangeOK (seq, h, schema, raiseError))
					return false;

				// If it is totally optional, then ignore their contents.
				if (seq.ValidatedMinOccurs == 0 && seq.ValidatedMaxOccurs == 0 &&
					this.ValidatedMinOccurs == 0 && this.ValidatedMaxOccurs == 0)
					return true;
				return ValidateRecurse (seq, h, schema, raiseError);
			} 

			XmlSchemaAll all = baseParticle as XmlSchemaAll;
			if (all != null) {
				// RecurseUnordered
				XmlSchemaObjectCollection already = new XmlSchemaObjectCollection ();
				for (int i = 0; i < this.Items.Count; i++) {
					XmlSchemaElement de = this.Items [i] as XmlSchemaElement;
					if (de == null) {
						if (raiseError)
							error (h, "Invalid sequence particle derivation by restriction from all.");
						return false;
					}
					foreach (XmlSchemaElement e in all.Items) {
						if (e.QualifiedName == de.QualifiedName) {
							if (already.Contains (e)) {
								if (raiseError)
									error (h, "Base element particle is mapped to the derived element particle in a sequence two or more times.");
								return false;
							} else {
								already.Add (e);
								if (!de.ValidateDerivationByRestriction (e, h, schema, raiseError))
									return false;
							}
						}
					}
				}
				foreach (XmlSchemaElement e in all.Items)
					if (!already.Contains (e))
						if (!e.ValidateIsEmptiable ()) {
							if (raiseError)
								error (h, "In base -all- particle, mapping-skipped base element which is not emptiable was found.");
							return false;
						}
				return true;
			}
			XmlSchemaAny any = baseParticle as XmlSchemaAny;
			if (any != null) {
				// NSRecurseCheckCardinality
				return ValidateNSRecurseCheckCardinality (any, h, schema, raiseError);
			}
			XmlSchemaChoice choice = baseParticle as XmlSchemaChoice;
			if (choice != null) {
				// MapAndSum
				// In fact it is not Recurse, but it looks almost common.
				return ValidateSeqRecurseMapSumCommon (choice, h, schema, false, true, raiseError);
			}
			return true;
		}