/// <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; 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); }
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); }
/// <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) { 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); }
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); }
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. ref 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(0); } errorCount = 0; if (RefName == null || RefName.IsEmpty) { error(h, "ref must be present"); } else if (!XmlSchemaUtil.CheckQName(RefName)) { error(h, "ref must be a valid qname"); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
/// <remarks> /// </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 (this.isRedefinedComponent) { if (Annotation != null) { Annotation.isRedefinedComponent = true; } if (AnyAttribute != null) { AnyAttribute.isRedefinedComponent = true; } foreach (XmlSchemaObject obj in Attributes) { obj.isRedefinedComponent = true; } if (Particle != null) { Particle.isRedefinedComponent = true; } } if (BaseTypeName == null || BaseTypeName.IsEmpty) { error(h, "base must be present, as a QName"); } else if (!XmlSchemaUtil.CheckQName(BaseTypeName)) { error(h, "BaseTypeName is not a valid XmlQualifiedName"); } if (this.AnyAttribute != null) { errorCount += 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 atgrp = (XmlSchemaAttributeGroupRef)obj; errorCount += atgrp.Compile(h, schema); } else { error(h, obj.GetType() + " is not valid in this place::ComplexConetnetExtension"); } } if (Particle != null) { if (Particle is XmlSchemaGroupRef) { errorCount += ((XmlSchemaGroupRef)Particle).Compile(h, schema); } else if (Particle is XmlSchemaAll) { errorCount += ((XmlSchemaAll)Particle).Compile(h, schema); } else if (Particle is XmlSchemaChoice) { errorCount += ((XmlSchemaChoice)Particle).Compile(h, schema); } else if (Particle is XmlSchemaSequence) { errorCount += ((XmlSchemaSequence)Particle).Compile(h, schema); } else { error(h, "Particle of a restriction is limited only to group, sequence, choice and all."); } } 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); } 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.Particle != null) { this.Particle.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 is not a valid XmlQualifiedName"); } 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::ComplexConetnetExtension"); } } if (this.Particle != null) { if (this.Particle is XmlSchemaGroupRef) { this.errorCount += ((XmlSchemaGroupRef)this.Particle).Compile(h, schema); } else if (this.Particle is XmlSchemaAll) { this.errorCount += ((XmlSchemaAll)this.Particle).Compile(h, schema); } else if (this.Particle is XmlSchemaChoice) { this.errorCount += ((XmlSchemaChoice)this.Particle).Compile(h, schema); } else if (this.Particle is XmlSchemaSequence) { this.errorCount += ((XmlSchemaSequence)this.Particle).Compile(h, schema); } else { base.error(h, "Particle of a restriction is limited only to group, sequence, choice and all."); } } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
///<remarks> /// 1. Base must be present and a QName ///</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 (this.isRedefinedComponent) { if (Annotation != null) { Annotation.isRedefinedComponent = true; } if (AnyAttribute != null) { AnyAttribute.isRedefinedComponent = true; } foreach (XmlSchemaObject obj in Attributes) { obj.isRedefinedComponent = true; } } if (BaseTypeName == null || BaseTypeName.IsEmpty) { error(h, "base must be present, as a QName"); } else if (!XmlSchemaUtil.CheckQName(BaseTypeName)) { error(h, "BaseTypeName must be a QName"); } if (this.AnyAttribute != null) { errorCount += 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 atgrp = (XmlSchemaAttributeGroupRef)obj; errorCount += atgrp.Compile(h, schema); } else { error(h, obj.GetType() + " is not valid in this place::SimpleConentExtension"); } } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
private void CompileCommon(ValidationEventHandler h, XmlSchema schema, bool refIsNotPresent) { if (refIsNotPresent) { if (Name == null) //a.4, b.1, { error(h, "Required attribute name must be present"); } else if (!XmlSchemaUtil.CheckNCName(Name)) // a.4.2, b1.2 { error(h, "attribute name must be NCName"); } else if (Name == "xmlns") // a.14 , b5 { error(h, "attribute name must not be xmlns"); } else { qualifiedName = new XmlQualifiedName(Name, targetNamespace); } if (SchemaType != null) { if (SchemaTypeName != null && !SchemaTypeName.IsEmpty) // a.8 { error(h, "attribute can't have both a type and <simpleType> content"); } errorCount += SchemaType.Compile(h, schema); } if (SchemaTypeName != null && !XmlSchemaUtil.CheckQName(SchemaTypeName)) { error(h, SchemaTypeName + " is not a valid QName"); } } else { if (RefName == null || RefName.IsEmpty) { throw new InvalidOperationException("Error: Should Never Happen. refname must be present"); } else { qualifiedName = RefName; } } if (AncestorSchema.TargetNamespace == XmlSchema.InstanceNamespace && Name != "nil" && Name != "type" && Name != "schemaLocation" && Name != "noNamespaceSchemaLocation") // a.15, a.16 { error(h, "targetNamespace can't be " + XmlSchema.InstanceNamespace); } if (DefaultValue != null && FixedValue != null) // a.6, b.3, c.3 { error(h, "default and fixed must not both be present in an Attribute"); } if (DefaultValue != null && Use != XmlSchemaUse.None && Use != XmlSchemaUse.Optional) { error(h, "if default is present, use must be optional"); } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); }