Example #1
0
 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)
 {
     foreach (XmlSchemaParticle p in this.Items)
     {
         p.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema);
     }
 }
 internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels,
                                                      ValidationEventHandler h, XmlSchema schema)
 {
     if (TargetGroup != null)
     {
         TargetGroup.Particle.ValidateUniqueTypeAttribution(labels, h, schema);
     }
 }
 internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames,
                                                          ValidationEventHandler h, XmlSchema schema)
 {
     if (TargetGroup != null)
     {
         TargetGroup.Particle.ValidateUniqueParticleAttribution(qnames, nsNames, h, schema);
     }
 }
 internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels,
                                                      ValidationEventHandler h, XmlSchema schema)
 {
     foreach (XmlSchemaParticle p in this.Items)
     {
         p.ValidateUniqueTypeAttribution(labels, h, schema);
     }
 }
 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;
         }
     }
 }
Example #7
0
 internal override void ValidateUniqueParticleAttribution(
     XmlSchemaObjectTable qnames, ArrayList nsNames,
     ValidationEventHandler h, XmlSchema schema)
 {
     // Wildcard Intersection check.
     foreach (XmlSchemaAny other in nsNames)
     {
         if (!ExamineAttributeWildcardIntersection(other, h, schema))
         {
             error(h, "Ambiguous -any- particle was found.");
         }
     }
     nsNames.Add(this);
 }
Example #8
0
 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);
     }
 }
Example #9
0
 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();
     named_identities = new XmlSchemaObjectTable();
     ids = new Hashtable();
     compilationItems = new XmlSchemaObjectCollection();
 }
        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);
        }
Example #12
0
        public static int ValidateAttributesResolved(
            XmlSchemaObjectTable attributesResolved,
            ValidationEventHandler h,
            XmlSchema schema,
            XmlSchemaObjectCollection attributes,
            XmlSchemaAnyAttribute anyAttribute,
            ref XmlSchemaAnyAttribute anyAttributeUse,
            XmlSchemaAttributeGroup redefined,
            bool skipEquivalent)
        {
            int errorCount = 0;

            if (anyAttribute != null && anyAttributeUse == null)
            {
                anyAttributeUse = anyAttribute;
            }

            ArrayList newAttrNames = new ArrayList();

            foreach (XmlSchemaObject xsobj in attributes)
            {
                XmlSchemaAttributeGroupRef grpRef = xsobj as XmlSchemaAttributeGroupRef;
                if (grpRef != null)
                {
                    // Resolve attributeGroup redefinition.
                    XmlSchemaAttributeGroup grp = null;
                    if (redefined != null && grpRef.RefName == redefined.QualifiedName)
                    {
                        grp = redefined;
                    }
                    else
                    {
                        grp = schema.FindAttributeGroup(grpRef.RefName);
                    }
                    // otherwise, it might be missing sub components.
                    if (grp == null)
                    {
                        if (!schema.missedSubComponents)                        // && schema.Schemas [grpRef.RefName.Namespace] != null)
                        {
                            grpRef.error(h, "Referenced attribute group " + grpRef.RefName + " was not found in the corresponding schema.");
                        }
                        continue;
                    }
                    if (grp.AttributeGroupRecursionCheck)
                    {
                        grp.error(h, "Attribute group recursion was found: " + grpRef.RefName);
                        continue;
                    }
                    try {
                        grp.AttributeGroupRecursionCheck = true;
                        errorCount += grp.Validate(h, schema);
                    } finally {
                        grp.AttributeGroupRecursionCheck = false;
                    }
                    if (grp.AnyAttributeUse != null)
                    {
                        if (anyAttribute == null)
                        {
                            anyAttributeUse = grp.AnyAttributeUse;
                        }
                    }
                    foreach (DictionaryEntry entry in grp.AttributeUses)
                    {
                        XmlSchemaAttribute attr = (XmlSchemaAttribute)entry.Value;

                        if (StrictMsCompliant && attr.Use == XmlSchemaUse.Prohibited)
                        {
                            continue;
                        }

                        if (attr.RefName != null && attr.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.RefName] as XmlSchemaAttribute)))
                        {
                            AddToTable(attributesResolved, attr, attr.RefName, h);
                        }
                        else if (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.QualifiedName] as XmlSchemaAttribute))
                        {
                            AddToTable(attributesResolved, attr, attr.QualifiedName, h);
                        }
                    }
                }
                else
                {
                    XmlSchemaAttribute attr = xsobj as XmlSchemaAttribute;
                    if (attr != null)
                    {
                        errorCount += attr.Validate(h, schema);

                        if (newAttrNames.Contains(attr.QualifiedName))
                        {
                            attr.error(h, String.Format("Duplicate attributes was found for '{0}'", attr.QualifiedName));
                        }
                        newAttrNames.Add(attr.QualifiedName);


                        if (StrictMsCompliant && attr.Use == XmlSchemaUse.Prohibited)
                        {
                            continue;
                        }

                        if (attr.RefName != null && attr.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.RefName] as XmlSchemaAttribute)))
                        {
                            AddToTable(attributesResolved, attr, attr.RefName, h);
                        }
                        else if (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.QualifiedName] as XmlSchemaAttribute))
                        {
                            AddToTable(attributesResolved, attr, attr.QualifiedName, h);
                        }
                    }
                    else
                    {
                        if (anyAttribute != null)
                        {
                            anyAttributeUse = (XmlSchemaAnyAttribute)xsobj;
                            anyAttribute.Validate(h, schema);
                        }
                    }
                }
            }
            return(errorCount);
        }
Example #13
0
 internal override void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels,
                                                      ValidationEventHandler h, XmlSchema schema)
 {
     // do nothing
 }
Example #14
0
 internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames,
                                                          ArrayList nsNames, ValidationEventHandler h, XmlSchema schema)
 {
     // do nothing
 }
Example #15
0
 internal virtual void ValidateUniqueTypeAttribution(XmlSchemaObjectTable labels,
                                                     ValidationEventHandler h, XmlSchema schema)
 {
 }
 internal XmlSchemaObjectTableEnumerator(XmlSchemaObjectTable table)
 {
     tmp   = (IEnumerable)table.table;
     xenum = (IDictionaryEnumerator)tmp.GetEnumerator();
 }
Example #17
0
 internal virtual void ValidateUniqueParticleAttribution(
     XmlSchemaObjectTable qnames, ArrayList nsNames,
     ValidationEventHandler h, XmlSchema schema)
 {
 }
 internal override void ValidateUniqueParticleAttribution(XmlSchemaObjectTable qnames, ArrayList nsNames,
                                                          ValidationEventHandler h, XmlSchema schema)
 {
     ValidateUPAOnHeadingOptionalComponents(qnames, nsNames, h, schema);
     ValidateUPAOnItems(qnames, nsNames, h, schema);
 }