public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
 {
     object obj2 = this.elements[name];
     errorCode = 0;
     if (obj2 == null)
     {
         context.NeedValidateChildren = false;
         return null;
     }
     int index = (int) obj2;
     if (context.AllElementsSet[index])
     {
         errorCode = -2;
         return null;
     }
     if (context.CurrentState.AllElementsRequired == -1)
     {
         context.CurrentState.AllElementsRequired = 0;
     }
     context.AllElementsSet.Set(index);
     if (this.isRequired[index])
     {
         context.CurrentState.AllElementsRequired++;
     }
     return this.particles[index];
 }
示例#2
0
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
        {
            BitSet set   = context.CurPos[context.CurrentState.CurPosIndex];
            int    index = (context.CurrentState.CurPosIndex + 1) % 2;
            BitSet set2  = context.CurPos[index];

            set2.Clear();
            int    num2     = this.symbols[name];
            object particle = null;

            errorCode = 0;
            for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
            {
                if (num2 == this.positions[i].symbol)
                {
                    set2.Or(this.followpos[i]);
                    particle = this.positions[i].particle;
                    break;
                }
            }
            if (!set2.IsEmpty)
            {
                context.CurrentState.CurPosIndex = index;
                return(particle);
            }
            if (!base.IsOpen || !set[this.endMarkerPos])
            {
                context.NeedValidateChildren = false;
                errorCode = -1;
            }
            return(null);
        }
示例#3
0
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
        {
            object obj2 = this.elements[name];

            errorCode = 0;
            if (obj2 == null)
            {
                context.NeedValidateChildren = false;
                return(null);
            }
            int index = (int)obj2;

            if (context.AllElementsSet[index])
            {
                errorCode = -2;
                return(null);
            }
            if (context.CurrentState.AllElementsRequired == -1)
            {
                context.CurrentState.AllElementsRequired = 0;
            }
            context.AllElementsSet.Set(index);
            if (this.isRequired[index])
            {
                context.CurrentState.AllElementsRequired++;
            }
            return(this.particles[index]);
        }
示例#4
0
        public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
        {
            ArrayList list = null;
            BitSet    set  = context.CurPos[context.CurrentState.CurPosIndex];

            for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
            {
                if (list == null)
                {
                    list = new ArrayList();
                }
                XmlSchemaParticle particle = (XmlSchemaParticle)this.positions[i].particle;
                if (particle == null)
                {
                    string str = this.symbols.NameOf(this.positions[i].symbol);
                    if (str.Length != 0)
                    {
                        list.Add(str);
                    }
                }
                else
                {
                    string nameString = particle.NameString;
                    if (!list.Contains(nameString))
                    {
                        list.Add(nameString);
                    }
                }
            }
            return(list);
        }
        public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
        {
            ArrayList particles = new ArrayList();

            if (context.RunningPositions != null)
            {
                List <RangePositionInfo> runningPositions = context.RunningPositions;
                BitSet set = new BitSet(this.positions.Count);
                for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--)
                {
                    set.Or(runningPositions[i].curpos);
                }
                for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j))
                {
                    if (this.positions[j].symbol >= 0)
                    {
                        XmlSchemaParticle p = this.positions[j].particle as XmlSchemaParticle;
                        if (p != null)
                        {
                            ContentValidator.AddParticleToExpected(p, schemaSet, particles);
                        }
                    }
                }
            }
            return(particles);
        }
 public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
 {
     ArrayList list = null;
     BitSet set = context.CurPos[context.CurrentState.CurPosIndex];
     for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
     {
         if (list == null)
         {
             list = new ArrayList();
         }
         XmlSchemaParticle particle = (XmlSchemaParticle) this.positions[i].particle;
         if (particle == null)
         {
             string str = this.symbols.NameOf(this.positions[i].symbol);
             if (str.Length != 0)
             {
                 list.Add(str);
             }
         }
         else
         {
             string nameString = particle.NameString;
             if (!list.Contains(nameString))
             {
                 list.Add(nameString);
             }
         }
     }
     return list;
 }
        internal void InitContent(ValidationState context)
        {
            if (IsAllElements)
            {
                context.AllElementsSet = new BitSet(this.allElementsSet.Count);
                return;
            }

            if (!IsCompiled)
            {
                context.CurrentNode    = contentNode;
                context.MinMaxValues   = null;
                context.HasNodeMatched = 0;
                context.HasMatched     = (contentType != CompiledContentModel.Type.Mixed) && (contentType != CompiledContentModel.Type.ElementOnly);
            }
            else
            {
                context.State = 0;
                if (dtrans != null && dtrans.Count > 0)
                {
                    context.HasMatched = ((int[])dtrans[0])[symbols.Count] > 0;
                }
                else
                {
                    context.HasMatched = true;
                }
            }
        }
示例#8
0
 public override bool CompleteValidation(ValidationState context)
 {
     if ((context.CurrentState.AllElementsRequired != this.countRequired) && (!this.IsEmptiable || (context.CurrentState.AllElementsRequired != -1)))
     {
         return(false);
     }
     return(true);
 }
示例#9
0
 public override bool CompleteValidation(ValidationState context)
 {
     if (!context.CurPos[context.CurrentState.CurPosIndex][this.endMarkerPos])
     {
         return(false);
     }
     return(true);
 }
 public override bool CompleteValidation(ValidationState context)
 {
     if (!context.HasMatched)
     {
         return false;
     }
     return true;
 }
 public override bool CompleteValidation(ValidationState context)
 {
     if (!context.CurPos[context.CurrentState.CurPosIndex][this.endMarkerPos])
     {
         return false;
     }
     return true;
 }
 public override bool CompleteValidation(ValidationState context)
 {
     if (!context.HasMatched)
     {
         return(false);
     }
     return(true);
 }
 public override bool CompleteValidation(ValidationState context)
 {
     if ((context.CurrentState.AllElementsRequired != this.countRequired) && (!this.IsEmptiable || (context.CurrentState.AllElementsRequired != -1)))
     {
         return false;
     }
     return true;
 }
 public virtual object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
 {
     if ((this.contentType == XmlSchemaContentType.TextOnly) || (this.contentType == XmlSchemaContentType.Empty))
     {
         context.NeedValidateChildren = false;
     }
     errorCode = -1;
     return null;
 }
 public virtual object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
 {
     if ((this.contentType == XmlSchemaContentType.TextOnly) || (this.contentType == XmlSchemaContentType.Empty))
     {
         context.NeedValidateChildren = false;
     }
     errorCode = -1;
     return(null);
 }
 public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
 {
     ArrayList particles = new ArrayList();
     foreach (DictionaryEntry entry in this.elements)
     {
         if (!context.AllElementsSet[(int) entry.Value] && (!isRequiredOnly || this.isRequired[(int) entry.Value]))
         {
             ContentValidator.AddParticleToExpected(this.particles[(int) entry.Value] as XmlSchemaParticle, schemaSet, particles);
         }
     }
     return particles;
 }
示例#17
0
        public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
        {
            ArrayList particles = new ArrayList();

            foreach (DictionaryEntry entry in this.elements)
            {
                if (!context.AllElementsSet[(int)entry.Value] && (!isRequiredOnly || this.isRequired[(int)entry.Value]))
                {
                    ContentValidator.AddParticleToExpected(this.particles[(int)entry.Value] as XmlSchemaParticle, schemaSet, particles);
                }
            }
            return(particles);
        }
示例#18
0
 private void Push(XmlQualifiedName elementName)
 {
     context = (ValidationState)_validationStack.Push();
     if (context == null)
     {
         context = new ValidationState();
         _validationStack.AddToTop(context);
     }
     context.LocalName            = elementName.Name;
     context.Namespace            = elementName.Namespace;
     context.HasMatched           = false;
     context.IsNill               = false;
     context.NeedValidateChildren = false;
 }
 public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
 {
     ArrayList particles = new ArrayList();
     BitSet set = context.CurPos[context.CurrentState.CurPosIndex];
     for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
     {
         XmlSchemaParticle p = (XmlSchemaParticle) this.positions[i].particle;
         if (p != null)
         {
             ContentValidator.AddParticleToExpected(p, schemaSet, particles);
         }
     }
     return particles;
 }
示例#20
0
        public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
        {
            ArrayList particles = new ArrayList();
            BitSet    set       = context.CurPos[context.CurrentState.CurPosIndex];

            for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
            {
                XmlSchemaParticle p = (XmlSchemaParticle)this.positions[i].particle;
                if (p != null)
                {
                    ContentValidator.AddParticleToExpected(p, schemaSet, particles);
                }
            }
            return(particles);
        }
 public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
 {
     ArrayList list = null;
     foreach (DictionaryEntry entry in this.elements)
     {
         if (!context.AllElementsSet[(int) entry.Value] && (!isRequiredOnly || this.isRequired[(int) entry.Value]))
         {
             if (list == null)
             {
                 list = new ArrayList();
             }
             list.Add(entry.Key);
         }
     }
     return list;
 }
示例#22
0
        public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
        {
            ArrayList list = null;

            foreach (DictionaryEntry entry in this.elements)
            {
                if (!context.AllElementsSet[(int)entry.Value] && (!isRequiredOnly || this.isRequired[(int)entry.Value]))
                {
                    if (list == null)
                    {
                        list = new ArrayList();
                    }
                    list.Add(entry.Key);
                }
            }
            return(list);
        }
 private void Push(XmlQualifiedName elementName)
 {
     context = (ValidationState)validationStack.Push();
     if (context == null)
     {
         context = new ValidationState();
         validationStack.AddToTop(context);
     }
     context.LocalName            = elementName.Name;
     context.Namespace            = elementName.Namespace;
     context.HasMatched           = false;
     context.IsNill               = false;
     context.ProcessContents      = processContents;
     context.NeedValidateChildren = false;
     context.Constr               = null; //resetting the constraints to be null incase context != null
                                          // when pushing onto stack;
 }
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
        {
            int index = this.symbols[name];
            int num2  = this.transitionTable[context.CurrentState.State][index];

            errorCode = 0;
            if (num2 != -1)
            {
                context.CurrentState.State = num2;
                context.HasMatched         = this.transitionTable[context.CurrentState.State][this.symbols.Count] > 0;
                return(this.symbols.GetParticle(index));
            }
            if (!base.IsOpen || !context.HasMatched)
            {
                context.NeedValidateChildren = false;
                errorCode = -1;
            }
            return(null);
        }
