示例#1
0
		internal static string DebugRdpPattern (RdpPattern p, Hashtable visitedPattern)
		{
			if (p is RdpText)
				return "<text/>\n";
			if (p is RdpEmpty)
				return "<empty/>\n";
			if (p is RdpNotAllowed)
				return "<notAllowed/>\n";

			if (visitedPattern.Contains (p))
				return "<" + p.PatternType + " ref='" + p.GetHashCode () + "'/>";
			visitedPattern.Add (p, p);
			string intl = "(id=" + p.GetHashCode () + ") ";

			RdpAbstractSingleContent s = p as RdpAbstractSingleContent;
			if (s != null)
				intl = DebugRdpPattern (s.Child, visitedPattern);
			RdpAbstractBinary b = p as RdpAbstractBinary;
			if (b != null)
				intl = DebugRdpPattern (b.LValue, visitedPattern) +
					DebugRdpPattern (b.RValue, visitedPattern);

			RdpData data = p as RdpData;
			if (data != null)
				intl = String.Format ("name={0},ns={1},type={2} {3}",
					data.Datatype.LocalName,
					data.Datatype.NamespaceURI,
					data.Datatype.GetType (),
					data is RdpDataExcept ? DebugRdpPattern (((RdpDataExcept) data).Except, visitedPattern) : String.Empty);

			RdpValue value = p as RdpValue;
			if (value != null)
				intl = String.Format ("name={0},ns={1},value={2} type={3}",
					value.Datatype.LocalName,
					value.Datatype.NamespaceURI,
					value.Value,
					value.Datatype.GetType ());

			RdpElement el = p as RdpElement;
			if (el != null)
				intl = DebugNameClass (el.NameClass) +
					DebugRdpPattern (el.Children, visitedPattern);

			RdpAttribute at = p as RdpAttribute;
			if (at != null)
				intl = DebugNameClass (at.NameClass) +
					DebugRdpPattern (at.Children, visitedPattern);

			string str = String.Format ("<{0} id='id{1}'>\n{2}\n</{0}>",
				p.PatternType.ToString (),
				p.GetHashCode (),
				intl);

			return str;
		}
示例#2
0
		public RdpInterleave MakeInterleave (RdpPattern p1, RdpPattern p2)
		{
			if (p1.GetHashCode () > p2.GetHashCode ()) {
				RdpPattern tmp = p1;
				p1 = p2;
				p2 = tmp;
			}

			Hashtable p1Table = setupTable (typeof (RdpInterleave), p1);
			if (p1Table [p2] == null) {
				RdpInterleave i = new RdpInterleave (p1, p2);
				i.setInternTable (this.patternPool);
				p1Table [p2] = i;
			}
			return (RdpInterleave) p1Table [p2];
		}
示例#3
0
		public RdpPattern MakeChoice (RdpPattern p1, RdpPattern p2)
		{
			if (p1.PatternType == RelaxngPatternType.NotAllowed)
				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);
			if (p2.PatternType == RelaxngPatternType.Empty)
				return MakeChoiceLeaf (p1);

			if (p1.GetHashCode () > p2.GetHashCode ()) {
				RdpPattern tmp = p1;
				p1 = p2;
				p2 = tmp;
			}

			Hashtable p1Table = setupTable (typeof (RdpChoice), p1);
			if (p1Table [p2] == null) {
				RdpChoice c = new RdpChoice (p1, p2);
				c.setInternTable (this.patternPool);
				p1Table [p2] = c;
			}
			return (RdpChoice) p1Table [p2];
		}