示例#1
0
        internal override void CheckXsdDeterministic(ArrayList terminalNodes, out BitSet set, out NamespaceList any)
        {
            BitSet        lset = null, rset = null;
            NamespaceList lany = null, rany = null;

            switch (contentType)
            {
            case Type.Sequence:
                left.CheckXsdDeterministic(terminalNodes, out lset, out lany);
                right.CheckXsdDeterministic(terminalNodes, out rset, out rany);
                if (left.CanSkip())
                {
                    Join(terminalNodes, lset, lany, rset, rany, out set, out any);
                }
                else
                {
                    set = lset;
                    any = lany;
                }
                break;

            case Type.Choice:
                left.CheckXsdDeterministic(terminalNodes, out lset, out lany);
                right.CheckXsdDeterministic(terminalNodes, out rset, out rany);
                Join(terminalNodes, lset, lany, rset, rany, out set, out any);
                break;

            default:
                left.CheckXsdDeterministic(terminalNodes, out set, out any);
                break;
            }
            return;
        }
        /*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);
         *  }
         * }*/

        private void CheckXsdDeterministic(ValidationEventHandler eventHandler)
        {
            ContentNode   cnode = ((InternalNode)contentNode).LeftNode;
            BitSet        set   = null;
            NamespaceList any   = null;

            //
            //note: only need to callback once per non-deterministic content model so we use try catch here
            //
            try {
                cnode.CheckXsdDeterministic(terminalNodes, out set, out any);
            }
            catch (XmlSchemaException e) {
                if (eventHandler != null)
                {
                    eventHandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_NonDeterministicAny)));
                }
                else
                {
                    throw e;
                }
            }
        }