Пример #1
0
        public override bool EvaluateEndElement()
        {
            if (head.EvaluateEndElement())
            {
//				return true;
                return(rest.EvaluateIsEmptiable());
            }
            if (!head.EvaluateIsEmptiable())
            {
                return(false);
            }
            return(rest.EvaluateEndElement());
        }
Пример #2
0
        public override XsdValidationState EvaluateStartElement(string name, string ns)
        {
            XsdValidationState afterHead = head.EvaluateStartElement(name, ns);

            if (afterHead != XsdValidationState.Invalid)
            {
                head = afterHead;
                return(afterHead is XsdEmptyValidationState ? rest : this);
            }
            else if (!head.EvaluateIsEmptiable())
            {
                return(XsdValidationState.Invalid);
            }

            return(rest.EvaluateStartElement(name, ns));
        }
Пример #3
0
        public override void GetExpectedParticles(ArrayList al)
        {
            // if not started, then just collect all items from seq.
            if (currentAutomata == null)
            {
                foreach (XmlSchemaParticle p in seq.CompiledItems)
                {
                    al.Add(p);
                    if (!p.ValidateIsEmptiable())
                    {
                        break;
                    }
                }
                return;
            }

            // automata for ongoing iteration
            if (currentAutomata != null)
            {
                currentAutomata.GetExpectedParticles(al);
                if (!currentAutomata.EvaluateIsEmptiable())
                {
                    return;
                }

                // remaining items after currentAutomata
                for (int i = current + 1; i < seq.CompiledItems.Count; i++)
                {
                    XmlSchemaParticle p = seq.CompiledItems [i] as XmlSchemaParticle;
                    al.Add(p);
                    if (!p.ValidateIsEmptiable())
                    {
                        break;
                    }
                }
            }

            // itself
            if (Occured + 1 == seq.ValidatedMaxOccurs)
            {
                return;
            }

            {
                for (int i = 0; i <= current; i++)
                {
                    al.Add(seq.CompiledItems [i]);
                }
            }
        }
Пример #4
0
        public override bool EvaluateEndElement()
        {
            if (seq.ValidatedMinOccurs > Occured + 1)
            {
                return(false);
            }
            if (seq.CompiledItems.Count == 0)
            {
                return(true);
            }
            if (currentAutomata == null && seq.ValidatedMinOccurs <= Occured)
            {
                return(true);
            }

            int idx = current < 0 ? 0 : current;
            XsdValidationState xa = currentAutomata;

            if (xa == null)
            {
                xa = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
            }
            while (xa != null)
            {
                if (!xa.EvaluateEndElement())
                {
                    if (!xa.EvaluateIsEmptiable())
                    {
                        return(false);                          // cannot omit following items.
                    }
                }
                idx++;
                if (seq.CompiledItems.Count > idx)
                {
                    xa = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
                }
                else
                {
                    xa = null;
                }
            }
            if (current < 0)
            {
                OccuredInternal++;
            }

            return(seq.ValidatedMinOccurs <= Occured && seq.ValidatedMaxOccurs >= Occured);
        }
Пример #5
0
        public override XsdValidationState EvaluateStartElement(string localName, string ns)
        {
            this.emptiableComputed = false;
            bool flag = true;
            int  i    = 0;

            while (i < this.choice.CompiledItems.Count)
            {
                XmlSchemaParticle  xsobj = (XmlSchemaParticle)this.choice.CompiledItems[i];
                XsdValidationState xsdValidationState  = base.Manager.Create(xsobj);
                XsdValidationState xsdValidationState2 = xsdValidationState.EvaluateStartElement(localName, ns);
                if (xsdValidationState2 != XsdValidationState.Invalid)
                {
                    base.OccuredInternal++;
                    if (base.Occured > this.choice.ValidatedMaxOccurs)
                    {
                        return(XsdValidationState.Invalid);
                    }
                    if (base.Occured == this.choice.ValidatedMaxOccurs)
                    {
                        return(xsdValidationState2);
                    }
                    return(base.Manager.MakeSequence(xsdValidationState2, this));
                }
                else
                {
                    if (!this.emptiableComputed)
                    {
                        flag &= xsdValidationState.EvaluateIsEmptiable();
                    }
                    i++;
                }
            }
            if (!this.emptiableComputed)
            {
                if (flag)
                {
                    this.emptiable = true;
                }
                if (!this.emptiable)
                {
                    this.emptiable = (this.choice.ValidatedMinOccurs <= base.Occured);
                }
                this.emptiableComputed = true;
            }
            return(XsdValidationState.Invalid);
        }
Пример #6
0
        internal override bool EvaluateIsEmptiable()
        {
            if (seq.ValidatedMinOccurs > Occured + 1)
            {
                return(false);
            }
            if (seq.ValidatedMinOccurs == 0 && currentAutomata == null)
            {
                return(true);
            }

            if (emptiable)
            {
                return(true);
            }
            if (seq.CompiledItems.Count == 0)
            {
                return(true);
            }

            int idx = current < 0 ? 0 : current;
            XsdValidationState xa = currentAutomata;

            if (xa == null)
            {
                xa = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
            }
            while (xa != null)
            {
                if (!xa.EvaluateIsEmptiable())
                {
                    return(false);
                }
                idx++;
                if (seq.CompiledItems.Count > idx)
                {
                    xa = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
                }
                else
                {
                    xa = null;
                }
            }
            emptiable = true;
            return(true);
        }
Пример #7
0
        public override XsdValidationState EvaluateStartElement(string localName, string ns)
        {
            emptiableComputed = false;
            bool allChildrenEmptiable = true;

            for (int i = 0; i < choice.CompiledItems.Count; i++)
            {
                XmlSchemaParticle  xsobj  = (XmlSchemaParticle)choice.CompiledItems [i];
                XsdValidationState xa     = Manager.Create(xsobj);
                XsdValidationState result = xa.EvaluateStartElement(localName, ns);
                if (result != XsdValidationState.Invalid)
                {
                    OccuredInternal++;
                    if (Occured > choice.ValidatedMaxOccurs)
                    {
                        return(XsdValidationState.Invalid);
                    }
                    else if (Occured == choice.ValidatedMaxOccurs)
                    {
                        return(result);
                    }
                    else
                    {
                        return(Manager.MakeSequence(result, this));
                    }
                }
                if (!emptiableComputed)
                {
                    allChildrenEmptiable &= xa.EvaluateIsEmptiable();
                }
            }
            if (!emptiableComputed)
            {
                if (allChildrenEmptiable)
                {
                    emptiable = true;
                }
                if (!emptiable)
                {
                    emptiable = choice.ValidatedMinOccurs <= Occured;
                }
                emptiableComputed = true;
            }
            return(XsdValidationState.Invalid);
        }
        internal override bool EvaluateIsEmptiable()
        {
            if (this.seq.ValidatedMinOccurs > base.Occured + 1)
            {
                return(false);
            }
            if (this.seq.ValidatedMinOccurs == 0m && this.currentAutomata == null)
            {
                return(true);
            }
            if (this.emptiable)
            {
                return(true);
            }
            if (this.seq.CompiledItems.Count == 0)
            {
                return(true);
            }
            int num = (this.current >= 0) ? this.current : 0;
            XsdValidationState xsdValidationState = this.currentAutomata;

            if (xsdValidationState == null)
            {
                xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
            }
            while (xsdValidationState != null)
            {
                if (!xsdValidationState.EvaluateIsEmptiable())
                {
                    return(false);
                }
                num++;
                if (this.seq.CompiledItems.Count > num)
                {
                    xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
                }
                else
                {
                    xsdValidationState = null;
                }
            }
            this.emptiable = true;
            return(true);
        }
        public override bool EvaluateEndElement()
        {
            if (this.seq.ValidatedMinOccurs > base.Occured + 1)
            {
                return(false);
            }
            if (this.seq.CompiledItems.Count == 0)
            {
                return(true);
            }
            if (this.currentAutomata == null && this.seq.ValidatedMinOccurs <= base.Occured)
            {
                return(true);
            }
            int num = (this.current >= 0) ? this.current : 0;
            XsdValidationState xsdValidationState = this.currentAutomata;

            if (xsdValidationState == null)
            {
                xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
            }
            while (xsdValidationState != null)
            {
                if (!xsdValidationState.EvaluateEndElement() && !xsdValidationState.EvaluateIsEmptiable())
                {
                    return(false);
                }
                num++;
                if (this.seq.CompiledItems.Count > num)
                {
                    xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
                }
                else
                {
                    xsdValidationState = null;
                }
            }
            if (this.current < 0)
            {
                base.OccuredInternal++;
            }
            return(this.seq.ValidatedMinOccurs <= base.Occured && this.seq.ValidatedMaxOccurs >= base.Occured);
        }
        public override XsdValidationState EvaluateStartElement(string name, string ns)
        {
            if (this.seq.CompiledItems.Count == 0)
            {
                return(XsdValidationState.Invalid);
            }
            int num = (this.current >= 0) ? this.current : 0;
            XsdValidationState xsdValidationState = this.currentAutomata;
            bool flag = false;
            XsdValidationState xsdValidationState2;

            for (;;)
            {
                if (xsdValidationState == null)
                {
                    xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
                    flag = true;
                }
                if (xsdValidationState is XsdEmptyValidationState && this.seq.CompiledItems.Count == num + 1 && base.Occured == this.seq.ValidatedMaxOccurs)
                {
                    break;
                }
                xsdValidationState2 = xsdValidationState.EvaluateStartElement(name, ns);
                if (xsdValidationState2 != XsdValidationState.Invalid)
                {
                    goto IL_E1;
                }
                if (!xsdValidationState.EvaluateIsEmptiable())
                {
                    goto Block_8;
                }
                num++;
                if (num > this.current && flag && this.current >= 0)
                {
                    goto Block_13;
                }
                if (this.seq.CompiledItems.Count > num)
                {
                    xsdValidationState = base.Manager.Create(this.seq.CompiledItems[num] as XmlSchemaParticle);
                }
                else
                {
                    if (this.current < 0)
                    {
                        goto Block_15;
                    }
                    num = 0;
                    xsdValidationState = null;
                }
            }
            return(XsdValidationState.Invalid);

Block_8:
            this.emptiable = false;
            return(XsdValidationState.Invalid);

IL_E1:
            this.current         = num;
            this.currentAutomata = xsdValidationState2;
            if (flag)
            {
                base.OccuredInternal++;
                if (base.Occured > this.seq.ValidatedMaxOccurs)
                {
                    return(XsdValidationState.Invalid);
                }
            }
            return(this);

Block_13:
            return(XsdValidationState.Invalid);

Block_15:
            return(XsdValidationState.Invalid);
        }
Пример #11
0
        public override XsdValidationState EvaluateStartElement(string name, string ns)
        {
            if (seq.CompiledItems.Count == 0)
            {
                return(XsdValidationState.Invalid);
            }

            int idx = current < 0 ? 0 : current;
            XsdValidationState xa = currentAutomata;
            // If it is true and when matching particle was found, then
            // it will increment occurence.
            bool increment = false;

            while (true)
            {
//				if (current < 0 || current == seq.CompiledItems.Count) {
//					idx = current = 0;
//					increment = true;
//				}
                if (xa == null)                         // This code runs in case of a newiteration.
                {
                    xa        = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
                    increment = true;
                }
                if (xa is XsdEmptyValidationState &&
                    seq.CompiledItems.Count == idx + 1 &&
                    Occured == seq.ValidatedMaxOccurs)
                {
                    return(XsdValidationState.Invalid);
                }
                else
                {
                    XsdValidationState result = xa.EvaluateStartElement(name, ns);
                    if (result == XsdValidationState.Invalid)
                    {
                        if (!xa.EvaluateIsEmptiable())
                        {
                            emptiable = false;
                            return(XsdValidationState.Invalid);
                        }
                    }
                    else
                    {
                        current         = idx;
                        currentAutomata = result;
                        if (increment)
                        {
                            OccuredInternal++;
                            if (Occured > seq.ValidatedMaxOccurs)
                            {
                                return(XsdValidationState.Invalid);
                            }
                        }
//						current++;
//						return Manager.MakeSequence (result, this);
                        return(this);
                        // skip in other cases.
                    }
                }
                idx++;
                if (idx > current && increment && current >= 0)
                {
                    return(XsdValidationState.Invalid);
                }
                if (seq.CompiledItems.Count > idx)
                {
                    xa = Manager.Create(seq.CompiledItems [idx] as XmlSchemaParticle);
                }
                else if (current < 0)                   // started from top
                {
                    return(XsdValidationState.Invalid);
                }
                else                            // started from middle
                {
                    idx = 0;
                    xa  = null;
                }
            }
        }