示例#25
0
        internal Validator(XmlNameTable nameTable, SchemaNames schemaNames, XmlValidatingReader reader) {
            this.nameTable = nameTable;
            this.schemaNames = schemaNames;
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            nsManager = reader.NamespaceManager;
            if (nsManager == null) {
                nsManager = new XmlNamespaceManager(nameTable);
                isProcessContents = true;
            }
            SchemaInfo = new SchemaInfo(schemaNames);

            validationStack = new HWStack(STACK_INCREMENT);
            textValue = new StringBuilder();
            this.name = XmlQualifiedName.Empty;
            attPresence = new Hashtable();
            context = null;
            attnDef = null;
        }
        public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
        {
            ArrayList list = null;

            if (context.RunningPositions != null)
            {
                List <RangePositionInfo> runningPositions = context.RunningPositions;
                BitSet set = new BitSet(this.positions.Count);
                for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--)
                {
                    set.Or(runningPositions[i].curpos);
                }
                for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j))
                {
                    if (list == null)
                    {
                        list = new ArrayList();
                    }
                    if (this.positions[j].symbol >= 0)
                    {
                        XmlSchemaParticle particle = this.positions[j].particle as XmlSchemaParticle;
                        if (particle == null)
                        {
                            string str = this.symbols.NameOf(this.positions[j].symbol);
                            if (str.Length != 0)
                            {
                                list.Add(str);
                            }
                        }
                        else
                        {
                            string nameString = particle.NameString;
                            if (!list.Contains(nameString))
                            {
                                list.Add(nameString);
                            }
                        }
                    }
                }
            }
            return(list);
        }
 public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
 {
     ArrayList particles = new ArrayList();
     int[] numArray = this.transitionTable[context.CurrentState.State];
     if (numArray != null)
     {
         for (int i = 0; i < (numArray.Length - 1); i++)
         {
             if (numArray[i] != -1)
             {
                 XmlSchemaParticle p = (XmlSchemaParticle) this.symbols.GetParticle(i);
                 if (p != null)
                 {
                     ContentValidator.AddParticleToExpected(p, schemaSet, particles);
                 }
             }
         }
     }
     return particles;
 }
        public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet)
        {
            ArrayList particles = new ArrayList();

            int[] numArray = this.transitionTable[context.CurrentState.State];
            if (numArray != null)
            {
                for (int i = 0; i < (numArray.Length - 1); i++)
                {
                    if (numArray[i] != -1)
                    {
                        XmlSchemaParticle p = (XmlSchemaParticle)this.symbols.GetParticle(i);
                        if (p != null)
                        {
                            ContentValidator.AddParticleToExpected(p, schemaSet, particles);
                        }
                    }
                }
            }
            return(particles);
        }
        public override void InitValidation(ValidationState context)
        {
            int count = this.positions.Count;
            List <RangePositionInfo> runningPositions = context.RunningPositions;

            if (runningPositions != null)
            {
                runningPositions.Clear();
            }
            else
            {
                runningPositions         = new List <RangePositionInfo>();
                context.RunningPositions = runningPositions;
            }
            RangePositionInfo item = new RangePositionInfo {
                curpos        = this.firstpos.Clone(),
                rangeCounters = new decimal[this.minMaxNodesCount]
            };

            runningPositions.Add(item);
            context.CurrentState.NumberOfRunningPos = 1;
            context.HasMatched = item.curpos.Get(this.endMarkerPos);
        }
        public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
        {
            ArrayList list = null;

            int[] numArray = this.transitionTable[context.CurrentState.State];
            if (numArray != null)
            {
                for (int i = 0; i < (numArray.Length - 1); i++)
                {
                    if (numArray[i] != -1)
                    {
                        if (list == null)
                        {
                            list = new ArrayList();
                        }
                        XmlSchemaParticle particle = (XmlSchemaParticle)this.symbols.GetParticle(i);
                        if (particle == null)
                        {
                            string str = this.symbols.NameOf(i);
                            if (str.Length != 0)
                            {
                                list.Add(str);
                            }
                        }
                        else
                        {
                            string nameString = particle.NameString;
                            if (!list.Contains(nameString))
                            {
                                list.Add(nameString);
                            }
                        }
                    }
                }
            }
            return(list);
        }
 public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly)
 {
     ArrayList list = null;
     int[] numArray = this.transitionTable[context.CurrentState.State];
     if (numArray != null)
     {
         for (int i = 0; i < (numArray.Length - 1); i++)
         {
             if (numArray[i] != -1)
             {
                 if (list == null)
                 {
                     list = new ArrayList();
                 }
                 XmlSchemaParticle particle = (XmlSchemaParticle) this.symbols.GetParticle(i);
                 if (particle == null)
                 {
                     string str = this.symbols.NameOf(i);
                     if (str.Length != 0)
                     {
                         list.Add(str);
                     }
                 }
                 else
                 {
                     string nameString = particle.NameString;
                     if (!list.Contains(nameString))
                     {
                         list.Add(nameString);
                     }
                 }
             }
         }
     }
     return list;
 }
 public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) {
     ArrayList particles = new ArrayList();
     BitSet expectedPos;
     if (context.RunningPositions != null) {
         List<RangePositionInfo> runningPositions = context.RunningPositions;
         expectedPos = new BitSet(positions.Count);
         for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) { 
             Debug.Assert(runningPositions[i].curpos != null);
             expectedPos.Or(runningPositions[i].curpos);
         }
         for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) {
             int symbol = positions[pos].symbol;
             if (symbol >= 0) { //non range nodes
                 XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle;
                 if (p == null) {
                    continue;
                 }
                 AddParticleToExpected(p, schemaSet, particles);
             }
         }
     }
     return particles;
 }
 public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) {
     ArrayList names = null;
     BitSet expectedPos;
     if (context.RunningPositions != null) {
         List<RangePositionInfo> runningPositions = context.RunningPositions;
         expectedPos = new BitSet(positions.Count);
         for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) {
             Debug.Assert(runningPositions[i].curpos != null);
             expectedPos.Or(runningPositions[i].curpos);
         }
         for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) {
             if (names == null) {
                 names = new ArrayList();
             }
             int symbol = positions[pos].symbol;
             if (symbol >= 0) { //non range nodes
                 XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle;
                 if (p == null) {
                     string s = symbols.NameOf(positions[pos].symbol);
                     if (s.Length != 0) {
                         names.Add(s);
                     }
                 }
                 else {
                     string s = p.NameString;
                     if (!names.Contains(s)) {
                         names.Add(s);
                     }
                 }
             }
         }
     }
     return names;
 }
 public override bool CompleteValidation(ValidationState context) {
     return context.HasMatched;
 }
        private void CheckXsdContent(ValidationState context, XmlQualifiedName qname, ref XmlSchemaContentProcessing processContents)
        {
            ContentNode  cnode     = context.CurrentNode;
            Object       lookup    = symbolTable[qname];
            int          terminals = symbols.Count;
            MinMaxNode   ln;
            InternalNode inNode;
            MinMaxValues mm;
            int          NodeMatched = context.HasNodeMatched;

            while (true)
            {
                switch (cnode.NodeType)
                {
                case ContentNode.Type.Any:
                case ContentNode.Type.Terminal:
                    context.HasNodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                    context.CurrentNode    = cnode.ParentNode;
                    context.HasMatched     = (cnode.ParentNode == endNode);
                    if (cnode.NodeType == ContentNode.Type.Any)
                    {
                        processContents = ((AnyNode)cnode).ProcessContents;
                    }
                    return;

                case ContentNode.Type.Sequence:
                    inNode = (InternalNode)cnode;
                    if (NodeMatched == 0)
                    {
                        if (inNode.LeftNode.Accepts(qname))
                        {
                            cnode = inNode.LeftNode;
                            break;
                        }
                        else if (inNode.LeftNode.Nullable())
                        {
                            NodeMatched = 1;
                        }
                        else
                        {
                            goto error;
                        }
                    }

                    if (NodeMatched == 1)
                    {
                        if (inNode.RightNode.Accepts(qname))
                        {
                            NodeMatched = 0;
                            cnode       = inNode.RightNode;
                            break;
                        }
                        else if (inNode.RightNode.Nullable())
                        {
                            NodeMatched = 2;
                        }
                        else
                        {
                            goto error;
                        }
                    }

                    if (NodeMatched == 2)
                    {
                        if (cnode.ParentNode != null)
                        {
                            if (((InternalNode)cnode.ParentNode).LeftNode == cnode)
                            {
                                NodeMatched = 1;
                            }
                            cnode = cnode.ParentNode;
                            break;
                        }
                        else
                        {
                            goto error;
                        }
                    }
                    break;

                case ContentNode.Type.Choice:
                    inNode = (InternalNode)cnode;
                    if (NodeMatched != 0)
                    {
                        NodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                        cnode       = cnode.ParentNode;
                    }
                    else if (inNode.LeftNode.Accepts(qname))
                    {
                        NodeMatched = 0;
                        cnode       = inNode.LeftNode;
                    }
                    else if (inNode.RightNode.Accepts(qname))
                    {
                        NodeMatched = 0;
                        cnode       = inNode.RightNode;
                    }
                    else
                    {
                        goto error;
                    }
                    break;

                case ContentNode.Type.Qmark:
                    inNode = (InternalNode)cnode;
                    if (NodeMatched != 0)
                    {
                        NodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                        cnode       = cnode.ParentNode;
                    }
                    else if (inNode.LeftNode.Accepts(qname))
                    {
                        cnode = inNode.LeftNode;
                    }
                    else
                    {
                        goto error;
                    }
                    break;

                case ContentNode.Type.Star:
                case ContentNode.Type.Plus:
                    inNode = (InternalNode)cnode;
                    if (inNode.LeftNode.Accepts(qname))
                    {
                        NodeMatched = 0;
                        cnode       = inNode.LeftNode;
                    }
                    else
                    {
                        NodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                        cnode       = cnode.ParentNode;
                    }
                    break;

                case ContentNode.Type.MinMax:
                    inNode = (InternalNode)cnode;
                    ln     = (MinMaxNode)cnode;
                    mm     = null;
                    if (context.MinMaxValues != null)
                    {
                        mm = (MinMaxValues)context.MinMaxValues[ln];
                    }
                    else
                    {
                        context.MinMaxValues = new Hashtable();
                    }
                    if (mm == null)
                    {
                        // new minmaxnode and add it to minmaxnodes hashtable
                        mm = new MinMaxValues(ln.Min, ln.Max);
                        context.MinMaxValues.Add(ln, mm);
                    }

                    if (mm.Max == 0)
                    {
                        NodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                        cnode       = cnode.ParentNode;
                        mm.Max      = ln.Max;
                        mm.Min      = ln.Min;
                    }
                    else if (inNode.LeftNode.Accepts(qname))
                    {
                        mm.Max     -= 1;
                        mm.Min     -= 1;
                        NodeMatched = 0;
                        cnode       = inNode.LeftNode;
                    }
                    else
                    {
                        if (mm.Min > 0)
                        {
                            goto error;
                        }
                        NodeMatched = (((InternalNode)cnode.ParentNode).LeftNode == cnode) ? 1 : 2;
                        cnode       = cnode.ParentNode;
                        mm.Max      = ln.Max;
                        mm.Min      = ln.Min;
                    }
                    break;
                } // switch
            }     // while (true)

error:
            context.NeedValidateChildren = false;
            ArrayList v = ExpectedXsdElements(context.CurrentNode, NodeMatched);

            if (v == null)
            {
                throw new XmlSchemaException(Res.Sch_InvalidContent, context.Name.ToString());
            }
            else
            {
                throw new XmlSchemaException(Res.Sch_InvalidContentExpecting, new string[] { context.Name.ToString(), v.ToString() });
            }
        }
 public virtual ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) {
     return null;
 }
 public virtual object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) {
     if (contentType == XmlSchemaContentType.TextOnly || contentType == XmlSchemaContentType.Empty) { //Cannot have elements in TextOnly or Empty content
         context.NeedValidateChildren = false;
     }
     errorCode = -1;
     return null;
 }
 public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) {
     ArrayList names = null;
     foreach (DictionaryEntry entry in elements) {
         if (!context.AllElementsSet[(int)entry.Value] && (!isRequiredOnly || isRequired[(int)entry.Value])) {
             if (names == null) {
                 names = new ArrayList();
             }
             names.Add(entry.Key);
         }
     }
     return names;
 }
