Ejemplo n.º 1
0
 internal bool ValidateNSRecurseCheckCardinality(XmlSchemaAny any, ValidationEventHandler h, XmlSchema schema, bool raiseError)
 {
     foreach (XmlSchemaObject xmlSchemaObject in this.Items)
     {
         XmlSchemaParticle xmlSchemaParticle = (XmlSchemaParticle)xmlSchemaObject;
         if (!xmlSchemaParticle.ValidateDerivationByRestriction(any, h, schema, raiseError))
         {
             return(false);
         }
     }
     return(this.ValidateOccurenceRangeOK(any, h, schema, raiseError));
 }
Ejemplo n.º 2
0
        /*
         * private bool ValidateRecurseLax (XmlSchemaGroupBase baseGroup,
         *      ValidationEventHandler h, XmlSchema schema, bool raiseError)
         * {
         *      int index = 0;
         *      for (int i = 0; i < baseGroup.CompiledItems.Count; i++) {
         *              XmlSchemaParticle pb = (XmlSchemaParticle) baseGroup.CompiledItems [i];
         *              pb = pb.GetOptimizedParticle (false);
         *              if (pb == XmlSchemaParticle.Empty)
         *                      continue;
         *              XmlSchemaParticle pd = null;
         *              while (this.CompiledItems.Count > index) {
         *                      pd = (XmlSchemaParticle) this.CompiledItems [index];
         *                      pd = pd.GetOptimizedParticle (false);
         *                      index++;
         *                      if (pd != XmlSchemaParticle.Empty)
         *                              break;
         *              }
         *              if (!ValidateParticleSection (ref index, pd, pb, h, schema, raiseError))
         *                      continue;
         *      }
         *      if (this.CompiledItems.Count > 0 && index != this.CompiledItems.Count) {
         *              if (raiseError)
         *                      error (h, "Invalid particle derivation by restriction was found. Extraneous derived particle was found.");
         *              return false;
         *      }
         *      return true;
         * }
         */

        private bool ValidateParticleSection(ref int index, XmlSchemaParticle pd, XmlSchemaParticle pb, ValidationEventHandler h, XmlSchema schema, bool raiseError)
        {
            if (pd == pb)             // they are same particle
            {
                return(true);
            }

            if (pd != null)
            {
//				XmlSchemaElement el = pd as XmlSchemaElement;
                XmlSchemaParticle pdx = pd;
//				if (el != null && el.SubstitutingElements.Count > 0)
//					pdx = el.SubstitutingChoice;

                if (!pdx.ValidateDerivationByRestriction(pb, h, schema, false))
                {
                    if (!pb.ValidateIsEmptiable())
                    {
                        if (raiseError)
                        {
                            error(h, "Invalid particle derivation by restriction was found. Invalid sub-particle derivation was found.");
                        }
                        return(false);
                    }
                    else
                    {
                        index--;                         // try the same derived particle and next base particle.
                        return(false);
                    }
                }
            }
            else if (!pb.ValidateIsEmptiable())
            {
                if (raiseError)
                {
                    error(h, "Invalid particle derivation by restriction was found. Base schema particle has non-emptiable sub particle that is not mapped to the derived particle.");
                }
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        internal bool ValidateSeqRecurseMapSumCommon(XmlSchemaGroupBase baseGroup,
                                                     ValidationEventHandler h, XmlSchema schema, bool isLax, bool isMapAndSum, bool raiseError)
        {
            int     index       = 0;
            int     baseIndex   = 0;
            decimal baseOccured = 0;

            if (baseGroup.CompiledItems.Count == 0 && this.CompiledItems.Count > 0)
            {
                if (raiseError)
                {
                    error(h, "Invalid particle derivation by restriction was found. base particle does not contain particles.");
                }
                return(false);
            }

            for (int i = 0; i < CompiledItems.Count; i++)
            {
                // get non-empty derived particle
                XmlSchemaParticle pd = null;
                while (this.CompiledItems.Count > index)
                {
                    pd = ((XmlSchemaParticle)this.CompiledItems [index]); //.GetOptimizedParticle (false);
                    if (pd != XmlSchemaParticle.Empty)                    // && pd.ValidatedMaxOccurs > 0)
                    {
                        break;
                    }
                    else
                    {
                        index++;
                    }
                }
                if (index >= CompiledItems.Count)
                {
                    if (raiseError)
                    {
                        error(h, "Invalid particle derivation by restriction was found. Cannot be mapped to base particle.");
                    }
                    return(false);
                }

                // get non-empty base particle
                XmlSchemaParticle pb = null;
                while (baseGroup.CompiledItems.Count > baseIndex)
                {
                    pb = ((XmlSchemaParticle)baseGroup.CompiledItems [baseIndex]);                     //.GetOptimizedParticle (false);
                    if (pb == XmlSchemaParticle.Empty && pb.ValidatedMaxOccurs > 0)
                    {
                        continue;
                    }
                    if (!pd.ValidateDerivationByRestriction(pb, h, schema, false))
                    {
                        if (!isLax && !isMapAndSum && pb.MinOccurs > baseOccured && !pb.ValidateIsEmptiable())
                        {
                            if (raiseError)
                            {
                                error(h, "Invalid particle derivation by restriction was found. Invalid sub-particle derivation was found.");
                            }
                            return(false);
                        }
                        else
                        {
                            baseOccured = 0;
                            baseIndex++;
                        }
                    }
                    else
                    {
                        baseOccured += pb.ValidatedMinOccurs;
                        if (baseOccured >= baseGroup.ValidatedMaxOccurs)
                        {
                            baseOccured = 0;
                            baseIndex++;
                        }
                        index++;
                        break;
                    }
                }
            }
            if (this.CompiledItems.Count > 0 && index != this.CompiledItems.Count)
            {
                if (raiseError)
                {
                    error(h, "Invalid particle derivation by restriction was found. Extraneous derived particle was found.");
                }
                return(false);
            }
            if (!isLax && !isMapAndSum)
            {
                if (baseOccured > 0)
                {
                    baseIndex++;
                }
                for (int i = baseIndex; i < baseGroup.CompiledItems.Count; i++)
                {
                    XmlSchemaParticle p = baseGroup.CompiledItems [i] as XmlSchemaParticle;
                    if (!p.ValidateIsEmptiable())
                    {
                        if (raiseError)
                        {
                            error(h, "Invalid particle derivation by restriction was found. There is a base particle which does not have mapped derived particle and is not emptiable.");
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        internal bool ValidateSeqRecurseMapSumCommon(XmlSchemaGroupBase baseGroup, ValidationEventHandler h, XmlSchema schema, bool isLax, bool isMapAndSum, bool raiseError)
        {
            int     num  = 0;
            int     num2 = 0;
            decimal num3 = 0m;

            if (baseGroup.CompiledItems.Count == 0 && this.CompiledItems.Count > 0)
            {
                if (raiseError)
                {
                    base.error(h, "Invalid particle derivation by restriction was found. base particle does not contain particles.");
                }
                return(false);
            }
            for (int i = 0; i < this.CompiledItems.Count; i++)
            {
                XmlSchemaParticle xmlSchemaParticle = null;
                while (this.CompiledItems.Count > num)
                {
                    xmlSchemaParticle = (XmlSchemaParticle)this.CompiledItems[num];
                    if (xmlSchemaParticle != XmlSchemaParticle.Empty)
                    {
                        break;
                    }
                    num++;
                }
                if (num >= this.CompiledItems.Count)
                {
                    if (raiseError)
                    {
                        base.error(h, "Invalid particle derivation by restriction was found. Cannot be mapped to base particle.");
                    }
                    return(false);
                }
                while (baseGroup.CompiledItems.Count > num2)
                {
                    XmlSchemaParticle xmlSchemaParticle2 = (XmlSchemaParticle)baseGroup.CompiledItems[num2];
                    if (xmlSchemaParticle2 != XmlSchemaParticle.Empty || !(xmlSchemaParticle2.ValidatedMaxOccurs > 0m))
                    {
                        if (xmlSchemaParticle.ValidateDerivationByRestriction(xmlSchemaParticle2, h, schema, false))
                        {
                            num3 += xmlSchemaParticle2.ValidatedMinOccurs;
                            if (num3 >= baseGroup.ValidatedMaxOccurs)
                            {
                                num3 = 0m;
                                num2++;
                            }
                            num++;
                            break;
                        }
                        if (!isLax && !isMapAndSum && xmlSchemaParticle2.MinOccurs > num3 && !xmlSchemaParticle2.ValidateIsEmptiable())
                        {
                            if (raiseError)
                            {
                                base.error(h, "Invalid particle derivation by restriction was found. Invalid sub-particle derivation was found.");
                            }
                            return(false);
                        }
                        num3 = 0m;
                        num2++;
                    }
                }
            }
            if (this.CompiledItems.Count > 0 && num != this.CompiledItems.Count)
            {
                if (raiseError)
                {
                    base.error(h, "Invalid particle derivation by restriction was found. Extraneous derived particle was found.");
                }
                return(false);
            }
            if (!isLax && !isMapAndSum)
            {
                if (num3 > 0m)
                {
                    num2++;
                }
                for (int j = num2; j < baseGroup.CompiledItems.Count; j++)
                {
                    XmlSchemaParticle xmlSchemaParticle3 = baseGroup.CompiledItems[j] as XmlSchemaParticle;
                    if (!xmlSchemaParticle3.ValidateIsEmptiable())
                    {
                        if (raiseError)
                        {
                            base.error(h, "Invalid particle derivation by restriction was found. There is a base particle which does not have mapped derived particle and is not emptiable.");
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }