コード例 #1
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public void AddWildcardTerminal(SchemaNamespaceList wildcard, XmlSchemaContentProcessing processContents, TypeNode elementType, Member mem) {
   AddTerminal(new WildcardNode(wildcard, processContents, elementType, mem));
   canCompile = false;
 }
コード例 #2
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public static SchemaNamespaceList Union(SchemaNamespaceList o1, SchemaNamespaceList o2) {
   SchemaNamespaceList nslist = null;
   if (o1.type == ListType.Any) {
     nslist = new SchemaNamespaceList();
   }
   else if (o2.type == ListType.Any) {
     nslist = new SchemaNamespaceList();
   }
   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 SchemaNamespaceList();
     }
   }
   else if (o2.type == ListType.Set && o1.type == ListType.Other) {
     if (o2.set.Contains(o2.targetNamespace)) {
       nslist = new SchemaNamespaceList();
     }
     else {
       nslist = o1.Clone();
     }
   }
   if (o1.types != null) {
     foreach (TypeNode t in o1.types) {
       nslist.AddType(t);
     }
   }
   if (o2.types != null) {
     foreach (TypeNode t in o2.types) {
       nslist.AddType(t);
     }
   }
   return nslist;
 }
コード例 #3
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public static SchemaNamespaceList Intersection(SchemaNamespaceList o1, SchemaNamespaceList o2) { 
   // This method is only used to figure out if we need to call Union, so
   // we can safely ignore the types ArrayList.
   SchemaNamespaceList nslist = null;
   if (o1.type == ListType.Any) {
     if (o2.type == ListType.Any)
       return null; // result in wildcard
     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 SchemaNamespaceList();
     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;
 }
コード例 #4
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public override bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard) {
   BitSet lset = null, rset = null; bitset = null; wildcard = null; 
   SchemaNamespaceList lany = null, rany = null;
   if (!LeftChild.CheckDeterministic(context, namedTerminals, out lset, out lany))
     return false;
   if (!RightChild.CheckDeterministic(context, namedTerminals, out rset, out rany))
     return false;
   return Join(context, namedTerminals, lset, lany, rset, rany, out bitset, out wildcard);
 }
コード例 #5
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public static bool IsSubset(SchemaNamespaceList sub, SchemaNamespaceList super) {
   if (super.type == ListType.Any) {
     // bugbug, what about the types ArrayList?
     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;
 }
コード例 #6
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
    protected bool Join(ValidationState context, NamedNode[] namedTerminals, BitSet lset, SchemaNamespaceList lany, BitSet rset, SchemaNamespaceList rany, out BitSet bitset, out SchemaNamespaceList wildcard) {
      wildcard = null;
      if (lset != null) {
        if (rset != null) {
          bitset = lset.Clone();
          bitset.And(rset);
          if (!bitset.IsEmpty) {
            Identifier id = (context.Name == null) ? Identifier.Empty : context.Name;
            context.HandleError(this, id, Error.NonDeterministicAny, id.ToString());
            return false;
          }
          bitset.Or(lset);
          bitset.Or(rset);
        }
        else {
          bitset = lset;
        }
      }
      else {
        bitset = rset;                
      }

      if (lany != null) {
        if (rany != null) {
          SchemaNamespaceList list = SchemaNamespaceList.Intersection(rany, lany);
          if (list == null ||  list.IsEmpty()) { 
            wildcard = SchemaNamespaceList.Union(rany, lany);
          }                
          else {
            Identifier id = (context.Name == null) ? Identifier.Empty : context.Name;
            context.HandleError(this, id, Error.NonDeterministicAny, id.ToString());
            return false;
          }
        }
        else {
          wildcard = lany;
        }                        
      }
      else {
        wildcard = rany;     
      } 

      if (wildcard != null && bitset != null) {
        for (int i = 0; i < bitset.Count; i++) {
          NamedNode node = namedTerminals[i];
          if (bitset.Get(i) && wildcard.Allows(node)) {
            Identifier id = (context.Name == null ? node.Name : context.Name);
            context.HandleError(this, id, Error.NonDeterministicAny, id.ToString());
            return false;
          }
        }
      }
      return true;
    }
コード例 #7
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
    public override bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard) {
      bitset = null; BitSet lset = null, rset = null; wildcard = null;
      SchemaNamespaceList lany = null, rany = null;
      if (!LeftChild.CheckDeterministic(context, namedTerminals, out lset, out lany))
        return false;
      if (!RightChild.CheckDeterministic(context, namedTerminals, out rset, out rany))
        return false;

      if (LeftChild.HasRange || LeftChild.IsNullable) {
        return Join(context, namedTerminals, lset, lany, rset, rany, out bitset, out wildcard);                            
      }
      else {
        bitset = lset;
        wildcard = lany;
      }
      return true;
    }
コード例 #8
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public override bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard) {
   return LeftChild.CheckDeterministic(context, namedTerminals, out bitset, out wildcard);                            
 }
コード例 #9
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public override bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard) {
   bitset = null;
   wildcard = this.wildcard;
   wildcard.AddType(this.TypeNode);
   return true;
 }
コード例 #10
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public WildcardNode(SchemaNamespaceList wildcard, XmlSchemaContentProcessing processContents, TypeNode elementType, Member mem ): base(mem, elementType)  {
   this.wildcard = wildcard;
   this.processContents = processContents;
 }
コード例 #11
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public override bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard) {
   bitset = Firstpos;
   wildcard = null;
   return true;
 }
コード例 #12
0
ファイル: Validation.cs プロジェクト: hesam/SketchSharp
 public abstract bool CheckDeterministic(ValidationState context, NamedNode[] namedTerminals, out BitSet bitset, out SchemaNamespaceList wildcard);