示例#39
0
 public override void InitValidation(ValidationState context)
 {
     context.AllElementsSet = new BitSet(this.elements.Count);
     context.CurrentState.AllElementsRequired = -1;
 }
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
        {
            RangePositionInfo info;

            errorCode = 0;
            int  num  = this.symbols[name];
            bool flag = false;
            List <RangePositionInfo> runningPositions = context.RunningPositions;
            int  numberOfRunningPos = context.CurrentState.NumberOfRunningPos;
            int  count = 0;
            int  index = -1;
            int  num5  = -1;
            bool flag2 = false;

            while (count < numberOfRunningPos)
            {
                info = runningPositions[count];
                BitSet curpos = info.curpos;
                for (int i = curpos.NextSet(-1); i != -1; i = curpos.NextSet(i))
                {
                    if (num == this.positions[i].symbol)
                    {
                        index = i;
                        if (num5 == -1)
                        {
                            num5 = count;
                        }
                        flag2 = true;
                        break;
                    }
                }
                if (flag2 && (this.positions[index].particle is XmlSchemaElement))
                {
                    break;
                }
                count++;
            }
            if ((count == numberOfRunningPos) && (index != -1))
            {
                count = num5;
            }
            if (count < numberOfRunningPos)
            {
                if (count != 0)
                {
                    runningPositions.RemoveRange(0, count);
                }
                numberOfRunningPos -= count;
                count = 0;
                while (count < numberOfRunningPos)
                {
                    info = runningPositions[count];
                    if (info.curpos.Get(index))
                    {
                        info.curpos             = this.followpos[index];
                        runningPositions[count] = info;
                        count++;
                    }
                    else
                    {
                        numberOfRunningPos--;
                        if (numberOfRunningPos > 0)
                        {
                            RangePositionInfo info2 = runningPositions[numberOfRunningPos];
                            runningPositions[numberOfRunningPos] = runningPositions[count];
                            runningPositions[count] = info2;
                        }
                    }
                }
            }
            else
            {
                numberOfRunningPos = 0;
            }
            if (numberOfRunningPos > 0)
            {
                if (numberOfRunningPos >= 0x2710)
                {
                    context.TooComplex  = true;
                    numberOfRunningPos /= 2;
                }
                for (count = numberOfRunningPos - 1; count >= 0; count--)
                {
                    int    num7 = count;
                    BitSet set2 = runningPositions[count].curpos;
                    flag = flag || set2.Get(this.endMarkerPos);
                    while ((numberOfRunningPos < 0x2710) && set2.Intersects(this.positionsWithRangeTerminals))
                    {
                        BitSet set3 = set2.Clone();
                        set3.And(this.positionsWithRangeTerminals);
                        int           num8     = set3.NextSet(-1);
                        LeafRangeNode particle = this.positions[num8].particle as LeafRangeNode;
                        info = runningPositions[num7];
                        if ((numberOfRunningPos + 2) >= runningPositions.Count)
                        {
                            RangePositionInfo item = new RangePositionInfo();
                            runningPositions.Add(item);
                            RangePositionInfo info5 = new RangePositionInfo();
                            runningPositions.Add(info5);
                        }
                        RangePositionInfo info3 = runningPositions[numberOfRunningPos];
                        if (info3.rangeCounters == null)
                        {
                            info3.rangeCounters = new decimal[this.minMaxNodesCount];
                        }
                        Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length);
                        decimal num9 = info3.rangeCounters[particle.Pos] = decimal.op_Increment(info3.rangeCounters[particle.Pos]);
                        if (num9 == particle.Max)
                        {
                            info3.curpos = this.followpos[num8];
                            info3.rangeCounters[particle.Pos]    = 0M;
                            runningPositions[numberOfRunningPos] = info3;
                            num7 = numberOfRunningPos++;
                        }
                        else
                        {
                            if (num9 < particle.Min)
                            {
                                info3.curpos = particle.NextIteration;
                                runningPositions[numberOfRunningPos] = info3;
                                numberOfRunningPos++;
                                break;
                            }
                            info3.curpos = particle.NextIteration;
                            runningPositions[numberOfRunningPos] = info3;
                            num7  = numberOfRunningPos + 1;
                            info3 = runningPositions[num7];
                            if (info3.rangeCounters == null)
                            {
                                info3.rangeCounters = new decimal[this.minMaxNodesCount];
                            }
                            Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length);
                            info3.curpos = this.followpos[num8];
                            info3.rangeCounters[particle.Pos] = 0M;
                            runningPositions[num7]            = info3;
                            numberOfRunningPos += 2;
                        }
                        set2 = runningPositions[num7].curpos;
                        flag = flag || set2.Get(this.endMarkerPos);
                    }
                }
                context.HasMatched = flag;
                context.CurrentState.NumberOfRunningPos = numberOfRunningPos;
                return(this.positions[index].particle);
            }
            errorCode = -1;
            context.NeedValidateChildren = false;
            return(null);
        }
 public override bool CompleteValidation(ValidationState context)
 {
     return(context.HasMatched);
 }
