当前位置: 首页>>代码示例>>C#>>正文


C# XmlSchema.IsNamespaceAbsent方法代码示例

本文整理汇总了C#中System.Xml.Schema.XmlSchema.IsNamespaceAbsent方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchema.IsNamespaceAbsent方法的具体用法?C# XmlSchema.IsNamespaceAbsent怎么用?C# XmlSchema.IsNamespaceAbsent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Schema.XmlSchema的用法示例。


在下文中一共展示了XmlSchema.IsNamespaceAbsent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Validate

		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if (IsValidated (schema.ValidationId))
				return errorCount;

			referencedGroup = schema.Groups [RefName] as XmlSchemaGroup;
			// it might be missing sub components.
			if (referencedGroup == null) {
				if (!schema.IsNamespaceAbsent (RefName.Namespace))
					error (h, "Referenced group " + RefName + " was not found in the corresponding schema.");
			}
			// See Errata E1-26: minOccurs=0 is now allowed.
			else if (referencedGroup.Particle is XmlSchemaAll && ValidatedMaxOccurs != 1)
				error (h, "Group reference to -all- particle must have schema component {maxOccurs}=1.");
			if (TargetGroup != null)
				TargetGroup.Validate (h, schema);

			ValidationId = schema.ValidationId;
			return errorCount;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:20,代码来源:XmlSchemaGroupRef.cs

示例2: ValidateDerivationValidRestriction

		internal void ValidateDerivationValidRestriction (XmlSchemaComplexType baseType,
			ValidationEventHandler h, XmlSchema schema)
		{
			// 1.
			if (baseType == null) {
				error (h, "Base schema type is not a complex type.");
				return;
			}
			if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
				error (h, "Prohibited derivation by restriction by base schema type.");
				return;
			}

			// 2.
			foreach (DictionaryEntry entry in this.AttributeUses) {
				XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
				XmlSchemaAttribute baseAttr = baseType.AttributeUses [attr.QualifiedName] as XmlSchemaAttribute;
				if (baseAttr != null) {
					// 2.1
					// 2.1.1
					if (baseAttr.ValidatedUse != XmlSchemaUse.Optional && attr.ValidatedUse != XmlSchemaUse.Required)
						error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
					// 2.1.2
					XmlSchemaSimpleType attrSimpleType = attr.AttributeType as XmlSchemaSimpleType;
					XmlSchemaSimpleType baseAttrSimpleType = baseAttr.AttributeType as XmlSchemaSimpleType;
					bool typeError = false;
					if (attrSimpleType != null)
						attrSimpleType.ValidateDerivationValid (baseAttrSimpleType, null, h, schema);
					else if (attrSimpleType == null && baseAttrSimpleType != null)
						typeError = true;
					else {
						Type t1 = attr.AttributeType.GetType ();
						Type t2 = baseAttr.AttributeType.GetType ();
						if (t1 != t2 && t1.IsSubclassOf (t2))
							typeError = true;
					}
					if (typeError)
						error (h, "Invalid attribute derivation by restriction because of its type: " + attr.QualifiedName + " .");
					// 2.1.3
					if (baseAttr.ValidatedFixedValue != null && attr.ValidatedFixedValue != baseAttr.ValidatedFixedValue)
						error (h, "Invalid attribute derivation by restriction because of its fixed value constraint: " + attr.QualifiedName + " .");
				} else {
					// 2.2
					if (baseType.AttributeWildcard != null)
						if (!baseType.AttributeWildcard.ValidateWildcardAllowsNamespaceName (
							attr.QualifiedName.Namespace, schema) &&
							!schema.IsNamespaceAbsent (attr.QualifiedName.Namespace))
							error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
				}
			}
			// I think 3. is considered in 2.
			// 4.
			if (this.AttributeWildcard != null && baseType != XmlSchemaComplexType.AnyType) {
				if (baseType.AttributeWildcard == null)
					error (h, "Invalid attribute derivation by restriction because of attribute wildcard.");
				else
					AttributeWildcard.ValidateWildcardSubset (baseType.AttributeWildcard, h, schema);
			}

			// 5.
			if (this == AnyType)
				return;
			if (contentTypeParticle == XmlSchemaParticle.Empty) {
				// 5.1
				if (ContentType != XmlSchemaContentType.Empty) {
					// TODO: 5.1.1
//					XmlSchemaSimpleType baseST = baseType as XmlSchemaSimpleType;
					// 5.1.2
					if (baseType.ContentType == XmlSchemaContentType.Mixed && !baseType.ContentTypeParticle.ValidateIsEmptiable ())
						error (h, "Invalid content type derivation.");

				} else {
					// 5.2
					if (baseType.ContentTypeParticle != XmlSchemaParticle.Empty &&
						!baseType.ContentTypeParticle.ValidateIsEmptiable ())
						error (h, "Invalid content type derivation.");
				}
			} else {
				// 5.3 => 3.9.6 Particle Valid (Restriction)
				if (baseType.ContentTypeParticle != null) {
					// 3.9.6 - 1 : same particle.
					// 3.9.6 - 2 is covered by using ActualParticle.
					if (!contentTypeParticle.ParticleEquals (baseType.ContentTypeParticle))
						contentTypeParticle.ValidateDerivationByRestriction (baseType.ContentTypeParticle, h, schema, true);
				}
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:87,代码来源:XmlSchemaComplexType.cs

示例3: Validate

		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if (IsValidated (schema.ValidationId))
				return errorCount;

			XmlSchemaType st = schema.FindSchemaType (baseTypeName);
			if (st != null) {
				XmlSchemaComplexType ct = st as XmlSchemaComplexType;
				if (ct != null && ct.ContentModel is XmlSchemaComplexContent)
					error (h, "Specified type is complex type which contains complex content.");
				st.Validate (h, schema);
				actualBaseSchemaType = st;
			} else if (baseTypeName == XmlSchemaComplexType.AnyTypeName) {
				actualBaseSchemaType = XmlSchemaComplexType.AnyType;
			} else if (XmlSchemaUtil.IsBuiltInDatatypeName (baseTypeName)) {
				actualBaseSchemaType = XmlSchemaDatatype.FromName (baseTypeName);
				if (actualBaseSchemaType == null)
					error (h, "Invalid schema datatype name is specified.");
			}
			// otherwise, it might be missing sub components.
			else if (!schema.IsNamespaceAbsent (baseTypeName.Namespace))
				error (h, "Referenced base schema type " + baseTypeName + " was not found in the corresponding schema.");

			ValidationId = schema.ValidationId;
			return errorCount;
		}
