public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains (qname)) { // FIXME: This logic unexpectedly allows // one redefining item and two or more redefining items. // FIXME: redefining item is not simple replacement, // but much more complex stuff. if (obj.isRedefineChild) { // take precedence. if (obj.redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else obj.redefinedObject = table [qname]; table.Set (qname, obj); } else if (table [qname].isRedefineChild) { if (table [qname].redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else table [qname].redefinedObject = obj; return; // never add to the table. } else if (StrictMsCompliant) { table.Set (qname, obj); } else obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } else table.Set (qname, obj); }
public XmlSchemaRedefine() { attributeGroups = new XmlSchemaObjectTable(); groups = new XmlSchemaObjectTable(); items = new XmlSchemaObjectCollection(this); schemaTypes = new XmlSchemaObjectTable(); }
internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { if (this.TargetGroup != null) { this.TargetGroup.Particle.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema); } }
internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { if (this.TargetGroup != null) { this.TargetGroup.Particle.ValidateUniqueTypeAttribution(labels, h, schema); } }
private void ProcessNewSubstitutionGroups(XmlSchemaObjectTable substitutionGroupsTable, bool resolve) { foreach (XmlSchemaSubstitutionGroup group in substitutionGroupsTable.Values) { if (resolve) { this.ResolveSubstitutionGroup(group, substitutionGroupsTable); } XmlQualifiedName examplar = group.Examplar; XmlSchemaSubstitutionGroup group2 = (XmlSchemaSubstitutionGroup)this.substitutionGroups[examplar]; if (group2 != null) { for (int i = 0; i < group.Members.Count; i++) { if (!group2.Members.Contains(group.Members[i])) { group2.Members.Add(group.Members[i]); } } } else { this.AddToTable(this.substitutionGroups, examplar, group); } } }
internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaParticle p in this.Items) { p.ValidateUniqueTypeAttribution(labels, h, schema); } }
private void ClearCompiledState() { this.attributeUses = null; this.localElements = null; this.attributeWildcard = null; this.contentTypeParticle = XmlSchemaParticle.Empty; this.blockResolved = XmlSchemaDerivationMethod.None; }
internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaObject xmlSchemaObject in this.Items) { XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)xmlSchemaObject; xmlSchemaElement.ValidateUniqueTypeAttribution(labels, h, schema); } }
internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaObject xmlSchemaObject in this.Items) { XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)xmlSchemaObject; xmlSchemaElement.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema); } }
internal void Preprocess(XmlSchema schema, string targetNamespace) { this.namespaceManager = new XmlNamespaceManager(this.nameTable); this.schema = schema; this.ids = schema.Ids; this.identityConstraints = schema.IdentityConstraints; ValidateIdAttribute(schema); Preprocess(schema, targetNamespace, Compositor.Root); }
// Adds all items in the XmlSchemaObjectTable to the specified XmlSchema // private static void AddTableToSchema(XmlSchema outSch, XmlSchemaObjectTable table) { var e = table.GetEnumerator(); while (e.MoveNext()) { outSch.Items.Add((XmlSchemaObject)e.Value); } }
private void ClearCompiledState() { //Re-set post-compiled state for cloned object _attributeUses = null; _localElements = null; _attributeWildcard = null; _contentTypeParticle = XmlSchemaParticle.Empty; _blockResolved = XmlSchemaDerivationMethod.None; }
private void ValidateUPAOnHeadingOptionalComponents(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaObject xmlSchemaObject in this.Items) { XmlSchemaParticle xmlSchemaParticle = (XmlSchemaParticle)xmlSchemaObject; xmlSchemaParticle.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema); if (xmlSchemaParticle.ValidatedMinOccurs != 0m) { break; } } }
internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { foreach (object obj in nsNames) { XmlSchemaAny other = (XmlSchemaAny)obj; if (!this.ExamineAttributeWildcardIntersection(other, h, schema)) { base.error(h, "Ambiguous -any- particle was found."); } } nsNames.Add(this); }
void ValidateUPAOnHeadingOptionalComponents(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { // heading optional components foreach (XmlSchemaParticle p in this.Items) { p.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema); if (p.ValidatedMinOccurs != 0) { break; } } }
public Compiler(XmlNameTable nameTable, ValidationEventHandler eventHandler, XmlSchema schemaForSchema, XmlSchemaCompilationSettings compilationSettings) : base(nameTable, null, eventHandler, compilationSettings) { this.attributes = new XmlSchemaObjectTable(); this.attributeGroups = new XmlSchemaObjectTable(); this.elements = new XmlSchemaObjectTable(); this.schemaTypes = new XmlSchemaObjectTable(); this.groups = new XmlSchemaObjectTable(); this.notations = new XmlSchemaObjectTable(); this.examplars = new XmlSchemaObjectTable(); this.identityConstraints = new XmlSchemaObjectTable(); this.complexTypeStack = new Stack(); this.schemasToCompile = new Hashtable(); this.importedSchemas = new Hashtable(); this.schemaForSchema = schemaForSchema; }
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); }
public static void AddToTable(XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains(qname)) { // FIXME: This logic unexpectedly allows // one redefining item and two or more redefining items. // FIXME: redefining item is not simple replacement, // but much more complex stuff. if (obj.isRedefineChild) // take precedence. { if (obj.redefinedObject != null) { obj.error(h, String.Format("Named item {0} was already contained in the schema object table.", qname)); } else { obj.redefinedObject = table [qname]; } table.Set(qname, obj); } else if (table [qname].isRedefineChild) { if (table [qname].redefinedObject != null) { obj.error(h, String.Format("Named item {0} was already contained in the schema object table.", qname)); } else { table [qname].redefinedObject = obj; } return; // never add to the table. } else if (StrictMsCompliant) { table.Set(qname, obj); } else { obj.error(h, String.Format("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } } else { table.Set(qname, obj); } }
public XmlSchema() { attributeFormDefault = XmlSchemaForm.None; blockDefault = XmlSchemaDerivationMethod.None; elementFormDefault = XmlSchemaForm.None; finalDefault = XmlSchemaDerivationMethod.None; includes = new XmlSchemaObjectCollection(); isCompiled = false; items = new XmlSchemaObjectCollection(); attributeGroups = new XmlSchemaObjectTable(); attributes = new XmlSchemaObjectTable(); elements = new XmlSchemaObjectTable(); groups = new XmlSchemaObjectTable(); notations = new XmlSchemaObjectTable(); schemaTypes = new XmlSchemaObjectTable(); }
public static void AddToTable(XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains(qname)) { if (obj.isRedefineChild) { if (obj.redefinedObject != null) { obj.error(h, string.Format("Named item {0} was already contained in the schema object table.", qname)); } else { obj.redefinedObject = table[qname]; } table.Set(qname, obj); } else { if (table[qname].isRedefineChild) { if (table[qname].redefinedObject != null) { obj.error(h, string.Format("Named item {0} was already contained in the schema object table.", qname)); } else { table[qname].redefinedObject = obj; } return; } if (XmlSchemaUtil.StrictMsCompliant) { table.Set(qname, obj); } else { obj.error(h, string.Format("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } } } else { table.Set(qname, obj); } }
internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) { for (Datatype_NOTATION e_notation = this; e_notation != null; e_notation = (Datatype_NOTATION)e_notation.Base) { if ((e_notation.Restriction != null) && ((e_notation.Restriction.Flags & RestrictionFlags.Enumeration) != 0)) { for (int i = 0; i < e_notation.Restriction.Enumeration.Count; i++) { XmlQualifiedName name = (XmlQualifiedName)e_notation.Restriction.Enumeration[i]; if (!notations.Contains(name)) { throw new XmlSchemaException("Sch_NotationRequired", caller); } } return; } } throw new XmlSchemaException("Sch_NotationRequired", caller); }
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); }
private void VerifyTables() { if (this.elements == null) { this.elements = new XmlSchemaObjectTable(); } if (this.attributes == null) { this.attributes = new XmlSchemaObjectTable(); } if (this.schemaTypes == null) { this.schemaTypes = new XmlSchemaObjectTable(); } if (this.substitutionGroups == null) { this.substitutionGroups = new XmlSchemaObjectTable(); } }
internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) { for (Datatype_NOTATION e_notation = this; e_notation != null; e_notation = (Datatype_NOTATION) e_notation.Base) { if ((e_notation.Restriction != null) && ((e_notation.Restriction.Flags & RestrictionFlags.Enumeration) != 0)) { for (int i = 0; i < e_notation.Restriction.Enumeration.Count; i++) { XmlQualifiedName name = (XmlQualifiedName) e_notation.Restriction.Enumeration[i]; if (!notations.Contains(name)) { throw new XmlSchemaException("Sch_NotationRequired", caller); } } return; } } throw new XmlSchemaException("Sch_NotationRequired", caller); }
private void ValidateUPAOnItems(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { XmlSchemaObjectTable xmlSchemaObjectTable = new XmlSchemaObjectTable(); ArrayList arrayList = new ArrayList(); XmlSchemaObjectTable xmlSchemaObjectTable2 = new XmlSchemaObjectTable(); ArrayList arrayList2 = new ArrayList(); for (int i = 0; i < this.Items.Count; i++) { XmlSchemaParticle xmlSchemaParticle = this.Items[i] as XmlSchemaParticle; xmlSchemaParticle.ValidateUniqueParticleAttribution(xmlSchemaObjectTable, arrayList, h, schema); if (xmlSchemaParticle.ValidatedMinOccurs == xmlSchemaParticle.ValidatedMaxOccurs) { xmlSchemaObjectTable.Clear(); arrayList.Clear(); } else { if (xmlSchemaParticle.ValidatedMinOccurs != 0m) { foreach (object obj in xmlSchemaObjectTable2.Names) { XmlQualifiedName name = (XmlQualifiedName)obj; xmlSchemaObjectTable.Set(name, null); } foreach (object obj2 in arrayList2) { arrayList.Remove(obj2); } } foreach (object obj3 in xmlSchemaObjectTable.Names) { XmlQualifiedName name2 = (XmlQualifiedName)obj3; xmlSchemaObjectTable2.Set(name2, xmlSchemaObjectTable[name2]); } arrayList2.Clear(); arrayList2.AddRange(arrayList); } } }
void ValidateUPAOnItems(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { // non-optional components XmlSchemaObjectTable elems = new XmlSchemaObjectTable(); ArrayList wildcards = new ArrayList(); XmlSchemaObjectTable tmpElems = new XmlSchemaObjectTable(); ArrayList tmpWildcards = new ArrayList(); for (int i = 0; i < Items.Count; i++) { XmlSchemaParticle p1 = Items [i] as XmlSchemaParticle; p1.ValidateUniqueParticleAttribution(elems, wildcards, h, schema); if (p1.ValidatedMinOccurs == p1.ValidatedMaxOccurs) { elems.Clear(); wildcards.Clear(); } else { if (p1.ValidatedMinOccurs != 0) { foreach (XmlQualifiedName n in tmpElems.Names) { elems.Set(n, null); // remove } foreach (object o in tmpWildcards) { wildcards.Remove(o); } } foreach (XmlQualifiedName n in elems.Names) { tmpElems.Set(n, elems [n]); } tmpWildcards.Clear(); tmpWildcards.AddRange(wildcards); } } }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (IsValidated(schema.CompilationId)) { return(errorCount); } if (redefined == null && redefinedObject != null) { redefinedObject.Compile(h, schema); redefined = (XmlSchemaAttributeGroup)redefinedObject; redefined.Validate(h, schema); } XmlSchemaObjectCollection actualAttributes = null; /* * if (this.redefined != null) { * actualAttributes = new XmlSchemaObjectCollection (); * foreach (XmlSchemaObject obj in Attributes) { * XmlSchemaAttributeGroupRef grp = obj as XmlSchemaAttributeGroupRef; * if (grp != null && grp.QualifiedName == this.QualifiedName) * actualAttributes.Add (redefined); * else * actualAttributes.Add (obj); * } * } * else */ actualAttributes = Attributes; attributeUses = new XmlSchemaObjectTable(); errorCount += XmlSchemaUtil.ValidateAttributesResolved(attributeUses, h, schema, actualAttributes, AnyAttribute, ref anyAttributeUse, redefined, false); ValidationId = schema.ValidationId; return(errorCount); }
internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) {/*noop*/}
internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaParticle p in this.Items) p.ValidateUniqueTypeAttribution (labels, h, schema); }
internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { if (TargetGroup != null) TargetGroup.Particle.ValidateUniqueTypeAttribution (labels, h, schema); }
private void GenerateAttribute(XmlSchemaObjectTable attributes, InstanceElement elem) { IDictionaryEnumerator ienum = attributes.GetEnumerator(); while (ienum.MoveNext()) { if (ienum.Value is XmlSchemaAttribute) { GenerateInstanceAttribute((XmlSchemaAttribute)ienum.Value, elem); } } }
internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) { }
private XmlSchemaAttribute GetAttributeFromNS(string ns, XmlSchemaObjectTable attributes) { return GetAttributeFromNS(ns, false, attributes); }
internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { // do nothing }
internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { // do nothing }
internal virtual void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { }
internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { // do nothing }
internal virtual void ValidateUniqueParticleAttribution ( XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { }
private bool IsValidTypeRedefine(XmlSchemaObject existingObject, XmlSchemaObject item, XmlSchemaObjectTable table) { XmlSchemaType schemaType = (item as XmlSchemaType) !; XmlSchemaType existingType = (existingObject as XmlSchemaType) !; if (existingType == schemaType.Redefined) { //schemaType is the redefinition of existingObject if (existingType.ElementDecl == null) { //If the existing one is not already compiled, then replace. table.Insert(schemaType.QualifiedName, schemaType); //Update with redefined entry return(true); } } else if (existingType.Redefined == schemaType) { //Redefined type already exists in the set, original type is added after redefined type, ignore the original type return(true); } return(false); }
internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { foreach (XmlSchemaParticle p in this.Items) p.ValidateUniqueParticleAttribution (qnames, nsNames, h, schema); }
internal virtual void ValidateUniqueParticleAttribution( XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { }
private XmlQueryCardinality AddAttributes(List<XmlQueryType> list, XmlSchemaObjectTable attributeUses, XmlSchemaAnyAttribute attributeWildcard, XmlQueryType filter) { XmlQueryCardinality card = XmlQueryCardinality.Zero; if (attributeWildcard != null) { XmlSchemaType attributeSchemaType = attributeWildcard.ProcessContentsCorrect == XmlSchemaContentProcessing.Skip ? DatatypeImplementation.UntypedAtomicType : DatatypeImplementation.AnySimpleType; // wildcard will match more then one attribute switch (attributeWildcard.NamespaceList.Type) { case NamespaceList.ListType.Set: foreach (string ns in attributeWildcard.NamespaceList.Enumerate) { card += AddFilteredPrime(list, CreateAttributeType(ns, false, attributeSchemaType), filter); } break; case NamespaceList.ListType.Other: card += AddFilteredPrime(list, CreateAttributeType(attributeWildcard.NamespaceList.Excluded, true, attributeSchemaType), filter); break; case NamespaceList.ListType.Any: default: card += AddFilteredPrime(list, attributeWildcard.ProcessContentsCorrect == XmlSchemaContentProcessing.Skip ? UntypedAttribute : Attribute, filter); break; } // Always optional card *= XmlQueryCardinality.ZeroOrOne; } foreach (XmlSchemaAttribute attribute in attributeUses.Values) { XmlQueryCardinality cardAttr = AddFilteredPrime(list, CreateAttributeType(attribute), filter); if (cardAttr != XmlQueryCardinality.Zero) { Debug.Assert(cardAttr == XmlQueryCardinality.ZeroOrOne || cardAttr == XmlQueryCardinality.One); card += (attribute.Use == XmlSchemaUse.Optional ? XmlQueryCardinality.ZeroOrOne : cardAttr); } } return card; }
internal virtual void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, ClrContentTypeInfo typeInfo) { foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { Debug.Assert(derivedAttribute.AttributeSchemaType != null); //For use=prohibited, without derivation it doesnt mean anything, hence attribute should be compiled ClrBasePropertyInfo propertyInfo = BuildProperty(derivedAttribute, false, false); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } }
internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels, ValidationEventHandler h, XmlSchema schema) { // do nothing }
private void TraverseAttributes(XmlSchemaObjectTable derivedAttributes, XmlSchemaObjectTable baseAttributes, ClrContentTypeInfo typeInfo) { foreach (XmlSchemaAttribute derivedAttribute in derivedAttributes.Values) { if (derivedAttribute.Use == XmlSchemaUse.Prohibited) { continue; } XmlSchemaAttribute baseAttribute = baseAttributes[derivedAttribute.QualifiedName] as XmlSchemaAttribute; if (baseAttribute != null && baseAttribute == derivedAttribute) { // Its the one copied from the base // http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3064 ClrBasePropertyInfo propertyInfo = BuildProperty( derivedAttribute, typeInfo.IsDerived, false); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } else { ClrBasePropertyInfo propertyInfo = BuildProperty(derivedAttribute, false, baseAttribute != null); BuildAnnotationInformation(propertyInfo, derivedAttribute, false, false); typeInfo.AddMember(propertyInfo); } } }
private XmlSchemaAttribute GetAttributeFromNS(string ns, bool other, XmlSchemaObjectTable attributes) { if (other) { foreach(XmlSchemaAttribute attr in schemaSet.GlobalAttributes.Values) { if (attr.QualifiedName.Namespace != ns && attr.QualifiedName.Namespace != string.Empty && attributes[attr.QualifiedName] == null) { return attr; } } } else { foreach(XmlSchemaAttribute attr in schemaSet.GlobalAttributes.Values) { if (attr.QualifiedName.Namespace == ns && attributes[attr.QualifiedName] == null) { return attr; } } } return null; }
private string DumpAttributes(XmlSchemaObjectTable attributeUses, XmlSchemaAnyAttribute attributeWildcard) { StringBuilder sb = new StringBuilder(); sb.Append("["); bool first = true; foreach (XmlSchemaAttribute attribute in attributeUses.Values) { if (attribute.Use != XmlSchemaUse.Prohibited) { if (first) { first = false; } else { sb.Append(" "); } sb.Append(attribute.QualifiedName.Name); if (attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) { sb.Append("?"); } } } if (attributeWildcard != null) { if (attributeUses.Count != 0) { sb.Append(" "); } sb.Append("<"); sb.Append(attributeWildcard.NamespaceList.ToString()); sb.Append(">"); } sb.Append("] - ["); first = true; foreach (XmlSchemaAttribute attribute in attributeUses.Values) { if (attribute.Use == XmlSchemaUse.Prohibited) { if (first) { first = false; } else { sb.Append(" "); } sb.Append(attribute.QualifiedName.Name); } } sb.Append("]"); return sb.ToString(); }
internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { if (TargetGroup != null) TargetGroup.Particle.ValidateUniqueParticleAttribution (qnames, nsNames, h, schema); }
public XmlSchema () { attributeFormDefault= XmlSchemaForm.None; blockDefault = XmlSchemaDerivationMethod.None; elementFormDefault = XmlSchemaForm.None; finalDefault = XmlSchemaDerivationMethod.None; includes = new XmlSchemaObjectCollection(); isCompiled = false; items = new XmlSchemaObjectCollection(); attributeGroups = new XmlSchemaObjectTable(); attributes = new XmlSchemaObjectTable(); elements = new XmlSchemaObjectTable(); groups = new XmlSchemaObjectTable(); notations = new XmlSchemaObjectTable(); schemaTypes = new XmlSchemaObjectTable(); }
internal abstract void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller);
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); } }
internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) { // Only datatypes that are derived from NOTATION by specifying a value for enumeration can be used in a schema. // Furthermore, the value of all enumeration facets must match the name of a notation declared in the current schema. // for(Datatype_NOTATION dt = this; dt != null; dt = (Datatype_NOTATION)dt.Base) { if (dt.Restriction != null && (dt.Restriction.Flags & RestrictionFlags.Enumeration) != 0) { for (int i = 0; i < dt.Restriction.Enumeration.Count; ++i) { XmlQualifiedName notation = (XmlQualifiedName)dt.Restriction.Enumeration[i]; if (!notations.Contains(notation)) { throw new XmlSchemaException(Res.Sch_NotationRequired, caller); } } return; } } throw new XmlSchemaException(Res.Sch_NotationRequired, caller); }
internal XSODictionaryEnumerator(List<XmlSchemaObjectTable.XmlSchemaObjectEntry> entries, int size, XmlSchemaObjectTable.EnumeratorType enumType) : base(entries, size, enumType) { }
public SchemaCollectionCompiler(XmlNameTable nameTable, ValidationEventHandler eventHandler) : base(nameTable, null, eventHandler) { this.examplars = new XmlSchemaObjectTable(); this.complexTypeStack = new Stack(); }
private XmlSchemaAttribute AddAttribute(string localName, string prefix, string childURI, string attrValue, bool bCreatingNewType, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, XmlSchemaObjectTable compiledAttributes) { if (childURI == XmlSchema.Namespace) { throw new XmlSchemaInferenceException(Res.SchInf_schema, 0, 0); } XmlSchemaAttribute xsa = null; int AttributeType = -1; XmlSchemaAttribute returnedAttribute = null; //this value will change to attributeReference if childURI!= parentURI XmlSchema xs = null; bool add = true; Debug.Assert(compiledAttributes != null); //AttributeUses is never null // First we need to look into the already compiled attributes // (they come from the schemaset which we got on input) // If there are none or we don't find it there, then we must search the list of attributes // where we are going to add a new one (if it doesn't exist). // This is necessary to avoid adding duplicate attribute declarations. ICollection searchCollectionPrimary, searchCollectionSecondary; if (compiledAttributes.Count > 0) { searchCollectionPrimary = compiledAttributes.Values; searchCollectionSecondary = addLocation; } else { searchCollectionPrimary = addLocation; searchCollectionSecondary = null; } if (childURI == XmlReservedNs.NsXml) { XmlSchemaAttribute attributeReference = null; //see if the reference exists attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI); if (attributeReference == null && searchCollectionSecondary != null) { attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI); } if (attributeReference == null) { attributeReference = new XmlSchemaAttribute(); attributeReference.RefName = new XmlQualifiedName(localName, childURI); if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) { attributeReference.Use = XmlSchemaUse.Required; } else { attributeReference.Use = XmlSchemaUse.Optional; } addLocation.Add(attributeReference); } returnedAttribute = attributeReference; } else { if (childURI.Length == 0) { xs = parentSchema; add = false; } else if (childURI != null && !schemaSet.Contains(childURI)) { /*if (parentSchema.AttributeFormDefault = XmlSchemaForm.Unqualified && childURI.Length == 0) { xs = parentSchema; add = false; break; }*/ xs = new XmlSchema(); xs.AttributeFormDefault = XmlSchemaForm.Unqualified; xs.ElementFormDefault = XmlSchemaForm.Qualified; if (childURI.Length != 0) xs.TargetNamespace = childURI; //schemas.Add(childURI, xs); this.schemaSet.Add(xs); if (prefix.Length != 0 && String.Compare(prefix, "xml", StringComparison.OrdinalIgnoreCase) != 0) NamespaceManager.AddNamespace(prefix, childURI); } else { ArrayList col = this.schemaSet.Schemas(childURI) as ArrayList; if (col != null && col.Count > 0) { xs = col[0] as XmlSchema; } } if (childURI.Length != 0) // { XmlSchemaAttribute attributeReference = null; //see if the reference exists attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI); if (attributeReference == null & searchCollectionSecondary != null) { attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI); } if (attributeReference == null) { attributeReference = new XmlSchemaAttribute(); attributeReference.RefName = new XmlQualifiedName(localName, childURI); if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) { attributeReference.Use = XmlSchemaUse.Required; } else { attributeReference.Use = XmlSchemaUse.Optional; } addLocation.Add(attributeReference); } returnedAttribute = attributeReference; //see if the attribute exists on the global level xsa = FindAttribute(xs.Items, localName); if (xsa == null) { xsa = new XmlSchemaAttribute(); xsa.Name = localName; xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); xsa.LineNumber = AttributeType; //we use LineNumber to store flags of valid types xs.Items.Add(xsa); } else { if (xsa.Parent == null) { AttributeType = xsa.LineNumber; // we use LineNumber to store flags of valid types } else { AttributeType = GetSchemaType(xsa.SchemaTypeName); xsa.Parent = null; } xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types } } else { xsa = FindAttribute(searchCollectionPrimary, localName); if (xsa == null && searchCollectionSecondary != null) { xsa = FindAttribute(searchCollectionSecondary, localName); } if (xsa == null) { xsa = new XmlSchemaAttribute(); xsa.Name = localName; xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) xsa.Use = XmlSchemaUse.Required; else xsa.Use = XmlSchemaUse.Optional; addLocation.Add(xsa); if (xs.AttributeFormDefault != XmlSchemaForm.Unqualified) { xsa.Form = XmlSchemaForm.Unqualified; } } else { if (xsa.Parent == null) { AttributeType = xsa.LineNumber; // we use LineNumber to store flags of valid types } else { AttributeType = GetSchemaType(xsa.SchemaTypeName); xsa.Parent = null; } xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types } returnedAttribute = xsa; } } string nullString = null; if (add && childURI != parentSchema.TargetNamespace) { for (int i = 0; i < parentSchema.Includes.Count; ++i) { XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport; if (import == null) { continue; } if (import.Namespace == childURI) { add = false; } } if (add) { XmlSchemaImport import = new XmlSchemaImport(); import.Schema = xs; if (childURI.Length != 0) { nullString = childURI; } import.Namespace = nullString; parentSchema.Includes.Add(import); } } return returnedAttribute; }
internal XSOEnumerator(List<XmlSchemaObjectTable.XmlSchemaObjectEntry> entries, int size, XmlSchemaObjectTable.EnumeratorType enumType) { this.entries = entries; this.size = size; this.enumType = enumType; this.currentIndex = -1; }