示例#42
0
 public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
 {
     throw new InvalidOperationException();
 }
 public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) {
     // ParticleContentValidator cannot be used during validation
     throw new InvalidOperationException();
 }
 private void Pop()
 {
     ValidationState state = (ValidationState) this.validationStack.Pop();
     if (this.startIDConstraint == this.validationStack.Length)
     {
         this.startIDConstraint = -1;
     }
     this.context = (ValidationState) this.validationStack.Peek();
     if (state.Validity == XmlSchemaValidity.Invalid)
     {
         this.context.Validity = XmlSchemaValidity.Invalid;
     }
     if (state.ValidationSkipped)
     {
         this.context.ValidationSkipped = true;
     }
     this.processContents = this.context.ProcessContents;
 }
 internal static void CompleteValidationError(ValidationState context, System.Xml.Schema.ValidationEventHandler eventHandler, object sender, string sourceUri, int lineNo, int linePos, XmlSchemaSet schemaSet)
 {
     ArrayList expected = null;
     bool getParticles = schemaSet != null;
     if (context.ElementDecl != null)
     {
         if (getParticles)
         {
             expected = context.ElementDecl.ContentValidator.ExpectedParticles(context, true, schemaSet);
         }
         else
         {
             expected = context.ElementDecl.ContentValidator.ExpectedElements(context, true);
         }
     }
     if ((expected == null) || (expected.Count == 0))
     {
         if (context.TooComplex)
         {
             SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_IncompleteContentComplex", new string[] { BuildElementName(context.LocalName, context.Namespace), Res.GetString("Sch_ComplexContentModel") }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
         }
         SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_IncompleteContent", BuildElementName(context.LocalName, context.Namespace), sourceUri, lineNo, linePos), XmlSeverityType.Error);
     }
     else if (context.TooComplex)
     {
         SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_IncompleteContentExpectingComplex", new string[] { BuildElementName(context.LocalName, context.Namespace), PrintExpectedElements(expected, getParticles), Res.GetString("Sch_ComplexContentModel") }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
     }
     else
     {
         SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_IncompleteContentExpecting", new string[] { BuildElementName(context.LocalName, context.Namespace), PrintExpectedElements(expected, getParticles) }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
     }
 }
 public override void InitValidation(ValidationState context) {
     Debug.Assert(elements.Count > 0);
     context.AllElementsSet = new BitSet(elements.Count); //
     context.CurrentState.AllElementsRequired = -1; // no elements at all
 }
 public override bool CompleteValidation(ValidationState context) {
     if (context.CurrentState.AllElementsRequired == countRequired || IsEmptiable && context.CurrentState.AllElementsRequired == -1) {
         return true;
     }
     return false;
 }