开发者ID:nobled,项目名称:mono,代码行数:26,代码来源:XmlSchemaSimpleContentExtension.cs

示例4: ValidateContentFirstPass

		private void ValidateContentFirstPass (ValidationEventHandler h, XmlSchema schema)
		{
			if (ContentModel != null) {
				errorCount += contentModel.Validate (h, schema);
				if (BaseXmlSchemaTypeInternal != null)
					errorCount += BaseXmlSchemaTypeInternal.Validate (h, schema);
			}
			else if (Particle != null) {
				errorCount += particle.Validate (h, schema);
				XmlSchemaGroupRef pgrp = Particle as XmlSchemaGroupRef;
				if (pgrp != null) {
					if (pgrp.TargetGroup != null)
						errorCount += pgrp.TargetGroup.Validate (h,schema);
					// otherwise, it might be missing sub components.
					else if (!schema.IsNamespaceAbsent (pgrp.RefName.Namespace))
						error (h, "Referenced group " + pgrp.RefName + " was not found in the corresponding schema.");
				}
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:19,代码来源:XmlSchemaComplexType.cs

示例5: ValidateContentModel

		private void ValidateContentModel (ValidationEventHandler h, XmlSchema schema)
		{
			XmlSchemaType baseType = BaseXmlSchemaTypeInternal;

			// Here we check 3.4.6 Properties Correct :: 2. and 3.
			XmlSchemaComplexContentExtension cce = contentModel.Content as XmlSchemaComplexContentExtension;
			XmlSchemaComplexContentRestriction ccr = contentModel.Content as XmlSchemaComplexContentRestriction;
			XmlSchemaSimpleContentExtension sce = contentModel.Content as XmlSchemaSimpleContentExtension;
			XmlSchemaSimpleContentRestriction scr = contentModel.Content as XmlSchemaSimpleContentRestriction;

			XmlSchemaAnyAttribute localAnyAttribute = null;
			XmlSchemaAnyAttribute baseAnyAttribute = null;

			// 3.4.6 Properties Correct :: 3. Circular definition prohibited.
			if (ValidateRecursionCheck ())
				error (h, "Circular definition of schema types was found.");
			if (baseType != null) {
				// Fill "Datatype" property.
				this.DatatypeInternal = baseType.Datatype;
			} else if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
				DatatypeInternal = XmlSchemaSimpleType.AnySimpleType;
			else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {
				DatatypeInternal = XmlSchemaDatatype.FromName (BaseSchemaTypeName);
			}

			XmlSchemaComplexType baseComplexType = baseType as XmlSchemaComplexType;
			XmlSchemaSimpleType baseSimpleType = baseType as XmlSchemaSimpleType;

			// 3.4.6 Derivation Valid (common to Extension and Restriction, Complex) :: 1.
			if (baseType != null && (baseType.FinalResolved & resolvedDerivedBy) != 0)
					error (h, "Specified derivation is specified as final by derived schema type.");

			// 3.4.6 Properties Correct :: 2.
			// Simple {base type definition} and restriction {derivation method} not allowed.
			if (baseSimpleType != null && resolvedDerivedBy == XmlSchemaDerivationMethod.Restriction)
				error (h, "If the base schema type is a simple type, then this type must be extension.");

			// Common to complexContent
			if (cce != null || ccr != null) {
				// 3.4.3 Complex Type Definition Representation OK :: 1.
				// base
				if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
					baseComplexType = XmlSchemaComplexType.AnyType;
				else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName))
					error (h, "Referenced base schema type is XML Schema datatype.");
				else if (baseComplexType == null && !schema.IsNamespaceAbsent (BaseSchemaTypeName.Namespace))
					error (h, "Referenced base schema type " + BaseSchemaTypeName + " was not complex type or not found in the corresponding schema.");
			}
			// Common to simpleContent 
			else {
				// ContentType of {content type}
				resolvedContentType = XmlSchemaContentType.TextOnly;

				// 3.4.3 Complex Type Definition Representation OK :: 1.
				// base
				if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
					baseComplexType = XmlSchemaComplexType.AnyType;

				if (baseComplexType != null && baseComplexType.ContentType != XmlSchemaContentType.TextOnly) {
					error (h, "Base schema complex type of a simple content must be simple content type. Base type is " + BaseSchemaTypeName);
				} else if (sce == null && (baseSimpleType != null && BaseSchemaTypeName.Namespace != XmlSchema.Namespace)) {
					error (h, "If a simple content is not an extension, base schema type must be complex type. Base type is " + BaseSchemaTypeName);
				} else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {
					// do nothing for particle.
				}
				// otherwise, it might be missing sub components.
				else if (baseType == null && !schema.IsNamespaceAbsent (BaseSchemaTypeName.Namespace))
					error (h, "Referenced base schema type " + BaseSchemaTypeName + " was not found in the corresponding schema.");

				// 3.4.3 Complex Type Definition Representation OK :: 2.
				// Note that baseSimpleType is also allowed as to Errata E1-27 (http://www.w3.org/2001/05/xmlschema-errata)
				if (baseComplexType != null) {
					if (baseComplexType.ContentType == XmlSchemaContentType.TextOnly) {
						// 2.1.1
					// Here "baseComplexType.Particle != null" is required for error-ignorant case
					} else if (scr != null && baseComplexType.ContentType == XmlSchemaContentType.Mixed && baseComplexType.Particle != null && baseComplexType.Particle.ValidateIsEmptiable () && scr.BaseType != null) {
						// 2.1.2 && 2.2: OK
					}
					else
						error (h, "Base complex type of a simple content restriction must be text only.");
				} else {
					if (sce != null && baseComplexType == null) {
						// 2.1.3 : OK
					}
					else
						error (h, "Not allowed base type of a simple content restriction.");
				}
			}

			// complexType/complexContent/extension
			if (cce != null) {
				// I don't think 3.4.6 Derivation Valid (Extension) :: 1.2
				// is constraining anything here, since 3.4.2 {attribute uses}
				// defines as to include base type's attribute uses.
				localAnyAttribute = cce.AnyAttribute;
				if (baseComplexType != null) {
					foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
						XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
						XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
					}
//.........这里部分代码省略.........
开发者ID:runefs,项目名称:Marvin,代码行数:101,代码来源:XmlSchemaComplexType.cs

示例6: Validate

		/// <summary>
		/// Schema Component: 
		///			QName, SimpleType, Scope, Default|Fixed, annotation
		/// </summary>
		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if(IsValidated (schema.ValidationId))
				return errorCount;

			// -- Attribute Declaration Schema Component --
			// {name}, {target namespace} -> QualifiedName. Already Compile()d.
			// {type definition} -> attributeType. From SchemaType or SchemaTypeName.
			// {scope} -> ParentIsSchema | isRedefineChild.
			// {value constraint} -> ValidatedFixedValue, ValidatedDefaultValue.
			// {annotation}
			// -- Attribute Use Schema Component --
			// {required}
			// {attribute declaration}
			// {value constraint}

			// First, fill type information for type reference
			if (SchemaType != null) {
				SchemaType.Validate (h, schema);
				attributeType = SchemaType;
			}
			else if (SchemaTypeName != null && SchemaTypeName != XmlQualifiedName.Empty)
			{
				// If type is null, then it is missing sub components .
				XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);
				if (type is XmlSchemaComplexType)
					error(h,"An attribute can't have complexType Content");
				else if (type != null) {	// simple type
					errorCount += type.Validate (h, schema);
					attributeType = type;
				}
				else if (SchemaTypeName == XmlSchemaComplexType.AnyTypeName)
					attributeType = XmlSchemaComplexType.AnyType;
				else if (XmlSchemaUtil.IsBuiltInDatatypeName (SchemaTypeName)) {
					attributeType = XmlSchemaDatatype.FromName (SchemaTypeName);
					if (attributeType == null)
						error (h, "Invalid xml schema namespace datatype was specified.");
				}
				// otherwise, it might be missing sub components.
				else if (!schema.IsNamespaceAbsent (SchemaTypeName.Namespace))
					error (h, "Referenced schema type " + SchemaTypeName + " was not found in the corresponding schema.");
			}

			// Then, fill type information for the type references for the referencing attributes
			if (RefName != null && RefName != XmlQualifiedName.Empty)
			{
				referencedAttribute = schema.FindAttribute (RefName);
				// If el is null, then it is missing sub components .
				if (referencedAttribute != null)
					errorCount += referencedAttribute.Validate (h, schema);
				// otherwise, it might be missing sub components.
				else if (!schema.IsNamespaceAbsent (RefName.Namespace))
					error (h, "Referenced attribute " + RefName + " was not found in the corresponding schema.");
			}

			if (attributeType == null)
				attributeType = XmlSchemaSimpleType.AnySimpleType;

			// Validate {value constraints}
			if (defaultValue != null || fixedValue != null) {
				XmlSchemaDatatype datatype = attributeType as XmlSchemaDatatype;
				if (datatype == null)
					datatype = ((XmlSchemaSimpleType) attributeType).Datatype;
				if (datatype.TokenizedType == XmlTokenizedType.QName)
					error (h, "By the defection of the W3C XML Schema specification, it is impossible to supply QName default or fixed values.");
				else {
					try {
						if (defaultValue != null) {
							validatedDefaultValue = datatype.Normalize (defaultValue);
							datatype.ParseValue (validatedDefaultValue, null, null);
						}
					} catch (Exception ex) {
						// FIXME: This is not a good way to handle exception.
						error (h, "The Attribute's default value is invalid with its type definition.", ex);
					}
					try {
						if (fixedValue != null) {
							validatedFixedValue = datatype.Normalize (fixedValue);
							validatedFixedTypedValue = datatype.ParseValue (validatedFixedValue, null, null);
						}
					} catch (Exception ex) {
						// FIXME: This is not a good way to handle exception.
						error (h, "The Attribute's fixed value is invalid with its type definition.", ex);
					}
				}
			}
			if (Use == XmlSchemaUse.None)
				validatedUse = XmlSchemaUse.Optional;
			else
				validatedUse = Use;

#if NET_2_0
			if (attributeType != null) {
				attributeSchemaType = attributeType as XmlSchemaSimpleType;
				if (attributeType == XmlSchemaSimpleType.AnySimpleType)
					attributeSchemaType = XmlSchemaSimpleType.XsAnySimpleType;
//.........这里部分代码省略.........
开发者ID:nobled,项目名称:mono,代码行数:101,代码来源:XmlSchemaAttribute.cs

示例7: GetActualType

		internal object GetActualType (ValidationEventHandler h, XmlSchema schema, bool validate)
		{
			object actualBaseSchemaType = null;

			XmlSchemaSimpleType type = baseType;
			if (type == null)
				type = schema.FindSchemaType (baseTypeName) as XmlSchemaSimpleType;
			if (type != null) {
				if (validate)
					errorCount += type.Validate (h, schema);
				actualBaseSchemaType = type;
			} else if (baseTypeName == XmlSchemaComplexType.AnyTypeName) {
				actualBaseSchemaType = XmlSchemaSimpleType.AnySimpleType;
			} else if (baseTypeName.Namespace == XmlSchema.Namespace ||
				baseTypeName.Namespace == XmlSchema.XdtNamespace) {
				actualBaseSchemaType = XmlSchemaDatatype.FromName (baseTypeName);
				if (actualBaseSchemaType == null)
					if (validate)
						error (h, "Invalid schema type name was specified: " + baseTypeName);
			}
			// otherwise, it might be missing sub components.
			else if (!schema.IsNamespaceAbsent (baseTypeName.Namespace))
				if (validate)
					error (h, "Referenced base schema type " + baseTypeName + " was not found in the corresponding schema.");

			return actualBaseSchemaType;
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:XmlSchemaSimpleTypeRestriction.cs

示例8: Validate

		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if (IsValidated (schema.ValidationId))
				return errorCount;

			// ListItemType
			XmlSchemaSimpleType type = itemType;
			if (type == null)
				type = schema.FindSchemaType (itemTypeName) as XmlSchemaSimpleType;
			if (type != null) {
				errorCount += type.Validate (h, schema);
				validatedListItemType = type;
			} else if (itemTypeName == XmlSchemaComplexType.AnyTypeName) {
				validatedListItemType = XmlSchemaSimpleType.AnySimpleType;
			} else if (XmlSchemaUtil.IsBuiltInDatatypeName (itemTypeName)) {
				validatedListItemType = XmlSchemaDatatype.FromName (itemTypeName);
				if (validatedListItemType == null)
					error (h, "Invalid schema type name was specified: " + itemTypeName);
			}
			// otherwise, it might be missing sub components.
			else if (!schema.IsNamespaceAbsent (itemTypeName.Namespace))
				error (h, "Referenced base list item schema type " + itemTypeName + " was not found.");

#if NET_2_0
			XmlSchemaSimpleType st = validatedListItemType as XmlSchemaSimpleType;
			if (st == null && validatedListItemType != null)
				st = XmlSchemaType.GetBuiltInSimpleType (((XmlSchemaDatatype) validatedListItemType).TypeCode);
			validatedListItemSchemaType = st;
#endif

			ValidationId = schema.ValidationId;
			return errorCount;
		}
开发者ID:user277,项目名称:mono,代码行数:33,代码来源:XmlSchemaSimpleTypeList.cs

示例9: Validate

		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if (IsValidated (schema.ValidationId))
				return errorCount;

			ArrayList al = new ArrayList ();
			// Validate MemberTypes
			if (MemberTypes != null) {
				foreach (XmlQualifiedName memberTypeName in MemberTypes) {
					object type = null;
					XmlSchemaType xstype = schema.FindSchemaType (memberTypeName) as XmlSchemaSimpleType;
					if (xstype != null) {
						errorCount += xstype.Validate (h, schema);
						type = xstype;
					} else if (memberTypeName == XmlSchemaComplexType.AnyTypeName) {
						type = XmlSchemaSimpleType.AnySimpleType;
					} else if (memberTypeName.Namespace == XmlSchema.Namespace ||
						memberTypeName.Namespace == XmlSchema.XdtNamespace) {
						type = XmlSchemaDatatype.FromName (memberTypeName);
						if (type == null)
							error (h, "Invalid schema type name was specified: " + memberTypeName);
					}
					// otherwise, it might be missing sub components.
					else if (!schema.IsNamespaceAbsent (memberTypeName.Namespace))
						error (h, "Referenced base schema type " + memberTypeName + " was not found in the corresponding schema.");

					al.Add (type);
				}
			}
			if (BaseTypes != null) {
				foreach (XmlSchemaSimpleType st in BaseTypes) {
					st.Validate (h, schema);
					al.Add (st);
				}
			}
			this.validatedTypes = al.ToArray ();

#if NET_2_0
			if (validatedTypes != null) {
				validatedSchemaTypes = new XmlSchemaSimpleType [validatedTypes.Length];
				for (int i = 0; i < validatedTypes.Length; i++) {
					object t = validatedTypes [i];
					XmlSchemaSimpleType st = t as XmlSchemaSimpleType;
					if (st == null && t != null)
						st = XmlSchemaType.GetBuiltInSimpleType (((XmlSchemaDatatype) t).TypeCode);
					validatedSchemaTypes [i] = st;
				}
			}
#endif

			ValidationId = schema.ValidationId;
			return errorCount;
		}
开发者ID:nobled,项目名称:mono,代码行数:53,代码来源:XmlSchemaSimpleTypeUnion.cs

示例10: Validate

		internal override int Validate(ValidationEventHandler h, XmlSchema schema)
		{
			if (IsValidated (schema.CompilationId))
				return errorCount;

			// See XML Schema Structures 3.6 for the complete description.

			// Element Declaration Properties Correct
			// 1. = 3.3.1 (modulo 5.3)

			// 3.3.1:
			// {annotation} is as is.
			// {name}, {target namespace}, {scope}, {disallowed substitution},
			// {substitution group exclusions} (handled the same as 'disallowed substitution')
			// and {identity-constraint-definitions} are Compile()d.
			// {value constraint} is going to be filled in step 2.

			// actual {nillable}, {abstract} 
			this.actualIsNillable = IsNillable;
			this.actualIsAbstract = IsAbstract;

			// Before determining element type, we need to validate substituting element
			if (this.SubstitutionGroup != XmlQualifiedName.Empty) {
				XmlSchemaElement substElem = substitutionGroupElement;
				if (substElem != null)
					substElem.Validate (h, schema);
			}

			// {type} from here
			XmlSchemaDatatype datatype = null;
			if (schemaType != null)
				elementType = schemaType;
			else if (SchemaTypeName != XmlQualifiedName.Empty) {
				XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);
				if (type != null) {
					type.Validate (h, schema);
					elementType = type;
				}
				else if (SchemaTypeName == XmlSchemaComplexType.AnyTypeName)
					elementType = XmlSchemaComplexType.AnyType;
				else if (XmlSchemaUtil.IsBuiltInDatatypeName (SchemaTypeName)) {
					datatype = XmlSchemaDatatype.FromName (SchemaTypeName);
					if (datatype == null)
						error (h, "Invalid schema datatype was specified.");
					else
						elementType = datatype;
				}
				// otherwise, it might be missing sub components.
				else if (!schema.IsNamespaceAbsent (SchemaTypeName.Namespace))
					error (h, "Referenced element schema type " + SchemaTypeName + " was not found in the corresponding schema.");
			}
			else if (RefName != XmlQualifiedName.Empty)
			{
				XmlSchemaElement refElem = schema.FindElement (RefName);
				// If el is null, then it is missing sub components .
				if (refElem != null) {
					this.referencedElement = refElem;
					errorCount += refElem.Validate (h, schema);
				}
				// otherwise, it might be missing sub components.
				else if (!schema.IsNamespaceAbsent (RefName.Namespace))
					error (h, "Referenced element " + RefName + " was not found in the corresponding schema.");
			}
			
			// Otherwise if there are substitution group, then the type of the substitution group element.
			if (referencedElement == null) {
				if (elementType == null && this.substitutionGroupElement != null)
					elementType = substitutionGroupElement.ElementType;
				// Otherwise, the -ur type- definition.
				if (elementType == null)
					elementType = XmlSchemaComplexType.AnyType;
			}

			XmlSchemaType xsType = elementType as XmlSchemaType;
			if (xsType != null) {
				errorCount += xsType.Validate (h, schema);
				datatype = xsType.Datatype;
			}
			// basic {type} is now filled, except for derivation by {substitution group}.

			// {substitution group affiliation}
			// 3. subsitution group's type derivation check.
			if (this.SubstitutionGroup != XmlQualifiedName.Empty) {
				XmlSchemaElement substElem = schema.FindElement (SubstitutionGroup);
				// If el is null, then it is missing sub components .
				if (substElem != null) {
					XmlSchemaType substSchemaType = substElem.ElementType as XmlSchemaType;
					if (substSchemaType != null) {
						// 3.3.6 Properties Correct 3.
						if ((substElem.FinalResolved & XmlSchemaDerivationMethod.Substitution) != 0)
							error (h, "Substituted element blocks substitution.");
						if (xsType != null && (substElem.FinalResolved & xsType.DerivedBy) != 0)
							error (h, "Invalid derivation was found. Substituted element prohibits this derivation method: " + xsType.DerivedBy + ".");
					}
					XmlSchemaComplexType xsComplexType = xsType as XmlSchemaComplexType;
					if (xsComplexType != null)
						xsComplexType.ValidateTypeDerivationOK (substElem.ElementType, h, schema);
					else {
						XmlSchemaSimpleType xsSimpleType = xsType as XmlSchemaSimpleType;
						if (xsSimpleType != null)
//.........这里部分代码省略.........
开发者ID:nobled,项目名称:mono,代码行数:101,代码来源:XmlSchemaElement.cs


注:本文中的System.Xml.Schema.XmlSchema.IsNamespaceAbsent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。