private void AddGlobalComponents(XmlSchema schema) { foreach (XmlSchemaElement el in schema.Elements.Values) { GlobalElements.Add(el.QualifiedName, el); } foreach (XmlSchemaAttribute a in schema.Attributes.Values) { GlobalAttributes.Add(a.QualifiedName, a); } foreach (XmlSchemaType t in schema.SchemaTypes.Values) { GlobalTypes.Add(t.QualifiedName, t); } foreach (XmlSchemaAttributeGroup g in schema.AttributeGroups.Values) { global_attribute_groups.Add(g.QualifiedName, g); } foreach (XmlSchemaGroup g in schema.Groups.Values) { global_groups.Add(g.QualifiedName, g); } foreach (DictionaryEntry pair in schema.IDCollection) { global_ids.Add(pair.Key, pair.Value); } foreach (XmlSchemaIdentityConstraint ic in schema.NamedIdentities.Values) { global_identity_constraints.Add(ic.QualifiedName, ic); } }
private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length != 0) { XmlSchemaObject obj2 = table[qname]; if (obj2 != null) { if ((obj2 == item) || (obj2.SourceUri == item.SourceUri)) { return(true); } string res = string.Empty; if (item is XmlSchemaComplexType) { res = "Sch_DupComplexType"; } else if (item is XmlSchemaSimpleType) { res = "Sch_DupSimpleType"; } else if (item is XmlSchemaElement) { res = "Sch_DupGlobalElement"; } else if (item is XmlSchemaAttribute) { if (qname.Namespace == "http://www.w3.org/XML/1998/namespace") { XmlSchemaObject obj3 = Preprocessor.GetBuildInSchema().Attributes[qname]; if (obj2 == obj3) { table.Insert(qname, item); return(true); } if (item == obj3) { return(true); } } res = "Sch_DupGlobalAttribute"; } this.SendValidationEvent(new XmlSchemaException(res, qname.ToString()), XmlSeverityType.Error); return(false); } table.Add(qname, item); } return(true); }
protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length == 0) { return; } XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; if (existingObject != null) { if (existingObject == item) { return; } string code = Res.Sch_DupGlobalElement; if (item is XmlSchemaAttributeGroup) { string ns = nameTable.Add(qname.Namespace); if (Ref.Equal(ns, NsXml)) //Check for xml namespace { XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname]; if ((object)existingObject == (object)builtInAttributeGroup) { table.Insert(qname, item); return; } else if ((object)item == (object)builtInAttributeGroup) //trying to overwrite customer's component with built-in, ignore built-in { return; } } else if (IsValidAttributeGroupRedefine(existingObject, item)) //check for redefines { table.Insert(qname, item); return; } code = Res.Sch_DupAttributeGroup; } else if (item is XmlSchemaAttribute) { string ns = nameTable.Add(qname.Namespace); if (Ref.Equal(ns, NsXml)) { XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname]; if ((object)existingObject == (object)builtInAttribute) //replace built-in one { table.Insert(qname, item); return; } else if ((object)item == (object)builtInAttribute) //trying to overwrite customer's component with built-in, ignore built-in { return; } } code = Res.Sch_DupGlobalAttribute; } else if (item is XmlSchemaSimpleType) { if (IsValidTypeRedefine(existingObject, item)) { table.Insert(qname, item); return; } code = Res.Sch_DupSimpleType; } else if (item is XmlSchemaComplexType) { if (IsValidTypeRedefine(existingObject, item)) { table.Insert(qname, item); return; } code = Res.Sch_DupComplexType; } else if (item is XmlSchemaGroup) { if (IsValidGroupRedefine(existingObject, item)) //check for redefines { table.Insert(qname, item); return; } code = Res.Sch_DupGroup; } else if (item is XmlSchemaNotation) { code = Res.Sch_DupNotation; } else if (item is XmlSchemaIdentityConstraint) { code = Res.Sch_DupIdentityConstraint; } else { Debug.Assert(item is XmlSchemaElement); } SendValidationEvent(code, qname.ToString(), item); } else { table.Add(qname, item); } }
private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length == 0) { return true; } XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; if (existingObject != null) { if (existingObject == item || existingObject.SourceUri == item.SourceUri) { return true; } string code = string.Empty; if (item is XmlSchemaComplexType) { code = Res.Sch_DupComplexType; } else if (item is XmlSchemaSimpleType) { code = Res.Sch_DupSimpleType; } else if (item is XmlSchemaElement) { code = Res.Sch_DupGlobalElement; } else if (item is XmlSchemaAttribute) { if (qname.Namespace == XmlReservedNs.NsXml) { XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname]; if (existingObject == builtInAttribute) { //replace built-in one table.Insert(qname, item); return true; } else if (item == builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in return true; } } code = Res.Sch_DupGlobalAttribute; } SendValidationEvent(new XmlSchemaException(code,qname.ToString()), XmlSeverityType.Error); return false; } else { table.Add(qname, item); return true; } }
protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length != 0) { XmlSchemaObject existingObject = table[qname]; if (existingObject != null) { if (existingObject != item) { string code = "Sch_DupGlobalElement"; if (item is XmlSchemaAttributeGroup) { if (Ref.Equal(this.nameTable.Add(qname.Namespace), this.NsXml)) { XmlSchemaObject obj3 = Preprocessor.GetBuildInSchema().AttributeGroups[qname]; if (existingObject == obj3) { table.Insert(qname, item); return; } if (item == obj3) { return; } } else if (this.IsValidAttributeGroupRedefine(existingObject, item, table)) { return; } code = "Sch_DupAttributeGroup"; } else if (item is XmlSchemaAttribute) { if (Ref.Equal(this.nameTable.Add(qname.Namespace), this.NsXml)) { XmlSchemaObject obj4 = Preprocessor.GetBuildInSchema().Attributes[qname]; if (existingObject == obj4) { table.Insert(qname, item); return; } if (item == obj4) { return; } } code = "Sch_DupGlobalAttribute"; } else if (item is XmlSchemaSimpleType) { if (this.IsValidTypeRedefine(existingObject, item, table)) { return; } code = "Sch_DupSimpleType"; } else if (item is XmlSchemaComplexType) { if (this.IsValidTypeRedefine(existingObject, item, table)) { return; } code = "Sch_DupComplexType"; } else if (item is XmlSchemaGroup) { if (this.IsValidGroupRedefine(existingObject, item, table)) { return; } code = "Sch_DupGroup"; } else if (item is XmlSchemaNotation) { code = "Sch_DupNotation"; } else if (item is XmlSchemaIdentityConstraint) { code = "Sch_DupIdentityConstraint"; } this.SendValidationEvent(code, qname.ToString(), item); } } else { table.Add(qname, item); } } }
private void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name == string.Empty) { return; } else if (table[qname] != null) { string code = Res.Sch_DupGlobalAttribute; if (item is XmlSchemaAttributeGroup) { code = Res.Sch_DupAttributeGroup; } else if (item is XmlSchemaComplexType) { code = Res.Sch_DupComplexType; } else if (item is XmlSchemaSimpleType) { code = Res.Sch_DupSimpleType; } else if (item is XmlSchemaElement) { code = Res.Sch_DupGlobalElement; } else if (item is XmlSchemaGroup) { code = Res.Sch_DupGroup; } else if (item is XmlSchemaNotation) { code = Res.Sch_DupNotation; } SendValidationEvent(code, qname.ToString(), item); } else { table.Add(qname, item); } }
protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length == 0) { return; } XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; if (existingObject != null) { if (existingObject == item) { return; } string code = Res.Sch_DupGlobalElement; if (item is XmlSchemaAttributeGroup) { string ns = nameTable.Add(qname.Namespace); if (Ref.Equal(ns, NsXml)) { //Check for xml namespace XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname]; if ((object)existingObject == (object)builtInAttributeGroup) { table.Insert(qname, item); return; } else if ((object)item == (object)builtInAttributeGroup) { //trying to overwrite customer's component with built-in, ignore built-in return; } } else if (IsValidAttributeGroupRedefine(existingObject, item, table)){ //check for redefines return; } code = Res.Sch_DupAttributeGroup; } else if (item is XmlSchemaAttribute) { string ns = nameTable.Add(qname.Namespace); if (Ref.Equal(ns, NsXml)) { XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname]; if ((object)existingObject == (object)builtInAttribute) { //replace built-in one table.Insert(qname, item); return; } else if ((object)item == (object)builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in return; } } code = Res.Sch_DupGlobalAttribute; } else if (item is XmlSchemaSimpleType) { if (IsValidTypeRedefine(existingObject, item, table)) { return; } code = Res.Sch_DupSimpleType; } else if (item is XmlSchemaComplexType) { if (IsValidTypeRedefine(existingObject, item, table)) { return; } code = Res.Sch_DupComplexType; } else if (item is XmlSchemaGroup) { if (IsValidGroupRedefine(existingObject, item, table)){ //check for redefines return; } code = Res.Sch_DupGroup; } else if (item is XmlSchemaNotation) { code = Res.Sch_DupNotation; } else if (item is XmlSchemaIdentityConstraint) { code = Res.Sch_DupIdentityConstraint; } else { Debug.Assert(item is XmlSchemaElement); } SendValidationEvent(code, qname.ToString(), item); } else { table.Add(qname, item); } }
private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) { if (qname.Name.Length != 0) { XmlSchemaObject obj2 = table[qname]; if (obj2 != null) { if ((obj2 == item) || (obj2.SourceUri == item.SourceUri)) { return true; } string res = string.Empty; if (item is XmlSchemaComplexType) { res = "Sch_DupComplexType"; } else if (item is XmlSchemaSimpleType) { res = "Sch_DupSimpleType"; } else if (item is XmlSchemaElement) { res = "Sch_DupGlobalElement"; } else if (item is XmlSchemaAttribute) { if (qname.Namespace == "http://www.w3.org/XML/1998/namespace") { XmlSchemaObject obj3 = Preprocessor.GetBuildInSchema().Attributes[qname]; if (obj2 == obj3) { table.Insert(qname, item); return true; } if (item == obj3) { return true; } } res = "Sch_DupGlobalAttribute"; } this.SendValidationEvent(new XmlSchemaException(res, qname.ToString()), XmlSeverityType.Error); return false; } table.Add(qname, item); } return true; }
internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { XmlSchemaElement labeled = labels [this.QualifiedName] as XmlSchemaElement; if (labeled == null) labels.Add (this.QualifiedName, this); else if (labeled.ElementType != this.ElementType) error (h, "Different types are specified on the same named elements in the same sequence. Element name is " + QualifiedName); }
internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { if (qnames.Contains (this.QualifiedName))// && !this.ParticleEquals ((XmlSchemaParticle) qnames [this.QualifiedName])) error (h, "Ambiguous element label was detected: " + this.QualifiedName); else { foreach (XmlSchemaAny any in nsNames) { if (any.ValidatedMaxOccurs == 0) continue; if (any.HasValueAny || any.HasValueLocal && this.QualifiedName.Namespace == "" || any.HasValueOther && this.QualifiedName.Namespace != this.QualifiedName.Namespace || any.HasValueTargetNamespace && this.QualifiedName.Namespace == this.QualifiedName.Namespace) { error (h, "Ambiguous element label which is contained by -any- particle was detected: " + this.QualifiedName); break; } else if (!any.HasValueOther) { bool bad = false; foreach (string ns in any.ResolvedNamespaces) { if (ns == this.QualifiedName.Namespace) { bad = true; break; } } if (bad) { error (h, "Ambiguous element label which is contained by -any- particle was detected: " + this.QualifiedName); break; } } else { if (any.TargetNamespace != this.QualifiedName.Namespace) error (h, String.Format ("Ambiguous element label '{0}' which is contained by -any- particle with ##other value than '{1}' was detected: ", this.QualifiedName.Namespace, any.TargetNamespace)); } } qnames.Add (this.QualifiedName, this); } }