示例#48
0
 public override void InitValidation(ValidationState context)
 {
     context.CurPos[0] = this.firstpos.Clone();
     context.CurPos[1] = new BitSet(this.firstpos.Count);
     context.CurrentState.CurPosIndex = 0;
 }
 public virtual void InitValidation(ValidationState context) {
     // do nothin'
 }
示例#50
0
 public override bool CompleteValidation(ValidationState context)
 {
     throw new InvalidOperationException();
 }
 public virtual bool CompleteValidation(ValidationState context) {
     return true;
 }
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) {
            errorCode = 0;
            int symbol = symbols[name];
            bool hasSeenFinalPosition = false;
            List<RangePositionInfo> runningPositions = context.RunningPositions;
            int matchCount = context.CurrentState.NumberOfRunningPos;
            int k = 0; 
            RangePositionInfo rposInfo;
            
            int pos = -1;
            int firstMatchedIndex = -1;
            bool matched = false;

#if RANGE_DEBUG
            WriteRunningPositions("Current running positions to match", runningPositions, name, matchCount);
#endif

            while (k < matchCount) { //we are looking for the first match in the list of bitsets
                rposInfo = runningPositions[k];
                BitSet curpos = rposInfo.curpos;
                for (int matchpos = curpos.NextSet(-1); matchpos != -1; matchpos = curpos.NextSet(matchpos)) { //In all sets, have to scan all positions because of Disabled UPA possibility
                    if (symbol == positions[matchpos].symbol) {
                        pos = matchpos; 
                        if (firstMatchedIndex == -1) { // get the first match for this symbol
                            firstMatchedIndex = k;
                        }
                        matched = true;
                        break;
                    }
                }
                if (matched && positions[pos].particle is XmlSchemaElement) { //We found a match in the list, break at that bitset
                    break;
                }
                else {
                    k++;
                }
            }

            if (k == matchCount && pos != -1) { // we did find a match but that was any and hence continued ahead for element
                k = firstMatchedIndex;
            }
            if (k < matchCount) { //There is a match
                if (k != 0) { //If the first bitset itself matched, then no need to remove anything
#if RANGE_DEBUG
                    WriteRunningPositions("Removing unmatched entries till the first match", runningPositions, XmlQualifiedName.Empty, k);
#endif
                    runningPositions.RemoveRange(0, k); //Delete entries from 0 to k-1
                }
                matchCount = matchCount - k;
                k = 0; // Since we re-sized the array
                while (k < matchCount) {
                    rposInfo = runningPositions[k];
                    matched = rposInfo.curpos.Get(pos); //Look for the bitset that matches the same position as pos
                    if (matched) { //If match found, get the follow positions of the current matched position
#if RANGE_DEBUG
                        Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "Matched position: " + pos + " "); SequenceNode.WriteBitSet(rposInfo.curpos);
                        Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "Follow pos of Matched position: "); SequenceNode.WriteBitSet(followpos[pos]);
#endif
                        rposInfo.curpos = followpos[pos]; //Note that we are copying the same counters of the current position to that of the follow position
                        runningPositions[k] = rposInfo; 
                        k++;
                    }
                    else { //Clear the current pos and get another position from the list to start matching
                        matchCount--;
                        if (matchCount > 0) {
                            RangePositionInfo lastrpos = runningPositions[matchCount];
                            runningPositions[matchCount] = runningPositions[k];
                            runningPositions[k] = lastrpos;
                        }
                    }
                }
            }
            else { //There is no match
                matchCount = 0;
            }

            if (matchCount > 0) {
                Debug.Assert(minMaxNodesCount > 0);
                if (matchCount >= 10000) {
                    context.TooComplex = true;
                    matchCount /= 2;
                }
#if RANGE_DEBUG
                WriteRunningPositions("Matched positions to expand ", runningPositions, name, matchCount);
#endif

                for (k = matchCount - 1; k >= 0; k--) { 
                    int j = k;
                    BitSet currentRunningPosition = runningPositions[k].curpos;
                    hasSeenFinalPosition = hasSeenFinalPosition || currentRunningPosition.Get(endMarkerPos); //Accepting position reached if the current position BitSet contains the endPosition
                    while (matchCount < 10000 && currentRunningPosition.Intersects(positionsWithRangeTerminals)) {
                        //Now might add 2 more positions to followpos 
                        //1. nextIteration of the rangeNode, which is firstpos of its parent's leftChild
                        //2. Followpos of the range node

                        BitSet countingPosition = currentRunningPosition.Clone();
                        countingPosition.And(positionsWithRangeTerminals);
                        int cPos = countingPosition.NextSet(-1); //Get the first position where leaf range node appears
                        LeafRangeNode lrNode = positions[cPos].particle as LeafRangeNode; //For a position with leaf range node, the particle is the node itself
                        Debug.Assert(lrNode != null);

                        rposInfo = runningPositions[j];
                        if (matchCount + 2 >= runningPositions.Count) {
                            runningPositions.Add(new RangePositionInfo());
                            runningPositions.Add(new RangePositionInfo());
                        }
                        RangePositionInfo newRPosInfo = runningPositions[matchCount];
                        if (newRPosInfo.rangeCounters == null) {
                            newRPosInfo.rangeCounters = new decimal[minMaxNodesCount];
                        }
                        Array.Copy(rposInfo.rangeCounters, 0, newRPosInfo.rangeCounters, 0, rposInfo.rangeCounters.Length);
                        decimal count = ++newRPosInfo.rangeCounters[lrNode.Pos];

                        if (count == lrNode.Max) {
                            newRPosInfo.curpos = followpos[cPos]; //since max has been reached, Get followposition of range node
                            newRPosInfo.rangeCounters[lrNode.Pos] = 0; //reset counter
                            runningPositions[matchCount] = newRPosInfo;
                            j = matchCount++;
                        }
                        else if (count < lrNode.Min) {
                            newRPosInfo.curpos = lrNode.NextIteration;
                            runningPositions[matchCount] = newRPosInfo;
                            matchCount++;
                            break;
                        }
                        else { // min <= count < max
                            newRPosInfo.curpos = lrNode.NextIteration; //set currentpos to firstpos of node which has the range
                            runningPositions[matchCount] = newRPosInfo;
                            j = matchCount + 1;
                            newRPosInfo = runningPositions[j];
                            if (newRPosInfo.rangeCounters == null) {
                                newRPosInfo.rangeCounters = new decimal[minMaxNodesCount];
                            }
                            Array.Copy(rposInfo.rangeCounters, 0, newRPosInfo.rangeCounters, 0, rposInfo.rangeCounters.Length);
                            newRPosInfo.curpos = followpos[cPos];
                            newRPosInfo.rangeCounters[lrNode.Pos] = 0;
                            runningPositions[j] = newRPosInfo;
                            matchCount += 2;
                        }
                        currentRunningPosition = runningPositions[j].curpos;
                        hasSeenFinalPosition = hasSeenFinalPosition || currentRunningPosition.Get(endMarkerPos);
                    }
                }
                context.HasMatched = hasSeenFinalPosition;
                context.CurrentState.NumberOfRunningPos = matchCount;
                return positions[pos].particle;
            } //matchcount > 0
            errorCode = -1;
            context.NeedValidateChildren = false;
            return null;
        }
 public virtual ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) {
     return null;
 }
 public override void InitValidation(ValidationState context)
 {
     context.CurrentState.State = 0;
     context.HasMatched         = this.transitionTable[0][this.symbols.Count] > 0;
 }
 public override bool CompleteValidation(ValidationState context) {
     // ParticleContentValidator cannot be used during validation
     throw new InvalidOperationException();
 }
