Example #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;
        }
Example #2
0
        private NamespaceList CompareSetToOther(NamespaceList other)
        {
            //clause 5.1
            NamespaceList nslist = null;

            if (this.set.Contains(other.targetNamespace)) //S contains negated ns
            {
                if (this.set.Contains(string.Empty))      // AND S contains absent
                {
                    nslist = new NamespaceList();         //any is the result
                }
                else                                      //clause 5.2
                {
                    nslist = new NamespaceList("##other", string.Empty);
                }
            }
            else if (this.set.Contains(string.Empty))   //clause 5.3 - Not expressible
            {
                nslist = null;
            }
            else   //clause 5.4 - Set S does not contain negated ns or absent
            {
                nslist = other.Clone();
            }
            return(nslist);
        }
Example #3
0
        public void AddNamespaceList(NamespaceList list, object particle, bool allowLocal)
        {
            switch (list.Type)
            {
            case NamespaceList.ListType.Any:
                this.particleLast = particle;
                return;

            case NamespaceList.ListType.Other:
                this.AddWildcard(list.Excluded, null);
                if (allowLocal)
                {
                    break;
                }
                this.AddWildcard(string.Empty, null);
                return;

            case NamespaceList.ListType.Set:
                foreach (string str in list.Enumerate)
                {
                    this.AddWildcard(str, particle);
                }
                break;

            default:
                return;
            }
        }
