internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); base.CompileOccurence(h, schema); if (this.Items.Count == 0) { base.warn(h, "Empty choice is unsatisfiable if minOccurs not equals to 0"); } foreach (XmlSchemaObject xmlSchemaObject in this.Items) { if (xmlSchemaObject is XmlSchemaElement || xmlSchemaObject is XmlSchemaGroupRef || xmlSchemaObject is XmlSchemaChoice || xmlSchemaObject is XmlSchemaSequence || xmlSchemaObject is XmlSchemaAny) { this.errorCount += xmlSchemaObject.Compile(h, schema); } else { base.error(h, "Invalid schema object was specified in the particles of the choice model group."); } } this.CompilationId = schema.CompilationId; return(this.errorCount); }
/// <remarks> /// 1. id must be of type ID /// 2. namespace can have one of the following values: /// a) ##any or ##other /// b) list of anyURI and ##targetNamespace and ##local /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } errorCount = 0; XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); wildcard.TargetNamespace = AncestorSchema.TargetNamespace; if (wildcard.TargetNamespace == null) { wildcard.TargetNamespace = ""; } CompileOccurence(h, schema); wildcard.Compile(Namespace, h, schema); if (processing == XmlSchemaContentProcessing.None) { wildcard.ResolvedProcessing = XmlSchemaContentProcessing.Strict; } else { wildcard.ResolvedProcessing = processing; } this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } if (nsmgr == null) { nsmgr = new XmlNamespaceManager(new NameTable()); if (Namespaces != null) { foreach (XmlQualifiedName qname in Namespaces.ToArray()) { nsmgr.AddNamespace(qname.Name, qname.Namespace); } } } currentPath = new XsdIdentityPath(); ParseExpression(xpath, h, schema); XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } this.errorCount = 0; if (this.ItemType != null && !this.ItemTypeName.IsEmpty) { base.error(h, "both itemType and simpletype can't be present"); } if (this.ItemType == null && this.ItemTypeName.IsEmpty) { base.error(h, "one of itemType or simpletype must be present"); } if (this.ItemType != null) { this.errorCount += this.ItemType.Compile(h, schema); } if (!XmlSchemaUtil.CheckQName(this.ItemTypeName)) { base.error(h, "BaseTypeName must be a XmlQualifiedName"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
public static XmlSchemaObject FindAttributeDeclaration(string ns, XmlSchemaSet schemas, XmlSchemaComplexType cType, XmlQualifiedName qname) { XmlSchemaObject xmlSchemaObject = cType.AttributeUses[qname]; if (xmlSchemaObject != null) { return(xmlSchemaObject); } if (cType.AttributeWildcard == null) { return(null); } if (!XmlSchemaUtil.AttributeWildcardItemValid(cType.AttributeWildcard, qname, ns)) { return(null); } if (cType.AttributeWildcard.ResolvedProcessContents == XmlSchemaContentProcessing.Skip) { return(cType.AttributeWildcard); } XmlSchemaAttribute xmlSchemaAttribute = schemas.GlobalAttributes[qname] as XmlSchemaAttribute; if (xmlSchemaAttribute != null) { return(xmlSchemaAttribute); } if (cType.AttributeWildcard.ResolvedProcessContents == XmlSchemaContentProcessing.Lax) { return(cType.AttributeWildcard); } return(null); }
///<remarks> /// 1. Content must be present and one of restriction or extention ///</remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } if (Content == null) { error(h, "Content must be present in a simpleContent"); } else { if (Content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction)Content; errorCount += xscr.Compile(h, schema); } else if (Content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension)Content; errorCount += xsce.Compile(h, schema); } else { error(h, "simpleContent can't have any value other than restriction or extention"); } } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); CompileOccurence(h, schema); if (Items.Count == 0) { this.warn(h, "Empty choice is unsatisfiable if minOccurs not equals to 0"); } foreach (XmlSchemaObject obj in Items) { if (obj is XmlSchemaElement || obj is XmlSchemaGroupRef || obj is XmlSchemaChoice || obj is XmlSchemaSequence || obj is XmlSchemaAny) { errorCount += obj.Compile(h, schema); } else { error(h, "Invalid schema object was specified in the particles of the choice model group."); } } this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } if (this.Name == null) { base.error(h, "Required attribute name must be present"); } else if (!XmlSchemaUtil.CheckNCName(this.name)) { base.error(h, "attribute name must be NCName"); } else { this.qualifiedName = new XmlQualifiedName(this.Name, base.AncestorSchema.TargetNamespace); } if (this.Public == null) { base.error(h, "public must be present"); } else if (!XmlSchemaUtil.CheckAnyUri(this.Public)) { base.error(h, "public must be anyURI"); } if (this.system != null && !XmlSchemaUtil.CheckAnyUri(this.system)) { base.error(h, "system must be present and of Type anyURI"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); return(this.errorCount); }
public static XmlQualifiedName ToQName(XmlReader reader, string qnamestr, out Exception innerEx) { innerEx = null; if (!XmlSchemaUtil.IsValidQName(qnamestr)) { innerEx = new Exception(qnamestr + " is an invalid QName. Either name or namespace is not a NCName"); return(XmlQualifiedName.Empty); } string[] array = qnamestr.Split(new char[] { ':' }, 2); string text; string name; if (array.Length == 2) { text = reader.LookupNamespace(array[0]); if (text == null) { innerEx = new Exception("Namespace Prefix '" + array[0] + "could not be resolved"); return(XmlQualifiedName.Empty); } name = array[1]; } else { text = reader.LookupNamespace(string.Empty); name = array[0]; } return(new XmlQualifiedName(name, text)); }
/// <remarks> /// 1. One of itemType or a <simpleType> must be present, but not both. /// 2. id must be of type ID /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } errorCount = 0; if (ItemType != null && !ItemTypeName.IsEmpty) { error(h, "both itemType and simpletype can't be present"); } if (ItemType == null && ItemTypeName.IsEmpty) { error(h, "one of itemType or simpletype must be present"); } if (ItemType != null) { errorCount += ItemType.Compile(h, schema); } if (!XmlSchemaUtil.CheckQName(ItemTypeName)) { error(h, "BaseTypeName must be a XmlQualifiedName"); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } this.errorCount = 0; this.wildcard.TargetNamespace = base.AncestorSchema.TargetNamespace; if (this.wildcard.TargetNamespace == null) { this.wildcard.TargetNamespace = string.Empty; } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.wildcard.Compile(this.Namespace, h, schema); if (this.processing == XmlSchemaContentProcessing.None) { this.wildcard.ResolvedProcessing = XmlSchemaContentProcessing.Strict; } else { this.wildcard.ResolvedProcessing = this.processing; } this.CompilationId = schema.CompilationId; return(this.errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } if (this.Content == null) { base.error(h, "Content must be present in a simpleContent"); } else if (this.Content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = (XmlSchemaSimpleContentRestriction)this.Content; this.errorCount += xmlSchemaSimpleContentRestriction.Compile(h, schema); } else if (this.Content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension = (XmlSchemaSimpleContentExtension)this.Content; this.errorCount += xmlSchemaSimpleContentExtension.Compile(h, schema); } else { base.error(h, "simpleContent can't have any value other than restriction or extention"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
/// <remarks> /// An Attribute group can only be defined as a child of XmlSchema or in XmlSchemaRedefine. /// The other attributeGroup has type XmlSchemaAttributeGroupRef. /// 1. Name must be present /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(errorCount); } errorCount = 0; if (redefinedObject != null) { errorCount += redefined.Compile(h, schema); if (errorCount == 0) { redefined = (XmlSchemaAttributeGroup)redefinedObject; } } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); if (this.Name == null || this.Name == String.Empty) //1 { error(h, "Name is required in top level simpletype"); } else if (!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2 { error(h, "name attribute of a simpleType must be NCName"); } else { this.qualifiedName = new XmlQualifiedName(this.Name, AncestorSchema.TargetNamespace); } if (this.AnyAttribute != null) { errorCount += this.AnyAttribute.Compile(h, schema); } foreach (XmlSchemaObject obj in Attributes) { if (obj is XmlSchemaAttribute) { XmlSchemaAttribute attr = (XmlSchemaAttribute)obj; errorCount += attr.Compile(h, schema); } else if (obj is XmlSchemaAttributeGroupRef) { XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef)obj; errorCount += gref.Compile(h, schema); } else { error(h, "invalid type of object in Attributes property"); } } this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } if (this.isRedefinedComponent) { if (base.Annotation != null) { base.Annotation.isRedefinedComponent = true; } if (this.AnyAttribute != null) { this.AnyAttribute.isRedefinedComponent = true; } foreach (XmlSchemaObject xmlSchemaObject in this.Attributes) { xmlSchemaObject.isRedefinedComponent = true; } } if (this.BaseTypeName == null || this.BaseTypeName.IsEmpty) { base.error(h, "base must be present, as a QName"); } else if (!XmlSchemaUtil.CheckQName(this.BaseTypeName)) { base.error(h, "BaseTypeName must be a QName"); } if (this.BaseType != null) { this.errorCount += this.BaseType.Compile(h, schema); } if (this.AnyAttribute != null) { this.errorCount += this.AnyAttribute.Compile(h, schema); } foreach (XmlSchemaObject xmlSchemaObject2 in this.Attributes) { if (xmlSchemaObject2 is XmlSchemaAttribute) { XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute)xmlSchemaObject2; this.errorCount += xmlSchemaAttribute.Compile(h, schema); } else if (xmlSchemaObject2 is XmlSchemaAttributeGroupRef) { XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = (XmlSchemaAttributeGroupRef)xmlSchemaObject2; this.errorCount += xmlSchemaAttributeGroupRef.Compile(h, schema); } else { base.error(h, xmlSchemaObject2.GetType() + " is not valid in this place::SimpleContentRestriction"); } } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
private void CompileCommon(ValidationEventHandler h, XmlSchema schema, bool refIsNotPresent) { if (refIsNotPresent) { if (this.Name == null) { base.error(h, "Required attribute name must be present"); } else if (!XmlSchemaUtil.CheckNCName(this.Name)) { base.error(h, "attribute name must be NCName"); } else if (this.Name == "xmlns") { base.error(h, "attribute name must not be xmlns"); } else { this.qualifiedName = new XmlQualifiedName(this.Name, this.targetNamespace); } if (this.SchemaType != null) { if (this.SchemaTypeName != null && !this.SchemaTypeName.IsEmpty) { base.error(h, "attribute can't have both a type and <simpleType> content"); } this.errorCount += this.SchemaType.Compile(h, schema); } if (this.SchemaTypeName != null && !XmlSchemaUtil.CheckQName(this.SchemaTypeName)) { base.error(h, this.SchemaTypeName + " is not a valid QName"); } } else { if (this.RefName == null || this.RefName.IsEmpty) { throw new InvalidOperationException("Error: Should Never Happen. refname must be present"); } this.qualifiedName = this.RefName; } if (base.AncestorSchema.TargetNamespace == "http://www.w3.org/2001/XMLSchema-instance" && this.Name != "nil" && this.Name != "type" && this.Name != "schemaLocation" && this.Name != "noNamespaceSchemaLocation") { base.error(h, "targetNamespace can't be http://www.w3.org/2001/XMLSchema-instance"); } if (this.DefaultValue != null && this.FixedValue != null) { base.error(h, "default and fixed must not both be present in an Attribute"); } if (this.DefaultValue != null && this.Use != XmlSchemaUse.None && this.Use != XmlSchemaUse.Optional) { base.error(h, "if default is present, use must be optional"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); }
// Is some value is read, return it. // If no values return empty. // If exception, return none public static XmlSchemaDerivationMethod ReadDerivationAttribute(XmlReader reader, out Exception innerExcpetion, string name, XmlSchemaDerivationMethod allowed) { innerExcpetion = null; try { string list = reader.Value; string warn = ""; XmlSchemaDerivationMethod val = 0; if (list.IndexOf("#all") != -1 && list.Trim() != "#all") { innerExcpetion = new Exception(list + " is not a valid value for " + name + ". #all if present must be the only value"); return(XmlSchemaDerivationMethod.All); } foreach (string xsdm in XmlSchemaUtil.SplitList(list)) { switch (xsdm) { case "": val = AddFlag(val, XmlSchemaDerivationMethod.Empty, allowed); break; case "#all": val = AddFlag(val, XmlSchemaDerivationMethod.All, allowed); break; case "substitution": val = AddFlag(val, XmlSchemaDerivationMethod.Substitution, allowed); break; case "extension": val = AddFlag(val, XmlSchemaDerivationMethod.Extension, allowed); break; case "restriction": val = AddFlag(val, XmlSchemaDerivationMethod.Restriction, allowed); break; case "list": val = AddFlag(val, XmlSchemaDerivationMethod.List, allowed); break; case "union": val = AddFlag(val, XmlSchemaDerivationMethod.Union, allowed); break; default: warn += xsdm + " "; break; } } if (warn != "") { innerExcpetion = new Exception(warn + "is/are not valid values for " + name); } return(val); } catch (Exception ex) { innerExcpetion = ex; return(XmlSchemaDerivationMethod.None); } }
/// <remarks> /// 1. Circular union type definition is disallowed. (WTH is this?) /// 2. id must be a valid ID /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } errorCount = 0; int count = BaseTypes.Count; foreach (XmlSchemaObject obj in baseTypes) { if (obj != null && obj is XmlSchemaSimpleType) { XmlSchemaSimpleType stype = (XmlSchemaSimpleType)obj; errorCount += stype.Compile(h, schema); } else { error(h, "baseTypes can't have objects other than a simpletype"); } } if (memberTypes != null) { for (int i = 0; i < memberTypes.Length; i++) { if (memberTypes[i] == null || !XmlSchemaUtil.CheckQName(MemberTypes[i])) { error(h, "Invalid membertype"); memberTypes[i] = XmlQualifiedName.Empty; } else { count += MemberTypes.Length; } } } if (count == 0) { error(h, "Atleast one simpletype or membertype must be present"); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(this.errorCount); } this.errorCount = 0; if (this.redefinedObject != null) { this.errorCount += this.redefined.Compile(h, schema); if (this.errorCount == 0) { this.redefined = (XmlSchemaAttributeGroup)this.redefinedObject; } } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); if (this.Name == null || this.Name == string.Empty) { base.error(h, "Name is required in top level simpletype"); } else if (!XmlSchemaUtil.CheckNCName(this.Name)) { base.error(h, "name attribute of a simpleType must be NCName"); } else { this.qualifiedName = new XmlQualifiedName(this.Name, base.AncestorSchema.TargetNamespace); } if (this.AnyAttribute != null) { this.errorCount += this.AnyAttribute.Compile(h, schema); } foreach (XmlSchemaObject xmlSchemaObject in this.Attributes) { if (xmlSchemaObject is XmlSchemaAttribute) { XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute)xmlSchemaObject; this.errorCount += xmlSchemaAttribute.Compile(h, schema); } else if (xmlSchemaObject is XmlSchemaAttributeGroupRef) { XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = (XmlSchemaAttributeGroupRef)xmlSchemaObject; this.errorCount += xmlSchemaAttributeGroupRef.Compile(h, schema); } else { base.error(h, "invalid type of object in Attributes property"); } } this.CompilationId = schema.CompilationId; return(this.errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { base.Compile(h, schema); if (this.refer == null || this.refer.IsEmpty) { base.error(h, "refer must be present"); } else if (!XmlSchemaUtil.CheckQName(this.refer)) { base.error(h, "Refer is not a valid XmlQualifiedName"); } return(this.errorCount); }
public static bool IsValidQName(string qname) { foreach (string name in qname.Split(new char[] { ':' }, 2)) { if (!XmlSchemaUtil.CheckNCName(name)) { return(false); } } return(true); }
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); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } this.errorCount = 0; int num = this.BaseTypes.Count; foreach (XmlSchemaObject xmlSchemaObject in this.baseTypes) { if (xmlSchemaObject != null && xmlSchemaObject is XmlSchemaSimpleType) { XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType)xmlSchemaObject; this.errorCount += xmlSchemaSimpleType.Compile(h, schema); } else { base.error(h, "baseTypes can't have objects other than a simpletype"); } } if (this.memberTypes != null) { for (int i = 0; i < this.memberTypes.Length; i++) { if (this.memberTypes[i] == null || !XmlSchemaUtil.CheckQName(this.MemberTypes[i])) { base.error(h, "Invalid membertype"); this.memberTypes[i] = XmlQualifiedName.Empty; } else { num += this.MemberTypes.Length; } } } if (num == 0) { base.error(h, "Atleast one simpletype or membertype must be present"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
// 1. name must be present // 2. MinOccurs & MaxOccurs of the Particle must be absent internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } if (Name == null) { error(h, "Required attribute name must be present"); } else if (!XmlSchemaUtil.CheckNCName(this.name)) { error(h, "attribute name must be NCName"); } else { qualifiedName = new XmlQualifiedName(Name, AncestorSchema.TargetNamespace); } if (Particle == null) { error(h, "Particle is required"); } else { if (Particle.MaxOccursString != null) { Particle.error(h, "MaxOccurs must not be present when the Particle is a child of Group"); } if (Particle.MinOccursString != null) { Particle.error(h, "MinOccurs must not be present when the Particle is a child of Group"); } Particle.Compile(h, schema); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h) { if (id == null) { return; } if (!XmlSchemaUtil.CheckNCName(id)) { xso.error(h, id + " is not a valid id attribute"); } else if (idCollection.ContainsKey(id)) { xso.error(h, "Duplicate id attribute " + id); } else { idCollection.Add(id, xso); } }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (base.IsValidated(schema.ValidationId)) { return(this.errorCount); } XmlSchemaSimpleType xmlSchemaSimpleType = this.itemType; if (xmlSchemaSimpleType == null) { xmlSchemaSimpleType = (schema.FindSchemaType(this.itemTypeName) as XmlSchemaSimpleType); } if (xmlSchemaSimpleType != null) { this.errorCount += xmlSchemaSimpleType.Validate(h, schema); this.validatedListItemType = xmlSchemaSimpleType; } else if (this.itemTypeName == XmlSchemaComplexType.AnyTypeName) { this.validatedListItemType = XmlSchemaSimpleType.AnySimpleType; } else if (XmlSchemaUtil.IsBuiltInDatatypeName(this.itemTypeName)) { this.validatedListItemType = XmlSchemaDatatype.FromName(this.itemTypeName); if (this.validatedListItemType == null) { base.error(h, "Invalid schema type name was specified: " + this.itemTypeName); } } else if (!schema.IsNamespaceAbsent(this.itemTypeName.Namespace)) { base.error(h, "Referenced base list item schema type " + this.itemTypeName + " was not found."); } XmlSchemaSimpleType xmlSchemaSimpleType2 = this.validatedListItemType as XmlSchemaSimpleType; if (xmlSchemaSimpleType2 == null && this.validatedListItemType != null) { xmlSchemaSimpleType2 = XmlSchemaType.GetBuiltInSimpleType(((XmlSchemaDatatype)this.validatedListItemType).TypeCode); } this.validatedListItemSchemaType = xmlSchemaSimpleType2; this.ValidationId = schema.ValidationId; return(this.errorCount); }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (base.IsValidated(schema.CompilationId)) { return(this.errorCount); } if (this.redefined == null && this.redefinedObject != null) { this.redefinedObject.Compile(h, schema); this.redefined = (XmlSchemaAttributeGroup)this.redefinedObject; this.redefined.Validate(h, schema); } XmlSchemaObjectCollection xmlSchemaObjectCollection = this.Attributes; this.attributeUses = new XmlSchemaObjectTable(); this.errorCount += XmlSchemaUtil.ValidateAttributesResolved(this.attributeUses, h, schema, xmlSchemaObjectCollection, this.AnyAttribute, ref this.anyAttributeUse, this.redefined, false); this.ValidationId = schema.ValidationId; return(this.errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } this.errorCount = 0; if (this.RefName == null || this.RefName.IsEmpty) { base.error(h, "ref must be present"); } else if (!XmlSchemaUtil.CheckQName(this.RefName)) { base.error(h, "ref must be a valid qname"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
/// <remarks> /// 1. MaxOccurs must be one. (default is also one) /// 2. MinOccurs must be zero or one. /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } this.schema = schema; if (MaxOccurs != Decimal.One) { error(h, "maxOccurs must be 1"); } if (MinOccurs != Decimal.One && MinOccurs != Decimal.Zero) { error(h, "minOccurs must be 0 or 1"); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); CompileOccurence(h, schema); foreach (XmlSchemaObject obj in Items) { XmlSchemaElement elem = obj as XmlSchemaElement; if (elem != null) { if (elem.ValidatedMaxOccurs != Decimal.One && elem.ValidatedMaxOccurs != Decimal.Zero) { elem.error(h, "The {max occurs} of all the elements of 'all' must be 0 or 1. "); } errorCount += elem.Compile(h, schema); } else { error(h, "XmlSchemaAll can only contain Items of type Element"); } } this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (IsValidated(schema.ValidationId)) { return(errorCount); } if (baseType != null) { baseType.Validate(h, schema); actualBaseSchemaType = baseType; } else if (baseTypeName != XmlQualifiedName.Empty) { XmlSchemaType st = schema.FindSchemaType(baseTypeName); if (st != null) { 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); }
public static bool AreSchemaDatatypeEqual(XmlSchemaSimpleType st1, object v1, XmlSchemaSimpleType st2, object v2) { if (st1.Datatype is XsdAnySimpleType) { return(XmlSchemaUtil.AreSchemaDatatypeEqual(st1.Datatype as XsdAnySimpleType, v1, st2.Datatype as XsdAnySimpleType, v2)); } string[] array = v1 as string[]; string[] array2 = v2 as string[]; if (st1 != st2 || array == null || array2 == null || array.Length != array2.Length) { return(false); } for (int i = 0; i < array.Length; i++) { if (array[i] != array2[i]) { return(false); } } return(true); }