示例#56
0
 public override void InitValidation(ValidationState context)
 {
     throw new InvalidOperationException();
 }
 private void Push(XmlQualifiedName elementName)
 {
     this.context = (ValidationState) this.validationStack.Push();
     if (this.context == null)
     {
         this.context = new ValidationState();
         this.validationStack.AddToTop(this.context);
     }
     this.context.LocalName = elementName.Name;
     this.context.Namespace = elementName.Namespace;
     this.context.HasMatched = false;
     this.context.IsNill = false;
     this.context.IsDefault = false;
     this.context.CheckRequiredAttribute = true;
     this.context.ValidationSkipped = false;
     this.context.Validity = XmlSchemaValidity.NotKnown;
     this.context.NeedValidateChildren = false;
     this.context.ProcessContents = this.processContents;
     this.context.ElementDeclBeforeXsi = null;
     this.context.Constr = null;
 }
        internal bool HasMatched(ValidationState context)
        {
            if (IsAllElements)
            {
                if (isAllEmptiable && context.AllElementsSet.IsEmpty)
                {
                    return(true);
                }
                else
                {
                    return(context.AllElementsSet.HasAllBits(this.allElementsSet));
                }
            }

            if (!IsCompiled)
            {
                // MIXED or ELEMENT
                int          NodeMatched = context.HasNodeMatched;
                InternalNode inNode      = (InternalNode)context.CurrentNode;
                if (inNode == contentNode)
                {
                    return(NodeMatched == 1 || inNode.LeftNode.Nullable());
                }
                while (inNode != contentNode)
                {
                    switch (inNode.NodeType)
                    {
                    case ContentNode.Type.Sequence:
                        if (((NodeMatched == 0) && (!inNode.LeftNode.Nullable() || !inNode.RightNode.Nullable())) ||
                            ((NodeMatched == 1) && !inNode.RightNode.Nullable()))
                        {
                            return(false);
                        }
                        break;

                    case ContentNode.Type.Choice:
                        if ((NodeMatched == 0) && !inNode.LeftNode.Nullable() && !inNode.LeftNode.Nullable())
                        {
                            return(false);
                        }
                        break;

                    case ContentNode.Type.Plus:
                        if ((NodeMatched == 0) && !inNode.LeftNode.Nullable())
                        {
                            return(false);
                        }
                        break;

                    case ContentNode.Type.MinMax: {
                        int          min;
                        MinMaxValues mm = (MinMaxValues)context.MinMaxValues[inNode];
                        if (mm == null)
                        {
                            min = ((MinMaxNode)inNode).Min;
                        }
                        else
                        {
                            min = mm.Min;
                        }
                        if ((min > 0) && !inNode.LeftNode.Nullable())
                        {
                            return(false);
                        }
                        break;
                    }

                    case ContentNode.Type.Star:
                    case ContentNode.Type.Qmark:
                    default:
                        break;
                    } // switch

                    NodeMatched = (((InternalNode)inNode.ParentNode).LeftNode == inNode) ? 1 : 2;
                    inNode      = (InternalNode)inNode.ParentNode;
                }

                return(NodeMatched == 1);
            }
            else
            {
                return(context.HasMatched);
            }
        }
 internal static void ElementValidationError(XmlQualifiedName name, ValidationState context, System.Xml.Schema.ValidationEventHandler eventHandler, object sender, string sourceUri, int lineNo, int linePos, XmlSchemaSet schemaSet)
 {
     ArrayList expected = null;
     if (context.ElementDecl != null)
     {
         ContentValidator contentValidator = context.ElementDecl.ContentValidator;
         XmlSchemaContentType contentType = contentValidator.ContentType;
         if ((contentType == XmlSchemaContentType.ElementOnly) || (((contentType == XmlSchemaContentType.Mixed) && (contentValidator != ContentValidator.Mixed)) && (contentValidator != ContentValidator.Any)))
         {
             bool getParticles = schemaSet != null;
             if (getParticles)
             {
                 expected = contentValidator.ExpectedParticles(context, false, schemaSet);
             }
             else
             {
                 expected = contentValidator.ExpectedElements(context, false);
             }
             if ((expected == null) || (expected.Count == 0))
             {
                 if (context.TooComplex)
                 {
                     SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementContentComplex", new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), Res.GetString("Sch_ComplexContentModel") }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
                 }
                 else
                 {
                     SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementContent", new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name) }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
                 }
             }
             else if (context.TooComplex)
             {
                 SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementContentExpectingComplex", new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), PrintExpectedElements(expected, getParticles), Res.GetString("Sch_ComplexContentModel") }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
             }
             else
             {
                 SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementContentExpecting", new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), PrintExpectedElements(expected, getParticles) }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
             }
         }
         else if (contentType == XmlSchemaContentType.Empty)
         {
             SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementInEmptyEx", new string[] { QNameString(context.LocalName, context.Namespace), name.ToString() }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
         }
         else if (!contentValidator.IsOpen)
         {
             SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException("Sch_InvalidElementInTextOnlyEx", new string[] { QNameString(context.LocalName, context.Namespace), name.ToString() }, sourceUri, lineNo, linePos), XmlSeverityType.Error);
         }
     }
 }
        internal void CheckContent(ValidationState context, XmlQualifiedName qname, ref XmlSchemaContentProcessing processContents)
        {
#if DEBUG
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, String.Format("\t\t\tSchemaContentModel.CheckContent({0}) in \"{1}\"", "\"" + qname.ToString() + "\"", context.Name));
#endif
            XmlQualifiedName n = qname.IsEmpty ? (schemaNames == null ? XmlQualifiedName.Empty : schemaNames.QnPCData) : qname;
            Object           lookup;

            if (context.IsNill)
            {
                throw new XmlSchemaException(Res.Sch_ContentInNill, context.Name.ToString());
            }

            switch (contentType)
            {
            case CompiledContentModel.Type.Any:
                context.HasMatched = true;
                return;

            case CompiledContentModel.Type.Empty:
                goto error;

            case CompiledContentModel.Type.Text:
                if (qname.IsEmpty)
                {
                    return;
                }
                else
                {
                    goto error;
                }

            case CompiledContentModel.Type.Mixed:
                if (qname.IsEmpty)
                {
                    return;
                }
                break;

            case CompiledContentModel.Type.ElementOnly:
                if (qname.IsEmpty)
                {
                    goto error;
                }
                break;

            default:
                break;
            }

            if (IsAllElements)
            {
                lookup = symbolTable[n];
                if (lookup != null)
                {
                    int index = (int)lookup;
                    if (context.AllElementsSet.Get(index))
                    {
                        throw new XmlSchemaException(Res.Sch_AllElement, qname.Name);
                    }
                    else
                    {
                        context.AllElementsSet.Set(index);
                    }
                }
                else
                {
                    goto error;
                }
                return;
            }
            if (!IsCompiled)
            {
                CheckXsdContent(context, qname, ref processContents);
                return;
            }

            lookup = symbolTable[n];

            if (lookup != null)
            {
                int sym = (int)lookup;
                if (sym != -1 && dtrans != null)
                {
                    int state = ((int[])dtrans[context.State])[sym];
                    if (state != -1)
                    {
                        context.State      = state;
                        context.HasMatched = ((int[])dtrans[context.State])[symbols.Count] > 0;
                        return;
                    }
                }
            }

            if (IsOpen && context.HasMatched)
            {
                // XDR allows any well-formed contents after matched.
                return;
            }

            //
            // report error
            //
            context.NeedValidateChildren = false;