Example #4
0
 public static bool IsSubset(NamespaceList sub, NamespaceList super)
 {
     if (super.type != ListType.Any)
     {
         if ((sub.type == ListType.Other) && (super.type == ListType.Other))
         {
             return(super.targetNamespace == sub.targetNamespace);
         }
         if (sub.type != ListType.Set)
         {
             return(false);
         }
         if (super.type == ListType.Other)
         {
             return(!sub.set.Contains(super.targetNamespace));
         }
         foreach (string str in sub.set.Keys)
         {
             if (!super.set.Contains(str))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #5
0
        internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2)
        {
            NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList);

            if (nsl != null)
            {
                XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
                anyAttribute.namespaceList = nsl;
                if (o1.processContents == XmlSchemaContentProcessing.Strict ||
                    o1.processContents == XmlSchemaContentProcessing.None ||
                    o2.processContents == XmlSchemaContentProcessing.Strict ||
                    o2.processContents == XmlSchemaContentProcessing.None)
                {
                    anyAttribute.processContents = XmlSchemaContentProcessing.Strict;
                }
                else if (o1.processContents == XmlSchemaContentProcessing.Lax ||
                         o2.processContents == XmlSchemaContentProcessing.Lax)
                {
                    anyAttribute.processContents = XmlSchemaContentProcessing.Lax;
                }
                else
                {
                    anyAttribute.processContents = XmlSchemaContentProcessing.Skip;
                }
                anyAttribute.Annotation = o1.Annotation;
                return(anyAttribute);
            }
            else
            {
                // not expressible
                return(null);
            }
        }
Example #6
0
 public static bool IsSubset(NamespaceList sub, NamespaceList super)
 {
     if (super.type == ListType.Any)
     {
         return(true);
     }
     else if (sub.type == ListType.Other && super.type == ListType.Other)
     {
         return(super.targetNamespace == sub.targetNamespace);
     }
     else if (sub.type == ListType.Set)
     {
         if (super.type == ListType.Other)
         {
             return(!sub.set.Contains(super.targetNamespace));
         }
         else
         {
             Debug.Assert(super.type == ListType.Set);
             foreach (string ns in sub.set.Keys)
             {
                 if (!super.set.Contains(ns))
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Example #7
0
        public ICollection GetNamespaceListSymbols(NamespaceList list)
        {
            ArrayList list2 = new ArrayList();

            foreach (XmlQualifiedName name in this.names.Keys)
            {
                if ((name != XmlQualifiedName.Empty) && list.Allows(name))
                {
                    list2.Add(this.names[name]);
                }
            }
            if (this.wildcards != null)
            {
                foreach (string str in this.wildcards.Keys)
                {
                    if (list.Allows(str))
                    {
                        list2.Add(this.wildcards[str]);
                    }
                }
            }
            if ((list.Type == NamespaceList.ListType.Any) || (list.Type == NamespaceList.ListType.Other))
            {
                list2.Add(this.last);
            }
            return(list2);
        }
 internal void BuildNamespaceListV1Compat(string targetNamespace) {
     if (ns != null) {
         namespaceList = new NamespaceListV1Compat(ns, targetNamespace);
     }
     else {
         namespaceList = new NamespaceList(); //This is only ##any, hence base class is sufficient
     }
 }
 internal void BuildNamespaceList(string targetNamespace) {
     if (ns != null) {
         namespaceList = new NamespaceList(ns, targetNamespace);
     }
     else {
         namespaceList = new NamespaceList();
     }
 }
Example #10
0
        public NamespaceList Clone()
        {
            NamespaceList list = (NamespaceList)base.MemberwiseClone();

            if (this.type == ListType.Set)
            {
                list.set = (Hashtable)this.set.Clone();
            }
            return(list);
        }
 internal void BuildNamespaceListV1Compat(string targetNamespace)
 {
     if (ns != null)
     {
         namespaceList = new NamespaceListV1Compat(ns, targetNamespace);
     }
     else
     {
         namespaceList = new NamespaceList(); //This is only ##any, hence base class is sufficient
     }
 }
Example #12
0
 internal void BuildNamespaceList(string targetNamespace)
 {
     if (_ns != null)
     { //If namespace="" default to namespace="##any"
         _namespaceList = new NamespaceList(_ns, targetNamespace);
     }
     else
     {
         _namespaceList = new NamespaceList();
     }
 }
Example #13
0
 internal void BuildNamespaceList(string targetNamespace)
 {
     if (ns != null)
     {
         namespaceList = new NamespaceList(ns, targetNamespace);
     }
     else
     {
         namespaceList = new NamespaceList();
     }
 }
Example #14
0
        public NamespaceList Clone()
        {
            NamespaceList nsl = (NamespaceList)MemberwiseClone();

            if (type == ListType.Set)
            {
                Debug.Assert(set != null);
                nsl.set = (Hashtable)(set.Clone());
            }
            return(nsl);
        }
Example #15
0
        public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2)
        {
            NamespaceList nslist = null;

            if (o1.type == ListType.Any)
            {
                nslist = o2.Clone();
            }
            else if (o2.type == ListType.Any)
            {
                nslist = o1.Clone();
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other)
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    nslist = o1.Clone();
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)
            {
                nslist      = o1.Clone();
                nslist      = new NamespaceList();
                nslist.type = ListType.Set;
                nslist.set  = new Hashtable();
                foreach (string ns in o1.set.Keys)
                {
                    if (o2.set.Contains(ns))
                    {
                        nslist.set.Add(ns, ns);
                    }
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)
            {
                nslist = o1.Clone();
                if (nslist.set[o2.targetNamespace] != null)
                {
                    nslist.set.Remove(o2.targetNamespace);
                }
            }
            else if (o2.type == ListType.Set && o1.type == ListType.Other)
            {
                nslist = o2.Clone();
                if (nslist.set[o1.targetNamespace] != null)
                {
                    nslist.set.Remove(o1.targetNamespace);
                }
            }
            return(nslist);
        }
        internal static string ToString(NamespaceList list)
        {
            if (list == null)
            {
                return null;
            }
            switch (list.Type)
            {
                case NamespaceList.ListType.Any:
                    return "##any";

                case NamespaceList.ListType.Other:
                    return "##other";

                case NamespaceList.ListType.Set:
                {
                    ArrayList list2 = new ArrayList();
                    foreach (string str in list.Enumerate)
                    {
                        list2.Add(str);
                    }
                    list2.Sort();
                    StringBuilder builder = new StringBuilder();
                    bool flag = true;
                    foreach (string str2 in list2)
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        else
                        {
                            builder.Append(" ");
                        }
                        if (str2.Length == 0)
                        {
                            builder.Append("##local");
                        }
                        else
                        {
                            builder.Append(str2);
                        }
                    }
                    return builder.ToString();
                }
            }
            return list.ToString();
        }
Example #17
0
 private NamespaceList CompareSetToOther(NamespaceList other)
 {
     if (this.set.Contains(other.targetNamespace))
     {
         if (this.set.Contains(string.Empty))
         {
             return(new NamespaceList());
         }
         return(new NamespaceList("##other", string.Empty));
     }
     if (this.set.Contains(string.Empty))
     {
         return(null);
     }
     return(other.Clone());
 }
Example #18
0
        public static NamespaceList Union(NamespaceList o1, NamespaceList o2)
        {
            NamespaceList nslist = null;

            if (o1.type == ListType.Any)
            {
                nslist = new NamespaceList();
            }
            else if (o2.type == ListType.Any)
            {
                nslist = new NamespaceList();
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other)
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    nslist = o1.Clone();
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)
            {
                nslist = o1.Clone();
                foreach (string ns in o2.set.Keys)
                {
                    nslist.set[ns] = ns;
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)
            {
                if (o1.set.Contains(o2.targetNamespace))
                {
                    nslist = new NamespaceList();
                }
            }
            else if (o2.type == ListType.Set && o1.type == ListType.Other)
            {
                if (o2.set.Contains(o2.targetNamespace))
                {
                    nslist = new NamespaceList();
                }
                else
                {
                    nslist = o1.Clone();
                }
            }
            return(nslist);
        }
        internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat)
        {
            NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList, v1Compat);

            if (nsl != null)
            {
                XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
                anyAttribute._namespaceList  = nsl;
                anyAttribute.ProcessContents = o1.ProcessContents;
                anyAttribute.Annotation      = o1.Annotation;
                return(anyAttribute);
            }
            else
            {
                // not expressible
                return(null);
            }
        }
Example #20
0
        internal static XmlSchemaAnyAttribute Union(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2)
        {
            NamespaceList nsl = NamespaceList.Union(o1.NamespaceList, o2.NamespaceList);

            if (nsl != null)
            {
                XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
                anyAttribute.namespaceList   = nsl;
                anyAttribute.processContents = o1.processContents;
                anyAttribute.Annotation      = o1.Annotation;
                return(anyAttribute);
            }
            else
            {
                // not expressible
                return(null);
            }
        }
        /*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;
                }
            }
        }
 public void AddNamespaceList(NamespaceList namespaceList, object particle) {
     symbols.AddNamespaceList(namespaceList, particle, false);
     AddLeafNode(new NamespaceListNode(namespaceList, particle));
 }
 public ICollection GetNamespaceListSymbols(NamespaceList list) {
     ArrayList match = new ArrayList();
     foreach(XmlQualifiedName name in names.Keys) {
         if (name != XmlQualifiedName.Empty && list.Allows(name)) {
             match.Add(names[name]);
         }
     }
     if (wildcards != null) {
         foreach(string wildcard in wildcards.Keys) {
             if (list.Allows(wildcard)) {
                 match.Add(wildcards[wildcard]);
             }
         }              
     }
     if (list.Type == NamespaceList.ListType.Any || list.Type == NamespaceList.ListType.Other) {
         match.Add(last); // add wildcard
     }
     return match;
 }
Example #24
0
        public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList list = null;

            if (o1.type == ListType.Any)
            {
                return(new NamespaceList());
            }
            if (o2.type == ListType.Any)
            {
                return(new NamespaceList());
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
            {
                list = o1.Clone();
                foreach (string str in o2.set.Keys)
                {
                    list.set[str] = str;
                }
                return(list);
            }
            if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    return(o1.Clone());
                }
                return(new NamespaceList("##other", string.Empty));
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
            {
                if (v1Compat)
                {
                    if (o1.set.Contains(o2.targetNamespace))
                    {
                        return(new NamespaceList());
                    }
                    return(o2.Clone());
                }
                if (o2.targetNamespace != string.Empty)
                {
                    return(o1.CompareSetToOther(o2));
                }
                if (o1.set.Contains(string.Empty))
                {
                    return(new NamespaceList());
                }
                return(new NamespaceList("##other", string.Empty));
            }
            if ((o2.type != ListType.Set) || (o1.type != ListType.Other))
            {
                return(list);
            }
            if (v1Compat)
            {
                if (o2.set.Contains(o2.targetNamespace))
                {
                    return(new NamespaceList());
                }
                return(o1.Clone());
            }
            if (o1.targetNamespace != string.Empty)
            {
                return(o2.CompareSetToOther(o1));
            }
            if (o2.set.Contains(string.Empty))
            {
                return(new NamespaceList());
            }
            return(new NamespaceList("##other", string.Empty));
        }
Example #25
0
 internal override void CheckXsdDeterministic(ArrayList terminalNodes, out BitSet set, out NamespaceList any)
 {
     set = Firstpos(terminalNodes.Count);
     any = null;
 }
 public static bool IsSubset(NamespaceList sub, NamespaceList super)
 {
     if (super.type != ListType.Any)
     {
         if ((sub.type == ListType.Other) && (super.type == ListType.Other))
         {
             return (super.targetNamespace == sub.targetNamespace);
         }
         if (sub.type != ListType.Set)
         {
             return false;
         }
         if (super.type == ListType.Other)
         {
             return !sub.set.Contains(super.targetNamespace);
         }
         foreach (string str in sub.set.Keys)
         {
             if (!super.set.Contains(str))
             {
                 return false;
             }
         }
     }
     return true;
 }
 public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2, bool v1Compat)
 {
     NamespaceList list = null;
     if (o1.type == ListType.Any)
     {
         return o2.Clone();
     }
     if (o2.type == ListType.Any)
     {
         return o1.Clone();
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
     {
         list = o1.Clone();
         list.RemoveNamespace(o2.targetNamespace);
         if (!v1Compat)
         {
             list.RemoveNamespace(string.Empty);
         }
         return list;
     }
     if ((o1.type == ListType.Other) && (o2.type == ListType.Set))
     {
         list = o2.Clone();
         list.RemoveNamespace(o1.targetNamespace);
         if (!v1Compat)
         {
             list.RemoveNamespace(string.Empty);
         }
         return list;
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
     {
         list = o1.Clone();
         list = new NamespaceList {
             type = ListType.Set,
             set = new Hashtable()
         };
         foreach (string str in o1.set.Keys)
         {
             if (o2.set.Contains(str))
             {
                 list.set.Add(str, str);
             }
         }
         return list;
     }
     if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
     {
         if (o1.targetNamespace == o2.targetNamespace)
         {
             return o1.Clone();
         }
         if (v1Compat)
         {
             return list;
         }
         if (o1.targetNamespace == string.Empty)
         {
             return o2.Clone();
         }
         if (o2.targetNamespace == string.Empty)
         {
             list = o1.Clone();
         }
     }
     return list;
 }
Example #28
0
 public void AddNamespaceList(NamespaceList namespaceList, object particle)
 {
     this.symbols.AddNamespaceList(namespaceList, particle, false);
     this.AddLeafNode(new NamespaceListNode(namespaceList, particle));
 }
Example #29
0
 internal override void CheckXsdDeterministic(ArrayList terminalNodes, out BitSet set, out NamespaceList any)
 {
     set = null;
     any = this.any.NamespaceList;
 }
Example #30
0
 public static NamespaceList Union(NamespaceList o1, NamespaceList o2) {
     NamespaceList nslist = null;
     if (o1.type == ListType.Any) {
         nslist = new NamespaceList();
     }
     else if (o2.type == ListType.Any) {
         nslist = new NamespaceList();
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Other) {
         if (o1.targetNamespace == o2.targetNamespace) {
             nslist = o1.Clone();
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Set) {
         nslist = o1.Clone();
         foreach (string ns in o2.set.Keys) {
             nslist.set[ns] = ns;
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Other) {
         if (o1.set.Contains(o2.targetNamespace)) {
             nslist = new NamespaceList();
         }
     }
     else if (o2.type == ListType.Set && o1.type == ListType.Other) {
         if (o2.set.Contains(o2.targetNamespace)) {
             nslist = new NamespaceList();
         }
         else {
             nslist = o1.Clone();
         }
     }
     return nslist;
 }
 internal void BuildNamespaceList(string targetNamespace) {
     if (ns != null) { //If namespace="" default to namespace="##any"
         namespaceList = new NamespaceList(ns, targetNamespace);
     }
     else {
         namespaceList = new NamespaceList();
     }
 }
Example #32
0
 public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2) { 
     NamespaceList nslist = null;
     if (o1.type == ListType.Any) {
         nslist = o2.Clone();
     }
     else if (o2.type == ListType.Any) {
         nslist = o1.Clone();
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Other) {
         if (o1.targetNamespace == o2.targetNamespace) {
             nslist = o1.Clone();
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Set) {
         nslist =  o1.Clone();
         nslist = new NamespaceList();
         nslist.type = ListType.Set;
         nslist.set = new Hashtable();
         foreach(string ns in o1.set.Keys) {
             if (o2.set.Contains(ns)) {
                 nslist.set.Add(ns, ns);
             }
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Other) {
         nslist = o1.Clone();
         if (nslist.set[o2.targetNamespace] != null) {
             nslist.set.Remove(o2.targetNamespace);
         }
     }
     else if (o2.type == ListType.Set && o1.type == ListType.Other) {
         nslist = o2.Clone();
         if (nslist.set[o1.targetNamespace] != null) {
             nslist.set.Remove(o1.targetNamespace);
         }
     }
     return nslist;
 }
 private ElementAccessor[] ImportAny(XmlSchemaAny any, bool makeElement, string targetNamespace)
 {
     SpecialMapping mapping;
     mapping = new SpecialMapping {
         TypeDesc = base.Scope.GetTypeDesc(makeElement ? typeof(XmlElement) : typeof(XmlNode)),
         TypeName = mapping.TypeDesc.Name
     };
     TypeFlags canBeElementValue = TypeFlags.CanBeElementValue;
     if (makeElement)
     {
         canBeElementValue |= TypeFlags.CanBeTextValue;
     }
     this.RunSchemaExtensions(mapping, XmlQualifiedName.Empty, null, any, canBeElementValue);
     if (this.GenerateOrder && (any.Namespace != null))
     {
         NamespaceList list = new NamespaceList(any.Namespace, targetNamespace);
         if (list.Type == NamespaceList.ListType.Set)
         {
             ICollection enumerate = list.Enumerate;
             ElementAccessor[] accessorArray = new ElementAccessor[(enumerate.Count == 0) ? 1 : enumerate.Count];
             int num = 0;
             foreach (string str in list.Enumerate)
             {
                 ElementAccessor accessor = new ElementAccessor {
                     Mapping = mapping,
                     Any = true,
                     Namespace = str
                 };
                 accessorArray[num++] = accessor;
             }
             if (num > 0)
             {
                 return accessorArray;
             }
         }
     }
     ElementAccessor accessor2 = new ElementAccessor {
         Mapping = mapping,
         Any = true
     };
     return new ElementAccessor[] { accessor2 };
 }
Example #34
0
 internal abstract void CheckXsdDeterministic(ArrayList terminalNodes, out BitSet set, out NamespaceList any);
 public NamespaceListNode(NamespaceList namespaceList, object particle) {
     this.namespaceList = namespaceList;
     this.particle = particle;
 }
 public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
 {
     NamespaceList list = null;
     if (o1.type == ListType.Any)
     {
         return new NamespaceList();
     }
     if (o2.type == ListType.Any)
     {
         return new NamespaceList();
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
     {
         list = o1.Clone();
         foreach (string str in o2.set.Keys)
         {
             list.set[str] = str;
         }
         return list;
     }
     if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
     {
         if (o1.targetNamespace == o2.targetNamespace)
         {
             return o1.Clone();
         }
         return new NamespaceList("##other", string.Empty);
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
     {
         if (v1Compat)
         {
             if (o1.set.Contains(o2.targetNamespace))
             {
                 return new NamespaceList();
             }
             return o2.Clone();
         }
         if (o2.targetNamespace != string.Empty)
         {
             return o1.CompareSetToOther(o2);
         }
         if (o1.set.Contains(string.Empty))
         {
             return new NamespaceList();
         }
         return new NamespaceList("##other", string.Empty);
     }
     if ((o2.type != ListType.Set) || (o1.type != ListType.Other))
     {
         return list;
     }
     if (v1Compat)
     {
         if (o2.set.Contains(o2.targetNamespace))
         {
             return new NamespaceList();
         }
         return o1.Clone();
     }
     if (o1.targetNamespace != string.Empty)
     {
         return o2.CompareSetToOther(o1);
     }
     if (o2.set.Contains(string.Empty))
     {
         return new NamespaceList();
     }
     return new NamespaceList("##other", string.Empty);
 }
 public void AddNamespaceList(NamespaceList list, object particle, bool allowLocal) {
     switch (list.Type) {
     case NamespaceList.ListType.Any:
         particleLast = particle;   
         break;
     case NamespaceList.ListType.Other:
         // Create a symbol for the excluded namespace, but don't set a particle for it.
         AddWildcard(list.Excluded, null);
         if (!allowLocal) {
             AddWildcard(string.Empty, null); //##local is not allowed
         }
         break; 
     case NamespaceList.ListType.Set:
         foreach(string wildcard in list.Enumerate) {
             AddWildcard(wildcard, particle);
         }
         break;
     }
 }
Example #38
0
        private void Join(ArrayList terminalNodes, BitSet lset, NamespaceList lany, BitSet rset, NamespaceList rany, out BitSet set, out NamespaceList any)
        {
            if (lset != null)
            {
                if (rset != null)
                {
                    set = lset.Clone();
                    set.And(rset);
                    if (!set.IsEmpty)
                    {
                        goto error;
                    }
                    set.Or(lset);
                    set.Or(rset);
                }
                else
                {
                    set = lset;
                }
            }
            else
            {
                set = rset;
            }

            if (lany != null)
            {
                if (rany != null)
                {
                    NamespaceList list = NamespaceList.Intersection(rany, lany);
                    if (list == null || list.IsEmpty())
                    {
                        any = NamespaceList.Union(rany, lany);
                    }
                    else
                    {
                        goto error;
                    }
                }
                else
                {
                    any = lany;
                }
            }
            else
            {
                any = rany;
            }

            if (any != null && set != null)
            {
                for (int i = 0; i < set.Count; i++)
                {
                    if (set.Get(i) && any.Allows(((TerminalNode)terminalNodes[i]).Name))
                    {
                        goto error;
                    }
                }
            }
            return;

error:
            throw new XmlSchemaException(Res.Sch_NonDeterministicAny);
        }
 private NamespaceList CompareSetToOther(NamespaceList other)
 {
     if (this.set.Contains(other.targetNamespace))
     {
         if (this.set.Contains(string.Empty))
         {
             return new NamespaceList();
         }
         return new NamespaceList("##other", string.Empty);
     }
     if (this.set.Contains(string.Empty))
     {
         return null;
     }
     return other.Clone();
 }
 public static bool IsSubset(NamespaceList sub, NamespaceList super) {
     if (super.type == ListType.Any) {
         return true;
     }
     else if (sub.type == ListType.Other && super.type == ListType.Other) {
         return super.targetNamespace == sub.targetNamespace;
     }
     else  if (sub.type == ListType.Set) {
         if (super.type == ListType.Other) {
             return !sub.set.Contains(super.targetNamespace);
         }
         else {
             Debug.Assert(super.type == ListType.Set);
             foreach (string ns in sub.set.Keys) {
                 if (!super.set.Contains(ns)) {
                     return false;
                 }
             }
             return true;
         }           
     }
     return false;
 }
Example #41
0
        public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList nslist = null;

            Debug.Assert(o1 != o2);
            if (o1.type == ListType.Any)   //clause 2 - o1 is Any
            {
                nslist = new NamespaceList();
            }
            else if (o2.type == ListType.Any)   //clause 2 - o2 is Any
            {
                nslist = new NamespaceList();
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)   //clause 3 , both are sets
            {
                nslist = o1.Clone();
                foreach (string ns in o2.set.Keys)
                {
                    nslist.set[ns] = ns;
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other) //clause 4, both are negations
            {
                if (o1.targetNamespace == o2.targetNamespace)                //negation of same value
                {
                    nslist = o1.Clone();
                }
                else                                                     //Not a breaking change, going from not expressible to not(absent)
                {
                    nslist = new NamespaceList("##other", string.Empty); //clause 4, negations of different values, result is not(absent)
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)
            {
                if (v1Compat)
                {
                    if (o1.set.Contains(o2.targetNamespace))
                    {
                        nslist = new NamespaceList();
                    }
                    else   //This was not there originally in V1, added for consistency since its not breaking
                    {
                        nslist = o2.Clone();
                    }
                }
                else
                {
                    if (o2.targetNamespace != string.Empty)   //clause 5, o1 is set S, o2 is not(tns)
                    {
                        nslist = o1.CompareSetToOther(o2);
                    }
                    else if (o1.set.Contains(string.Empty))   //clause 6.1 - set S includes absent, o2 is not(absent)
                    {
                        nslist = new NamespaceList();
                    }
                    else   //clause 6.2 - set S does not include absent, result is not(absent)
                    {
                        nslist = new NamespaceList("##other", string.Empty);
                    }
                }
            }
            else if (o2.type == ListType.Set && o1.type == ListType.Other)
            {
                if (v1Compat)
                {
                    if (o2.set.Contains(o2.targetNamespace))
                    {
                        nslist = new NamespaceList();
                    }
                    else
                    {
                        nslist = o1.Clone();
                    }
                }
                else                                        //New rules
                {
                    if (o1.targetNamespace != string.Empty) //clause 5, o1 is set S, o2 is not(tns)
                    {
                        nslist = o2.CompareSetToOther(o1);
                    }
                    else if (o2.set.Contains(string.Empty))   //clause 6.1 - set S includes absent, o2 is not(absent)
                    {
                        nslist = new NamespaceList();
                    }
                    else   //clause 6.2 - set S does not include absent, result is not(absent)
                    {
                        nslist = new NamespaceList("##other", string.Empty);
                    }
                }
            }
            return(nslist);
        }
 public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat) {
     NamespaceList nslist = null;
     Debug.Assert(o1 != o2);
     if (o1.type == ListType.Any) { //clause 2 - o1 is Any
         nslist = new NamespaceList();
     }
     else if (o2.type == ListType.Any) { //clause 2 - o2 is Any
         nslist = new NamespaceList();
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Set) { //clause 3 , both are sets
         nslist = o1.Clone();
         foreach (string ns in o2.set.Keys) {
             nslist.set[ns] = ns;
         }
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Other) { //clause 4, both are negations
         if (o1.targetNamespace == o2.targetNamespace) { //negation of same value
             nslist = o1.Clone();
         }
         else {
             nslist = new NamespaceList("##other", string.Empty); //clause 4, negations of different values, result is not(absent)
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Other) {
         if (v1Compat) {
             if (o1.set.Contains(o2.targetNamespace)) {
                 nslist = new NamespaceList();
             }
             else { //This was not there originally in V1, added for consistency since its not breaking
                 nslist = o2.Clone();
             }
         }
         else {
             if (o2.targetNamespace != string.Empty) { //clause 5, o1 is set S, o2 is not(tns)
                 nslist = o1.CompareSetToOther(o2); 
             }
             else if (o1.set.Contains(string.Empty)) { //clause 6.1 - set S includes absent, o2 is not(absent) 
                 nslist = new NamespaceList();
             }
             else { //clause 6.2 - set S does not include absent, result is not(absent)
                 nslist = new NamespaceList("##other", string.Empty);
             }
         }
     }
     else if (o2.type == ListType.Set && o1.type == ListType.Other) {
         if (v1Compat) {
             if (o2.set.Contains(o2.targetNamespace)) {
                 nslist = new NamespaceList();
             }
             else {
                 nslist = o1.Clone();
             }
         }
         else { //New rules
             if (o1.targetNamespace != string.Empty) { //clause 5, o1 is set S, o2 is not(tns)
                 nslist = o2.CompareSetToOther(o1); 
             }
             else if (o2.set.Contains(string.Empty)) { //clause 6.1 - set S includes absent, o2 is not(absent) 
                 nslist = new NamespaceList();
             }
             else { //clause 6.2 - set S does not include absent, result is not(absent)
                 nslist = new NamespaceList("##other", string.Empty);
             }
         }
     }
     return nslist;
 }
Example #43
0
        public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList nslist = null;

            Debug.Assert(o1 != o2);      //clause 1
            if (o1.type == ListType.Any) //clause 2 - o1 is any
            {
                nslist = o2.Clone();
            }
            else if (o2.type == ListType.Any)   //clause 2 - o2 is any
            {
                nslist = o1.Clone();
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)   //Clause 3 o2 is other
            {
                nslist = o1.Clone();
                nslist.RemoveNamespace(o2.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty); //remove ##local
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Set)   //Clause 3 o1 is other
            {
                nslist = o2.Clone();
                nslist.RemoveNamespace(o1.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty); //remove ##local
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)   //clause 4
            {
                nslist      = o1.Clone();
                nslist      = new NamespaceList();
                nslist.type = ListType.Set;
                nslist.set  = new Hashtable();
                foreach (string ns in o1.set.Keys)
                {
                    if (o2.set.Contains(ns))
                    {
                        nslist.set.Add(ns, ns);
                    }
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other)
            {
                if (o1.targetNamespace == o2.targetNamespace)   //negation of same namespace name
                {
                    nslist = o1.Clone();
                    return(nslist);
                }
                if (!v1Compat)
                {
                    if (o1.targetNamespace == string.Empty)   // clause 6 - o1 is negation of absent
                    {
                        nslist = o2.Clone();
                    }
                    else if (o2.targetNamespace == string.Empty)   //clause 6 - o1 is negation of absent
                    {
                        nslist = o1.Clone();
                    }
                }
                //if it comes here, its not expressible //clause 5
            }
            return(nslist);
        }
 private NamespaceList CompareSetToOther(NamespaceList other) {
     //clause 5.1
     NamespaceList nslist = null;
     if (this.set.Contains(other.targetNamespace)) { //S contains negated ns
         if (this.set.Contains(string.Empty)) { // AND S contains absent
             nslist = new NamespaceList(); //any is the result
         }
         else { //clause 5.2
             nslist = new NamespaceList("##other", string.Empty);
         }
     }
     else if (this.set.Contains(string.Empty)) { //clause 5.3 - Not expressible
         nslist = null;
     }
     else { //clause 5.4 - Set S does not contain negated ns or absent 
         nslist = other.Clone();
     }
     return nslist;    
 }
 public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2, bool v1Compat) {
     NamespaceList nslist = null;
     Debug.Assert(o1 != o2); //clause 1
     if (o1.type == ListType.Any) { //clause 2 - o1 is any
         nslist = o2.Clone();
     }
     else if (o2.type == ListType.Any) { //clause 2 - o2 is any
         nslist = o1.Clone();
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Other) { //Clause 3 o2 is other
         nslist = o1.Clone();
         nslist.RemoveNamespace(o2.targetNamespace);
         if (!v1Compat) {
             nslist.RemoveNamespace(string.Empty); //remove ##local
         }
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Set) { //Clause 3 o1 is other
         nslist = o2.Clone();
         nslist.RemoveNamespace(o1.targetNamespace);
         if (!v1Compat) {
             nslist.RemoveNamespace(string.Empty); //remove ##local
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Set) { //clause 4
         nslist =  o1.Clone();
         nslist = new NamespaceList();
         nslist.type = ListType.Set;
         nslist.set = new Hashtable();
         foreach(string ns in o1.set.Keys) {
             if (o2.set.Contains(ns)) {
                 nslist.set.Add(ns, ns);
             }
         }
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Other) {
         if (o1.targetNamespace == o2.targetNamespace) { //negation of same namespace name
             nslist = o1.Clone();
             return nslist;
         }
         if (!v1Compat) { 
             if (o1.targetNamespace == string.Empty) { // clause 6 - o1 is negation of absent
                 nslist = o2.Clone();
             }
             else if (o2.targetNamespace == string.Empty) { //clause 6 - o1 is negation of absent
                 nslist = o1.Clone();
             }
         }
         //if it comes here, its not expressible //clause 5
     }
     return nslist;
 }
Example #46
0
 public NamespaceListNode(NamespaceList namespaceList, object particle)
 {
     this.namespaceList = namespaceList;
     this.particle      = particle;
 }
Example #47
0
 internal static bool IsSubset(XmlSchemaAnyAttribute sub, XmlSchemaAnyAttribute super)
 {
     return(NamespaceList.IsSubset(sub.NamespaceList, super.NamespaceList));
 }
Example #48
0
        private ElementAccessor[] ImportAny(XmlSchemaAny any, bool makeElement, string targetNamespace)
        {
            SpecialMapping mapping = new SpecialMapping();

            mapping.TypeDesc = Scope.GetTypeDesc(makeElement ? typeof(XmlElement) : typeof(XmlNode));
            mapping.TypeName = mapping.TypeDesc.Name;


            TypeFlags flags = TypeFlags.CanBeElementValue;
            if (makeElement)
                flags |= TypeFlags.CanBeTextValue;

            // let the extensions to run
            RunSchemaExtensions(mapping, XmlQualifiedName.Empty, null, any, flags);

            if (GenerateOrder && any.Namespace != null)
            {
                NamespaceList list = new NamespaceList(any.Namespace, targetNamespace);

                if (list.Type == NamespaceList.ListType.Set)
                {
                    ICollection namespaces = list.Enumerate;
                    ElementAccessor[] accessors = new ElementAccessor[namespaces.Count == 0 ? 1 : namespaces.Count];
                    int count = 0;
                    foreach (string ns in list.Enumerate)
                    {
                        ElementAccessor accessor = new ElementAccessor();
                        accessor.Mapping = mapping;
                        accessor.Any = true;
                        accessor.Namespace = ns;
                        accessors[count++] = accessor;
                    }
                    if (count > 0)
                    {
                        return accessors;
                    }
                }
            }

            ElementAccessor anyAccessor = new ElementAccessor();
            anyAccessor.Mapping = mapping;
            anyAccessor.Any = true;
            return new ElementAccessor[] { anyAccessor };
        }
        internal static string ToString(NamespaceList list) {
            if (list == null)
                return null;
            switch (list.Type) {
            case NamespaceList.ListType.Any:
                return "##any";
            case NamespaceList.ListType.Other:
                return "##other";
            case NamespaceList.ListType.Set:
                ArrayList ns = new ArrayList();

                foreach (string s in list.Enumerate) {
                    ns.Add(s);
                }
                ns.Sort();
                StringBuilder sb = new StringBuilder();
                bool first = true;
                foreach (string s in ns) {
                    if (first) {
                        first = false;
                    }
                    else {
                        sb.Append(" ");
                    }
                    if (s.Length == 0) {
                        sb.Append("##local");
                    }
                    else {
                        sb.Append(s);
                    }
                }
                return sb.ToString();

            default:
                return list.ToString();
            }
        }
Example #50
0
        public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList list = null;

            if (o1.type == ListType.Any)
            {
                return(o2.Clone());
            }
            if (o2.type == ListType.Any)
            {
                return(o1.Clone());
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
            {
                list = o1.Clone();
                list.RemoveNamespace(o2.targetNamespace);
                if (!v1Compat)
                {
                    list.RemoveNamespace(string.Empty);
                }
                return(list);
            }
            if ((o1.type == ListType.Other) && (o2.type == ListType.Set))
            {
                list = o2.Clone();
                list.RemoveNamespace(o1.targetNamespace);
                if (!v1Compat)
                {
                    list.RemoveNamespace(string.Empty);
                }
                return(list);
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
            {
                list = o1.Clone();
                list = new NamespaceList {
                    type = ListType.Set,
                    set  = new Hashtable()
                };
                foreach (string str in o1.set.Keys)
                {
                    if (o2.set.Contains(str))
                    {
                        list.set.Add(str, str);
                    }
                }
                return(list);
            }
            if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    return(o1.Clone());
                }
                if (v1Compat)
                {
                    return(list);
                }
                if (o1.targetNamespace == string.Empty)
                {
                    return(o2.Clone());
                }
                if (o2.targetNamespace == string.Empty)
                {
                    list = o1.Clone();
                }
            }
            return(list);
        }