Get() 공개 메소드

public Get ( int index ) : bool
index int
리턴 bool
 private void CheckDeterministic(BitSet set, int t, ValidationEventHandler eventHandler)
 {
     nodeTable.Clear();
     for (int i = 0; i < t; i++)
     {
         if (set.Get(i))
         {
             XmlQualifiedName n = ((TerminalNode)terminalNodes[i]).Name;
             if (!n.IsEmpty)
             {
                 if (nodeTable[n] == null)
                 {
                     nodeTable.Add(n, n);
                 }
                 else
                 {
                     if (eventHandler != null)
                     {
                         eventHandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_NonDeterministic, n.ToString())));
                     }
                     else
                     {
                         throw new XmlSchemaException(Res.Sch_NonDeterministic, n.ToString());
                     }
                 }
             }
         }
     }
 }
        /*
         *  returns names of all legal elements following the specified state
         */
        internal ArrayList ExpectedElements(int state, BitSet allElementsSet)
        {
            ArrayList names = new ArrayList();

            if (IsAllElements)
            {
                for (int i = 0; i < allElementsSet.Count; i++)
                {
                    if (!allElementsSet.Get(i))
                    {
                        names.Add(symbols[i]);
                    }
                }
            }
            else
            {
                if (IsCompiled)
                {
                    int[] t = null;
                    if (dtrans != null)
                    {
                        t = (int[])dtrans[state];
                    }
                    if (t != null)
                    {
                        for (int i = 0; i < terminalNodes.Count; i++)
                        {
                            XmlQualifiedName n = ((TerminalNode)terminalNodes[i]).Name;
                            if (!n.IsEmpty)
                            {
                                string name = n.ToString();
                                if (!names.Contains(name))
                                {
                                    Object lookup = symbolTable[n];
                                    if ((lookup != null) && (t[(int)lookup] != -1))
                                    {
                                        names.Add(name);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //need to deal with not compiled content model
                }
            }
            return(names);
        }
예제 #3
0
 private bool Accepts(ContentNode node, XmlQualifiedName qname, int positions, Object index)
 {
     if (index != null)
     {
         BitSet first = node.Firstpos(positions);
         for (int i = 0; i < first.Count; i++)
         {
             if (first.Get(i) && qname.Equals(((TerminalNode)terminalNodes[i]).Name))
             {
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         return(node.Accepts(qname));
     }
 }
예제 #4
0
        //  returns names of all legal elements following the specified state
         internal ArrayList ExpectedElements(int state, BitSet allElementsSet) {
            ArrayList names = new ArrayList();

            if (IsAllElements) {
                for (int i = 0; i < allElementsSet.Count; i++) {
                    if (!allElementsSet.Get(i)) {
                        names.Add(symbols[i]);
                    }
                }
            }
            else {
                if (IsCompiled) {
                    int[] t = null;
                    if (dtrans != null)
                        t = (int[])dtrans[state];
                    if (t!=null) {
                        for (int i = 0; i < terminalNodes.Count; i++) {
                            XmlQualifiedName n = ((TerminalNode)terminalNodes[i]).Name;
                            if (!n.IsEmpty) {
                                string name = n.ToString();
                                if (!names.Contains(name)) {
                                    Object lookup = symbolTable[n];
                                    if ((lookup != null) && (t[(int)lookup] != -1)) {
                                        names.Add(name);
                                    }
                                }
                            }
                        }
                    }
                }
                else {
                    //need to deal with not compiled content model
                }
            }
            return names;
        }
예제 #5
0
 private void CheckDeterministic(BitSet set, int t, ValidationEventHandler eventHandler) {
     nodeTable.Clear();
     for (int i = 0; i < t; i++) {
         if (set.Get(i)) {
             XmlQualifiedName n = ((TerminalNode)terminalNodes[i]).Name;
             if (!n.IsEmpty) {
                 if (nodeTable[n] == null) {
                     nodeTable.Add(n, n);
                 }
                 else {
                     if (eventHandler != null) {
                         eventHandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_NonDeterministic,n.ToString())));
                     }
                     else {
                         throw new XmlSchemaException(Res.Sch_NonDeterministic,n.ToString());
                     }
                 }
             }
         }
     }
 }
예제 #6
0
        internal void    Finish(ValidationEventHandler eventHandler, bool compile) {
            stack = null;
            IsCompiled = !abnormalContent && compile;
            if (contentNode == null)
                return;

#if DEBUG
            StringBuilder bb = new StringBuilder();
            contentNode.Dump(bb);
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, "\t\t\tContent: (" + bb.ToString() + ")");
#endif

            // add end node
            endNode = NewTerminalNode(XmlQualifiedName.Empty);
            contentNode = new InternalNode(contentNode, endNode, ContentNode.Type.Sequence);
            ((InternalNode)contentNode).LeftNode.ParentNode = contentNode;
            endNode.ParentNode = contentNode;

            if (!IsCompiled) {
                CheckXsdDeterministic(eventHandler);
                return;
            }

            if (nodeTable == null)
                nodeTable = new Hashtable();

            // calculate followpos
            int terminals = terminalNodes.Count;
            BitSet[] followpos = new BitSet[terminals];
            for (int i = 0; i < terminals; i++) {
                followpos[i] = new BitSet(terminals);
            }
            contentNode.CalcFollowpos(followpos);

            // state table
            ArrayList Dstates = new ArrayList(16);
            // transition table
            dtrans = new ArrayList(16);
            // lists unmarked states
            ArrayList unmarked = new ArrayList(16);
            // state lookup table
            Hashtable statetable = new Hashtable();

            BitSet empty = new BitSet(terminals);
            statetable.Add(empty, -1);

            // start with firstpos at the root
            BitSet set = contentNode.Firstpos(terminals);
            statetable.Add(set, Dstates.Count);
            unmarked.Add(set);
            Dstates.Add(set);

            int[] a = new int[symbols.Count + 1];
            dtrans.Add(a);
            if (set.Get(endNode.Pos)) {
                a[symbols.Count] = 1;   // accepting
            }

            // current state processed
            int state = 0;

            // check all unmarked states
            while (unmarked.Count > 0) {
                int[] t = (int[])dtrans[state];

                set = (BitSet)unmarked[0];
                CheckDeterministic(set, terminals, eventHandler);
                unmarked.RemoveAt(0);

                // check all input symbols
                for (int sym = 0; sym < symbols.Count; sym++) {
                    XmlQualifiedName n = (XmlQualifiedName)symbols[sym];
                    BitSet newset = new BitSet(terminals);

                    // if symbol is in the set add followpos to new set
                    for (int i = 0; i < terminals; i++) {
                        if (set.Get(i) && n.Equals(((TerminalNode)terminalNodes[i]).Name)) {
                            newset.Or(followpos[i]);
                        }
                    }

                    Object lookup = statetable[newset];
                    // this state will transition to
                    int transitionTo;
                    // if new set is not in states add it
                    if (lookup == null) {
                        transitionTo = Dstates.Count;
                        statetable.Add(newset, transitionTo);
                        unmarked.Add(newset);
                        Dstates.Add(newset);
                        a = new int[symbols.Count + 1];
                        dtrans.Add(a);
                        if (newset.Get(endNode.Pos)) {
                            a[symbols.Count] = 1;   // accepting
                        }
                    }
                    else {
                        transitionTo = (int)lookup;
                    }
                    // set the transition for the symbol
                    t[sym] = transitionTo;
                }
                state++;
            }

            nodeTable = null;
        }
        internal void    Finish(ValidationEventHandler eventHandler, bool compile)
        {
            stack      = null;
            IsCompiled = !abnormalContent && compile;
            if (contentNode == null)
            {
                return;
            }

#if DEBUG
            StringBuilder bb = new StringBuilder();
            contentNode.Dump(bb);
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, "\t\t\tContent: (" + bb.ToString() + ")");
#endif

            // add end node
            endNode     = NewTerminalNode(XmlQualifiedName.Empty);
            contentNode = new InternalNode(contentNode, endNode, ContentNode.Type.Sequence);
            ((InternalNode)contentNode).LeftNode.ParentNode = contentNode;
            endNode.ParentNode = contentNode;

            if (!IsCompiled)
            {
                CheckXsdDeterministic(eventHandler);
                return;
            }

            if (nodeTable == null)
            {
                nodeTable = new Hashtable();
            }

            // calculate followpos
            int      terminals = terminalNodes.Count;
            BitSet[] followpos = new BitSet[terminals];
            for (int i = 0; i < terminals; i++)
            {
                followpos[i] = new BitSet(terminals);
            }
            contentNode.CalcFollowpos(followpos);

            // state table
            ArrayList Dstates = new ArrayList(16);
            // transition table
            dtrans = new ArrayList(16);
            // lists unmarked states
            ArrayList unmarked = new ArrayList(16);
            // state lookup table
            Hashtable statetable = new Hashtable();

            BitSet empty = new BitSet(terminals);
            statetable.Add(empty, -1);

            // start with firstpos at the root
            BitSet set = contentNode.Firstpos(terminals);
            statetable.Add(set, Dstates.Count);
            unmarked.Add(set);
            Dstates.Add(set);

            int[] a = new int[symbols.Count + 1];
            dtrans.Add(a);
            if (set.Get(endNode.Pos))
            {
                a[symbols.Count] = 1;   // accepting
            }

            // current state processed
            int state = 0;

            // check all unmarked states
            while (unmarked.Count > 0)
            {
                int[] t = (int[])dtrans[state];

                set = (BitSet)unmarked[0];
                CheckDeterministic(set, terminals, eventHandler);
                unmarked.RemoveAt(0);

                // check all input symbols
                for (int sym = 0; sym < symbols.Count; sym++)
                {
                    XmlQualifiedName n      = (XmlQualifiedName)symbols[sym];
                    BitSet           newset = new BitSet(terminals);

                    // if symbol is in the set add followpos to new set
                    for (int i = 0; i < terminals; i++)
                    {
                        if (set.Get(i) && n.Equals(((TerminalNode)terminalNodes[i]).Name))
                        {
                            newset.Or(followpos[i]);
                        }
                    }

                    Object lookup = statetable[newset];
                    // this state will transition to
                    int transitionTo;
                    // if new set is not in states add it
                    if (lookup == null)
                    {
                        transitionTo = Dstates.Count;
                        statetable.Add(newset, transitionTo);
                        unmarked.Add(newset);
                        Dstates.Add(newset);
                        a = new int[symbols.Count + 1];
                        dtrans.Add(a);
                        if (newset.Get(endNode.Pos))
                        {
                            a[symbols.Count] = 1;   // accepting
                        }
                    }
                    else
                    {
                        transitionTo = (int)lookup;
                    }
                    // set the transition for the symbol
                    t[sym] = transitionTo;
                }
                state++;
            }

            nodeTable = null;
        }
        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);
        }
예제 #9
0
파일: compiler.cs 프로젝트: ArildF/masters
 private bool IsSequenceFromAll(XmlSchemaSequence derivedSequence, XmlSchemaAll baseAll) {
     if (!IsValidOccurrenceRangeRestriction(derivedSequence, baseAll) || derivedSequence.Items.Count > baseAll.Items.Count) {
         return false;
     }
     BitSet map = new BitSet(baseAll.Items.Count);
     foreach (XmlSchemaParticle p in derivedSequence.Items) {
         int i = GetMappingParticle(p, baseAll.Items);
         if (i >= 0) {
             if (map.Get(i)) {
                 return false;
             }
             else {
                 map.Set(i);
             }
         }
         else {
             return false;
         }
     }
     for (int i = 0; i < baseAll.Items.Count; i++) {
         if (!map.Get(i) && !IsParticleEmptiable((XmlSchemaParticle)baseAll.Items[i])) {
             return false;
         }
     }
     return true;
 }