Example #1
0
        /// <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);
        }
Example #2
0
 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
 {
     if (this.CompilationId == schema.CompilationId)
     {
         return(0);
     }
     this.schema = schema;
     if (base.MaxOccurs != 1m)
     {
         base.error(h, "maxOccurs must be 1");
     }
     if (base.MinOccurs != 1m && base.MinOccurs != 0m)
     {
         base.error(h, "minOccurs must be 0 or 1");
     }
     XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h);
     base.CompileOccurence(h, schema);
     foreach (XmlSchemaObject xmlSchemaObject in this.Items)
     {
         XmlSchemaElement xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;
         if (xmlSchemaElement != null)
         {
             if (xmlSchemaElement.ValidatedMaxOccurs != 1m && xmlSchemaElement.ValidatedMaxOccurs != 0m)
             {
                 xmlSchemaElement.error(h, "The {max occurs} of all the elements of 'all' must be 0 or 1. ");
             }
             this.errorCount += xmlSchemaElement.Compile(h, schema);
         }
         else
         {
             base.error(h, "XmlSchemaAll can only contain Items of type Element");
         }
     }
     this.CompilationId = schema.CompilationId;
     return(this.errorCount);
 }