5 // Ben Maurer (bmaurer@users.sourceforge.net)
6 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
9 // (C) 2003 Atsushi Enomoto
13 using System.Collections;
15 using System.Xml.XPath;
18 namespace Mono.Xml.Xsl {
19 internal class Debug {
20 [System.Diagnostics.Conditional("DEBUG")]
21 internal static void TraceContext(XPathNavigator context) {
22 string output = "(null)";
24 if (context != null) {
25 context = context.Clone ();
26 switch (context.NodeType) {
27 case XPathNodeType.Element:
28 output = string.Format("<{0}:{1}", context.Prefix, context.LocalName);
29 for (bool attr = context.MoveToFirstAttribute(); attr; attr = context.MoveToNextAttribute()) {
30 output += string.Format(" {0}:{1}={2}", context.Prefix, context.LocalName, context.Value);
42 [System.Diagnostics.Conditional("DEBUG")]
43 internal static void Assert (bool condition, string message)
46 throw new Exception (message);
49 [System.Diagnostics.Conditional("DEBUG")]
50 internal static void WriteLine (object value)
52 Console.Error.WriteLine (value);
55 [System.Diagnostics.Conditional("DEBUG")]
56 internal static void WriteLine (string message)
58 Console.Error.WriteLine (message);
61 static Stack eleStack = new Stack ();
63 [System.Diagnostics.Conditional("DEBUG")]
64 internal static void EnterNavigator (Compiler c)
66 eleStack.Push (c.Input.Clone ());
69 [System.Diagnostics.Conditional("DEBUG")]
70 internal static void ExitNavigator (Compiler c)
72 XPathNavigator x = (XPathNavigator)eleStack.Pop();
73 if (!x.IsSamePosition (c.Input))
74 throw new Exception ("Position must be the same on enter/exit. Enter node: " + x.Name + " exit node " + c.Input.Name);