Merge pull request #1155 from steffen-kiess/json-string
[mono.git] / mcs / class / Commons.Xml.Relaxng / Commons.Xml.Relaxng.Derivative / RdpPatterns.cs
index 88fe2eeadceb7c8719b3238e07c910847510751b..b65e59f33575c873b7d4274556f707350e622f19 100644 (file)
@@ -48,6 +48,16 @@ namespace Commons.Xml.Relaxng.Derivative
        // for now).
        public abstract class RdpPattern
        {
+               public static readonly RdpPattern Anything;
+
+               static RdpPattern ()
+               {
+                       RdpPattern anyAtts = new RdpList (new RdpAttribute (RdpAnyName.Instance, RdpText.Instance));
+                       RdpElement anyElement = new RdpElement (RdpAnyName.Instance, null);
+                       Anything = new RdpChoice (RdpEmpty.Instance, new RdpChoice (anyAtts, new RdpChoice (RdpText.Instance, new RdpList (anyElement))));
+                       anyElement.Children = Anything;
+               }
+
                internal bool nullableComputed;
                internal bool isNullable;
                Hashtable patternPool;
@@ -125,6 +135,8 @@ namespace Commons.Xml.Relaxng.Derivative
                                return p2;
                        if (p2.PatternType == RelaxngPatternType.NotAllowed)
                                return p1;
+                       if (p1 == p2)
+                               return p1;
                        // choice-leaves support
                        if (p1.PatternType == RelaxngPatternType.Empty)
                                return MakeChoiceLeaf (p2);
@@ -1481,7 +1493,7 @@ namespace Commons.Xml.Relaxng.Derivative
                                p : p.Group (this.Choice (RdpEmpty.Instance));
                }
 
-               internal virtual RdpPattern EmptyTextDeriv (MemoizationStore memo)
+               internal override RdpPattern EmptyTextDeriv (MemoizationStore memo)
                {
                        RdpPattern p = memo.EmptyTextDeriv (Child);
                        return p.PatternType == RelaxngPatternType.NotAllowed ?
@@ -1639,11 +1651,6 @@ namespace Commons.Xml.Relaxng.Derivative
                                return RdpNotAllowed.Instance;
                }
 
-               internal virtual RdpPattern EmptyTextDeriv (MemoizationStore memo)
-               {
-                       return RdpEmpty.Instance;
-               }
-
                internal override void CheckConstraints (bool attribute, bool oneOrMore, bool oneOrMoreGroup, bool oneOrMoreInterleave, bool list, bool dataExcept)
                {
                        if (list)
@@ -2128,12 +2135,12 @@ namespace Commons.Xml.Relaxng.Derivative
                        constraintsChecked = true;
                        if (attribute || list || dataExcept)
                                throw new RelaxngException ("Not allowed element occurence was specified in the pattern.");
-                       this.Children.CheckConstraints (false, oneOrMore, oneOrMoreGroup, oneOrMoreInterleave, false, false);
+                       this.Children.CheckConstraints (false, false, false, oneOrMoreInterleave, false, false);
                }
 
                internal override bool ContainsText()
                {
-                       return children.ContainsText ();
+                       return false;
                }
        }