本文整理汇总了C#中System.Xml.Schema.XmlSchema.FindElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchema.FindElement方法的具体用法?C# XmlSchema.FindElement怎么用?C# XmlSchema.FindElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchema
的用法示例。
在下文中一共展示了XmlSchema.FindElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
//.........这里部分代码省略.........