error:

            ArrayList v = null;
            if (dtrans != null)
            {
                v = ExpectedElements(context.State, context.AllElementsSet);
            }
            if (v == null || v.Count == 0)
            {
                if (!(qname.IsEmpty))
                {
                    throw new XmlSchemaException(Res.Sch_InvalidElementContent, new string[] { context.Name.ToString(), n.ToString() });
                }
                else
                {
                    if (n.Name.Equals("#PCDATA"))
                    {
                        if (contentType == CompiledContentModel.Type.Empty)
                        {
                            throw new XmlSchemaException(Res.Sch_InvalidTextWhiteSpace);
                        }
                        else
                        {
                            throw new XmlSchemaException(Res.Sch_InvalidTextInElement, context.Name.ToString());
                        }
                    }
                    else
                    {
                        throw new XmlSchemaException(Res.Sch_InvalidContent, context.Name.ToString());
                    }
                }
            }
            else
            {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < v.Count; ++i)
                {
                    builder.Append(v[i].ToString());
                    if (i + 1 < v.Count)
                    {
                        builder.Append(" ");
                    }
                }
                if (qname.IsEmpty)
                {
                    if (n.Name.Equals("#PCDATA"))
                    {
                        throw new XmlSchemaException(Res.Sch_InvalidTextInElementExpecting, new string[] { context.Name.ToString(), builder.ToString() });
                    }
                    else
                    {
                        throw new XmlSchemaException(Res.Sch_InvalidContentExpecting, new string[] { context.Name.ToString(), builder.ToString() });
                    }
                }
                else
                {
                    throw new XmlSchemaException(Res.Sch_InvalidElementContentExpecting, new string[] { context.Name.ToString(), n.ToString(), builder.ToString() });
                }
            }
        }