Ejemplo n.º 1
0
        private NamespaceList CompareSetToOther(NamespaceList other)
        {
            //clause 5.1
            NamespaceList nslist = null;

            if (_set.Contains(other._targetNamespace))
            {                                     //S contains negated ns
                if (_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 (_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);
        }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
        public NamespaceList Clone()
        {
            NamespaceList nsl = (NamespaceList)MemberwiseClone();

            if (_type == ListType.Set)
            {
                Debug.Assert(_set != null);
                nsl._set = (Hashtable)(_set.Clone());
            }
            return(nsl);
        }
Ejemplo n.º 4
0
 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
     }
 }
Ejemplo n.º 5
0
 internal void BuildNamespaceList(string targetNamespace)
 {
     if (_ns != null)
     {
         _namespaceList = new NamespaceList(_ns, targetNamespace);
     }
     else
     {
         _namespaceList = new NamespaceList();
     }
 }
Ejemplo n.º 6
0
 internal void BuildNamespaceList(string targetNamespace)
 {
     if (_ns != null)
     { //If namespace="" default to namespace="##any"
         _namespaceList = new NamespaceList(_ns, targetNamespace);
     }
     else
     {
         _namespaceList = new NamespaceList();
     }
 }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 internal static bool IsSubset(XmlSchemaAnyAttribute sub, XmlSchemaAnyAttribute super)
 {
     return(NamespaceList.IsSubset(sub.NamespaceList, super.NamespaceList));
 }