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


C# XmlSchema.FindSchemaType方法代码示例

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


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

示例1: CollectSchemaComponent

		private void CollectSchemaComponent (ValidationEventHandler h, XmlSchema schema)
		{
			if (CollectProcessId == schema.CompilationId)
				return;
			// Below are already contributed by Compile():
			// {name}, {namespace} => QualifiedName, QNameInternal
			// {abstract} => ValidatedIsAbstract
			// {prohibited substitutions} => BlockResolved
			// {final} => FinalResolved
			// {annotations} => Annotation (XmlSchemaAnnotated)

			// Below are different properties depending on simpleContent | complexContent.
			// {base type definition}
			// {derivation method}
			// {attribute uses} => AttributeUses (later)
			// {attribute wildcard} => AttributeWildcard (later)
			// {content type}


			// {base type definition} => baseSchemaTypeInternal (later)
			if (contentModel != null) {
				BaseSchemaTypeName = contentModel.Content != null ? contentModel.Content.GetBaseTypeName () : XmlQualifiedName.Empty;

				BaseXmlSchemaTypeInternal = schema.FindSchemaType(BaseSchemaTypeName);
			}
			// Resolve redefine.
			if (this.isRedefineChild && BaseXmlSchemaType != null && this.QualifiedName == BaseSchemaTypeName) {
				XmlSchemaType redType = (XmlSchemaType) redefinedObject;
				if (redType == null)
					error (h, "Redefinition base type was not found.");
				else
					BaseXmlSchemaTypeInternal = redType;
			}

			// {derivation method} => resolvedDerivedBy
			if (contentModel != null && contentModel.Content != null) {
				resolvedDerivedBy =
					contentModel.Content.IsExtension ?
					XmlSchemaDerivationMethod.Extension :
					XmlSchemaDerivationMethod.Restriction;
			}
			else
				resolvedDerivedBy = XmlSchemaDerivationMethod.Empty;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:44,代码来源:XmlSchemaComplexType.cs

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

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