Author: atsushi
Date: 2007-06-29 04:45:11 -0400 (Fri, 29 Jun 2007)
New Revision: 81031

Added:
   trunk/olive/class/Mono.XsltDebugger/
   trunk/olive/class/Mono.XsltDebugger/Assembly/
   trunk/olive/class/Mono.XsltDebugger/Assembly/AssemblyInfo.cs
   trunk/olive/class/Mono.XsltDebugger/Assembly/ChangeLog
   trunk/olive/class/Mono.XsltDebugger/ChangeLog
   trunk/olive/class/Mono.XsltDebugger/Makefile
   trunk/olive/class/Mono.XsltDebugger/Mono.Xml/
   trunk/olive/class/Mono.XsltDebugger/Mono.Xml/ChangeLog
   trunk/olive/class/Mono.XsltDebugger/Mono.Xml/XmlNodeWriter.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger.dll.sources
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/ChangeLog
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventArgs.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventHandler.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventArgs.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventHandler.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebugger.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerBreakpoint.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerContext.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerException.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerSession.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventArgs.cs
   
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventHandler.cs
   trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltInjector.cs
Log:
initial checkin.



Added: trunk/olive/class/Mono.XsltDebugger/Assembly/AssemblyInfo.cs
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Assembly/AssemblyInfo.cs        
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Assembly/AssemblyInfo.cs        
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,48 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//   Andreas Nahr ([EMAIL PROTECTED])
+//
+// (C) 2003 Ximian, Inc.  http://www.ximian.com
+// (C) 2004 Novell (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+
+//[assembly: AssemblyTitle ("")]
+[assembly: AssemblyDescription ("Mono.XsltDebugger.dll")]
+
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyFileVersion ("0.0.0.1")]
+
+[assembly: ComVisible (false)]
+
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../mono.pub")]
+

Added: trunk/olive/class/Mono.XsltDebugger/Assembly/ChangeLog
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Assembly/ChangeLog      2007-06-29 
07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Assembly/ChangeLog      2007-06-29 
08:45:11 UTC (rev 81031)
@@ -0,0 +1,3 @@
+2007-06-29  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * AssemblyInfo.cs : initial checkin.

Added: trunk/olive/class/Mono.XsltDebugger/ChangeLog
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/ChangeLog       2007-06-29 07:18:13 UTC 
(rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/ChangeLog       2007-06-29 08:45:11 UTC 
(rev 81031)
@@ -0,0 +1,4 @@
+2007-06-29  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * Makefile
+         Mono.XsltDebugger.dll.sources : initial checkin.

Added: trunk/olive/class/Mono.XsltDebugger/Makefile
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Makefile        2007-06-29 07:18:13 UTC 
(rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Makefile        2007-06-29 08:45:11 UTC 
(rev 81031)
@@ -0,0 +1,22 @@
+thisdir = class/Mono.XsltDebugger
+SUBDIRS = 
+include ../../build/rules.make
+
+RESOURCE_FILES = 
+
+OTHER_RES = $(RESOURCE_FILES)
+
+LIBRARY = Mono.XsltDebugger.dll
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll \
+       $(foreach r, $(OTHER_RES), /resource:$(r),$(notdir $(r)))
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
+EXTRA_DISTFILES = \
+       $(RESOURCE_FILES)
+
+include ../../build/library.make
+
+$(the_lib): $(OTHER_RES)
+
+dll-sources:
+       ls ../../build/common/*.cs > $(LIBRARY).sources
+       ls */*.cs >> $(LIBRARY).sources

Added: trunk/olive/class/Mono.XsltDebugger/Mono.Xml/ChangeLog
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.Xml/ChangeLog      2007-06-29 
07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.Xml/ChangeLog      2007-06-29 
08:45:11 UTC (rev 81031)
@@ -0,0 +1,3 @@
+2007-06-29  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XmlNodeWriter.cs : initial checkin. Mostly copy from System.Xml.

Added: trunk/olive/class/Mono.XsltDebugger/Mono.Xml/XmlNodeWriter.cs
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.Xml/XmlNodeWriter.cs       
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.Xml/XmlNodeWriter.cs       
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,392 @@
+//
+// Mono.Xml.XmlNodeWriter
+//
+// Author:
+//     Atsushi Enomoto ([EMAIL PROTECTED])
+//
+//     (C)2003 Atsushi Enomoto
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml;
+
+namespace System.Xml
+{
+       internal class XmlNodeWriter : XmlWriter
+       {
+               public XmlNodeWriter () : this (true)
+               {
+               }
+
+               // It should be public after some tests are done :-)
+               public XmlNodeWriter (bool isDocumentEntity)
+               {
+                       doc = new XmlDocument ();
+                       state = XmlNodeType.None;
+                       this.isDocumentEntity = isDocumentEntity;
+                       if (!isDocumentEntity)
+                               current = fragment = doc.CreateDocumentFragment 
();
+               }
+
+               XmlDocument doc;
+               bool isClosed;
+               // If it is not null, then we are now inside the element.
+               XmlNode current;
+               // If it is not null, then we are now inside the attribute.
+               XmlAttribute attribute;
+               // If it is false, then allow to contain multiple document 
elements.
+               bool isDocumentEntity;
+               XmlDocumentFragment fragment;
+
+               // None: started or closed.
+               // XmlDeclaration: after xmldecl. Never allow xmldecl.
+               // DocumentType: after doctype. Never allow xmldecl and doctype.
+               // Element: inside document element.
+               // 
+               XmlNodeType state;
+
+               // Properties
+               public XmlNode Document {
+                       get { return isDocumentEntity ? (XmlNode)doc : 
(XmlNode)fragment; }
+               }
+
+               public XmlNode Current {
+                       get { return current; }
+               }
+
+               public override WriteState WriteState {
+                       get {
+                               if (isClosed)
+                                       return WriteState.Closed;
+                               if (attribute != null)
+                                       return WriteState.Attribute;
+
+                               switch (state) {
+                               case XmlNodeType.None:
+                                       return WriteState.Start;
+                               case XmlNodeType.XmlDeclaration:
+                                       return WriteState.Prolog;
+                               case XmlNodeType.DocumentType:
+                                       return WriteState.Element;
+                               default:
+                                       return WriteState.Content;
+                               }
+                       }
+               }
+
+               public override string XmlLang {
+                       get {
+                               for (XmlElement n = current as XmlElement; n != 
null; n = n.ParentNode as XmlElement)
+                                       if (n.HasAttribute ("xml:lang"))
+                                               return n.GetAttribute 
("xml:lang");
+                               return String.Empty;
+                       }
+               }
+
+               public override XmlSpace XmlSpace {
+                       get {
+                               for (XmlElement n = current as XmlElement; n != 
null; n = n.ParentNode as XmlElement) {
+                                       string xs = n.GetAttribute 
("xml:space");
+                                       switch (xs) {
+                                       case "preserve":
+                                               return XmlSpace.Preserve;
+                                       case "default":
+                                               return XmlSpace.Default;
+                                       case "":
+                                               continue;
+                                       default:
+                                               throw new 
InvalidOperationException (String.Format ("Invalid xml:space {0}.", xs));
+                                       }
+                               }
+                               return XmlSpace.None;
+                       }
+               }
+
+               // Private Methods
+
+               private void CheckState ()
+               {
+                       if (isClosed)
+                               throw new InvalidOperationException ();
+
+               }
+
+               private void WritePossiblyTopLevelNode (XmlNode n, bool 
possiblyAttribute)
+               {
+                       CheckState ();
+                       if (!possiblyAttribute && attribute != null)
+                               throw new InvalidOperationException 
(String.Format ("Current state is not acceptable for {0}.", n.NodeType));
+
+                       if (state != XmlNodeType.Element)
+                               Document.AppendChild (n);
+                       else if (attribute != null)
+                               attribute.AppendChild (n);
+                       else
+                               current.AppendChild (n);
+                       if (state == XmlNodeType.None)
+                               state = XmlNodeType.XmlDeclaration;
+               }
+
+               // Public Methods
+
+               public override void Close ()
+               {
+                       CheckState ();
+                       isClosed = true;
+               }
+
+               public override void Flush ()
+               {
+               }
+
+               public override string LookupPrefix (string ns)
+               {
+                       CheckState ();
+                       if (current == null)
+                               throw new InvalidOperationException ();
+                       return current.GetPrefixOfNamespace (ns);
+               }
+
+               // StartDocument
+
+               public override void WriteStartDocument ()
+               {
+                       WriteStartDocument (null);
+               }
+
+               public override void WriteStartDocument (bool standalone)
+               {
+                       WriteStartDocument (standalone ? "yes" : "no");
+               }
+
+               private void WriteStartDocument (string sddecl)
+               {
+                       CheckState ();
+                       if (state != XmlNodeType.None)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for xmldecl.");
+
+                       doc.AppendChild (doc.CreateXmlDeclaration ("1.0", null, 
sddecl));
+                       state = XmlNodeType.XmlDeclaration;
+               }
+               
+               // EndDocument
+               
+               public override void WriteEndDocument ()
+               {
+                       CheckState ();
+
+                       isClosed = true;
+               }
+
+               // DocumentType
+               public override void WriteDocType (string name, string 
publicId, string systemId, string internalSubset)
+               {
+                       CheckState ();
+                       switch (state) {
+                       case XmlNodeType.None:
+                       case XmlNodeType.XmlDeclaration:
+                               doc.AppendChild (doc.CreateDocumentType (name, 
publicId, systemId, internalSubset));
+                               state = XmlNodeType.DocumentType;
+                               break;
+                       default:
+                               throw new InvalidOperationException ("Current 
state is not acceptable for doctype.");
+                       }
+               }
+
+               // StartElement
+
+               public override void WriteStartElement (string prefix, string 
name, string ns)
+               {
+                       CheckState ();
+                       if (isDocumentEntity && state == XmlNodeType.EndElement 
&& doc.DocumentElement != null)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for startElement.");
+
+                       XmlElement el = doc.CreateElement (prefix, name, ns);
+                       if (current == null) {
+                               Document.AppendChild (el);
+                               state = XmlNodeType.Element;
+                       } else {
+                               current.AppendChild (el);
+                               state = XmlNodeType.Element;
+                       }
+
+                       current = el;
+               }
+
+               // EndElement
+
+               public override void WriteEndElement ()
+               {
+                       WriteEndElementInternal (false);
+               }
+               
+               public override void WriteFullEndElement ()
+               {
+                       WriteEndElementInternal (true);
+               }
+
+               private void WriteEndElementInternal (bool forceFull)
+               {
+                       CheckState ();
+                       if (current == null)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for endElement.");
+
+                       if (!forceFull && current.FirstChild == null)
+                               ((XmlElement) current).IsEmpty = true;
+
+                       if (isDocumentEntity && current.ParentNode == doc)
+                               state = XmlNodeType.EndElement;
+                       else
+                               current = current.ParentNode;
+               }
+
+               // StartAttribute
+
+               public override void WriteStartAttribute (string prefix, string 
name, string ns)
+               {
+                       CheckState ();
+                       if (attribute != null)
+                               throw new InvalidOperationException ("There is 
an open attribute.");
+                       if (!(current is XmlElement))
+                               throw new InvalidOperationException ("Current 
state is not acceptable for startAttribute.");
+
+                       attribute = doc.CreateAttribute (prefix, name, ns);
+                       ((XmlElement)current).SetAttributeNode (attribute);
+               }
+
+               public override void WriteEndAttribute ()
+               {
+                       CheckState ();
+                       if (attribute == null)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for startAttribute.");
+
+                       attribute = null;
+               }
+
+               public override void WriteCData (string data)
+               {
+                       CheckState ();
+                       if (current == null)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for CDATAsection.");
+
+                       current.AppendChild (doc.CreateCDataSection (data));
+               }
+
+               public override void WriteComment (string comment)
+               {
+                       WritePossiblyTopLevelNode (doc.CreateComment (comment), 
false);
+               }
+
+               public override void WriteProcessingInstruction (string name, 
string value)
+               {
+                       WritePossiblyTopLevelNode (
+                               doc.CreateProcessingInstruction (name, value), 
false);
+               }
+
+               public override void WriteEntityRef (string name)
+               {
+                       WritePossiblyTopLevelNode (doc.CreateEntityReference 
(name), true);
+               }
+
+               public override void WriteCharEntity (char c)
+               {
+                       WritePossiblyTopLevelNode (doc.CreateTextNode (new 
string (new char [] {c}, 0, 1)), true);
+               }
+
+               public override void WriteWhitespace (string ws)
+               {
+                       WritePossiblyTopLevelNode (doc.CreateWhitespace (ws), 
true);
+               }
+
+               public override void WriteString (string data)
+               {
+                       CheckState ();
+                       if (current == null)
+                               throw new InvalidOperationException ("Current 
state is not acceptable for Text.");
+
+                       if (attribute != null)
+                               attribute.AppendChild (doc.CreateTextNode 
(data));
+                       else {
+                               XmlText last = current.LastChild as XmlText;
+                               if (last == null)
+                                       
current.AppendChild(doc.CreateTextNode(data));
+                               else 
+                                       last.AppendData(data);
+                       }
+               }
+
+               public override void WriteName (string name)
+               {
+                       WriteString (name);
+               }
+
+               public override void WriteNmToken (string nmtoken)
+               {
+                       WriteString (nmtoken);
+               }
+
+               public override void WriteQualifiedName (string name, string ns)
+               {
+                       string prefix = LookupPrefix (ns);
+                       if (prefix == null)
+                               throw new ArgumentException (String.Format 
("Invalid namespace {0}", ns));
+                       if (prefix != String.Empty)
+                               WriteString (name);
+                       else
+                               WriteString (prefix + ":" + name);
+               }
+
+               public override void WriteChars (char [] chars, int start, int 
len)
+               {
+                       WriteString (new string (chars, start, len));
+               }
+
+               public override void WriteRaw (string data)
+               {
+                       // It never supports raw string.
+                       WriteString (data);
+               }
+
+               public override void WriteRaw (char [] chars, int start, int 
len)
+               {
+                       // It never supports raw string.
+                       WriteChars (chars, start, len);
+               }
+
+               public override void WriteBase64 (byte [] data, int start, int 
len)
+               {
+                       // It never supports raw string.
+                       WriteString (Convert.ToBase64String (data, start, len));
+               }
+               
+               public override void WriteBinHex (byte [] data, int start, int 
len)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void WriteSurrogateCharEntity (char c1, char c2)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}

Added: trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/ChangeLog
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/ChangeLog     
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/ChangeLog     
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,8 @@
+2007-06-29  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XsltExecuteEventArgs.cs XsltExecuteEventHandler.cs
+         XsltDebuggerBreakpoint.cs XsltDebuggerException.cs
+         XsltDebugger.cs XsltCompileEventArgs.cs XsltCompleteEventArgs.cs
+         XsltCompileEventHandler.cs XsltCompleteEventHandler.cs
+         XsltDebuggerSession.cs XsltDebuggerContext.cs XsltInjector.cs :
+         initial checkin. (It does not support any debugging yet.)

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventArgs.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventArgs.cs   
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventArgs.cs   
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,22 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltCompileEventArgs : EventArgs
+       {
+               XPathNavigator nav;
+
+               public XsltCompileEventArgs (XPathNavigator nav)
+               {
+                       this.nav = nav;
+               }
+
+               public XPathNavigator StyleElement {
+                       get { return nav; }
+               }
+       }
+}
+

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventHandler.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventHandler.cs
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompileEventHandler.cs
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,9 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public delegate void XsltCompileEventHandler (object o, 
XsltCompileEventArgs args);
+}

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventArgs.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventArgs.cs  
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventArgs.cs  
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,15 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltCompleteEventArgs : EventArgs
+       {
+               public XsltCompleteEventArgs ()
+               {
+               }
+       }
+}
+

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventHandler.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventHandler.cs
   2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltCompleteEventHandler.cs
   2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,9 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public delegate void XsltCompleteEventHandler (object o, 
XsltCompleteEventArgs args);
+}

Added: trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebugger.cs
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebugger.cs       
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebugger.cs       
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,162 @@
+using System;
+using System.Collections;
+using System.IO;
+using System.Security.Policy;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltDebugger
+       {
+               XPathDocument style;
+               XPathDocument input;
+               XmlResolver xml_resolver;
+               Evidence evidence;
+               ArrayList breakpoints = new ArrayList ();
+               XsltDebuggerSession current_run;
+               XmlNamespaceManager nsmgr = new XmlNamespaceManager (new 
NameTable ());
+
+               public XsltDebugger ()
+               {
+               }
+
+               public XmlNamespaceManager NamespaceManager {
+                       get { return nsmgr; }
+               }
+
+               public XsltDebuggerSession CurrentRun {
+                       get { return current_run; }
+               }
+
+               public XPathDocument Stylesheet {
+                       get { return style; }
+                       set {
+                               if (current_run != null)
+                                       throw new InvalidOperationException 
("Cannot set stylesheet because debug is in progress");
+                               style = value;
+                       }
+               }
+
+               public XPathDocument Input {
+                       get { return input; }
+                       set {
+                               if (current_run != null)
+                                       throw new InvalidOperationException 
("Cannot set input document because debug is in progress");
+                               input = value;
+                       }
+               }
+
+               public XmlResolver XmlResolver {
+                       set { xml_resolver = value; }
+               }
+
+               public Evidence Evidence {
+                       get { return evidence; }
+                       set { evidence = value; }
+               }
+
+               public IList Breakpoints {
+                       get { return breakpoints; }
+               }
+
+               public void AddBreakpoint (XsltDebuggerBreakpoint point)
+               {
+                       if (point == null)
+                               throw new ArgumentNullException ("point");
+                       foreach (XsltDebuggerBreakpoint bp in breakpoints)
+                               if (bp.Equals (point))
+                                       return;
+                       breakpoints.Add (point);
+               }
+
+               public void RemoveBreakpoint (XsltDebuggerBreakpoint point)
+               {
+                       if (point == null)
+                               throw new ArgumentNullException ("point");
+                       for (int i = 0; i < breakpoints.Count; i++)
+                               if (point.Equals (breakpoints [i])) {
+                                       breakpoints.RemoveAt (i);
+                                       return;
+                               }
+               }
+
+               public void Run ()
+               {
+                       if (current_run != null) {
+                               if (WarnAndQueryExistingRun ())
+                                       return;
+                               Abort ();
+                       }
+                       current_run = new XsltDebuggerSession (this);
+
+                       // set breakpoints
+                       current_run.Executed += OnExecute;
+
+                       current_run.Run ();
+               }
+
+               public virtual void Interrupt ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual void Resume ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual void Abort ()
+               {
+                       if (current_run != null)
+                               current_run.Dispose ();
+                       current_run = null;
+               }
+
+               protected virtual bool WarnAndQueryExistingRun ()
+               {
+                       // warn something and return true if it should stop new 
run.
+                       return false;
+               }
+
+               // customizible
+               protected internal virtual void LoadStylesheet (XslTransform 
transform)
+               {
+                       if (transform == null)
+                               throw new ArgumentNullException ("transform");
+                       if (style == null)
+                               throw new XsltDebuggerException ("Stylesheet 
document is not specified");
+                       transform.Load (style, xml_resolver, evidence);
+               }
+
+               // customizible
+               protected internal virtual void Transform (XslTransform 
transform, XmlWriter writer)
+               {
+                       if (transform == null)
+                               throw new ArgumentNullException ("transform");
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
+                       if (input == null)
+                               throw new XsltDebuggerException ("Input 
document is not specified");
+                       transform.Transform (input, null, writer, xml_resolver);
+               }
+
+               void OnExecute (object o, XsltExecuteEventArgs args)
+               {
+                       if (!Break (args.Context))
+                               return;
+Console.WriteLine ("Match");
+               }
+
+               bool Break (XsltDebuggerContext ctx)
+               {
+                       // FIXME: support StepIn,StepNext,StepOut etc.
+
+                       foreach (XsltDebuggerBreakpoint bp in breakpoints)
+                               if (bp.Match (ctx))
+                                       return true;
+                       return false;
+               }
+       }
+}

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerBreakpoint.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerBreakpoint.cs 
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerBreakpoint.cs 
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,142 @@
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public abstract class XsltDebuggerBreakpoint
+       {
+               public virtual void Initialize (XsltDebuggerSession run)
+               {
+               }
+
+               public abstract bool Match (XsltDebuggerContext ctx);
+
+               public virtual string ToSummaryString ()
+               {
+                       return ToString ();
+               }
+       }
+
+       public class XsltStylesheetBreakpoint : XsltDebuggerBreakpoint
+       {
+               XPathNavigator style;
+               string base_uri;
+               int line, column;
+
+               public XsltStylesheetBreakpoint (string baseUri, int line, int 
column)
+               {
+                       this.base_uri = baseUri;
+                       this.line = line;
+                       this.column = column;
+               }
+
+               public int LineNumber {
+                       get { return line; }
+               }
+
+               public int LinePosition {
+                       get { return column; }
+               }
+
+               public string BaseUri {
+                       get { return base_uri; }
+               }
+
+               public override string ToSummaryString ()
+               {
+                       return String.Format ("[style] {0} ({1},{2})", 
base_uri, line, column);
+               }
+
+               public override bool Equals (object o)
+               {
+                       XsltStylesheetBreakpoint other = o as 
XsltStylesheetBreakpoint;
+                       return  other != null &&
+                               other.line == line &&
+                               other.column == column &&
+                               other.base_uri == base_uri;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return (line << 24) + (column << 16) + 
base_uri.GetHashCode ();
+               }
+
+               public override bool Match (XsltDebuggerContext ctx)
+               {
+                       XPathNavigator s = ctx.StylesheetElement;
+                       IXmlLineInfo li = s as IXmlLineInfo;
+                       if (style != null)
+                               return s.IsSamePosition (style);
+                       if (li == null)
+                               return false;
+                       else if (base_uri != null && base_uri != s.BaseURI ||
+                                line != li.LineNumber ||
+                                column != 0 && column != li.LinePosition)
+                               return false;
+                       style = s;
+                       return true;
+               }
+       }
+
+       public abstract class XsltOutputBreakpoint : XsltDebuggerBreakpoint
+       {
+       }
+
+       public class XsltOutputXPathBreakpoint : XsltOutputBreakpoint
+       {
+               const string CustomCacheId = "XsltOutputXPathBreakpoint";
+
+               // target XPath (and cache)
+               XPathExpression exp;
+               string xpath;
+
+               public XsltOutputXPathBreakpoint (string xpath)
+               {
+                       this.xpath = xpath;
+               }
+
+               public override bool Equals (object o)
+               {
+                       XsltOutputXPathBreakpoint other = o as 
XsltOutputXPathBreakpoint;
+                       return other != null && other.xpath == xpath;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return xpath.GetHashCode ();
+               }
+
+               public override bool Match (XsltDebuggerContext ctx)
+               {
+                       XPathNavigator last_node = ctx.Session.CustomCache 
[CustomCacheId] as XPathNavigator;
+
+                       XmlNodeWriter w = ctx.Session.Output as XmlNodeWriter;
+                       XmlNode n = w != null ? w.Document : null;
+                       if (n == null)
+                               return false; // it is not ready for debugging.
+
+                       if (exp == null)
+                               exp = n.CreateNavigator ().Compile (xpath);
+
+                       exp.SetContext (ctx.Session.Debugger.NamespaceManager);
+                       XPathNodeIterator i = w.Current.CreateNavigator 
().Select (exp);
+                       bool next = last_node == null;
+                       while (i.MoveNext ()) {
+                               if (next) {
+                                       ctx.Session.CustomCache [CustomCacheId] 
= i.Current;
+                                       return true;
+                               } else if (i.Current.IsSamePosition (last_node))
+                                       next = true;
+                       }
+                       return false;
+               }
+
+               public override string ToSummaryString ()
+               {
+                       return String.Format ("[outout/xpath] {0}", xpath);
+               }
+       }
+}

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerContext.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerContext.cs    
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerContext.cs    
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,42 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltDebuggerContext
+       {
+               XsltDebuggerSession session;
+               XPathNodeIterator nodes;
+               XPathNavigator style;
+               XsltContext xsltctx;
+
+               public XsltDebuggerContext (XsltDebuggerSession session, 
XPathNodeIterator currentNodeset, XPathNavigator stylesheetElement, XsltContext 
xsltContext)
+               {
+                       this.session = session;
+                       this.nodes = currentNodeset;
+                       this.style = stylesheetElement;
+                       this.xsltctx = xsltContext;
+               }
+
+               public XsltDebuggerSession Session {
+                       get { return session; }
+               }
+
+               // I wonder if we should expose current nodeset
+
+               // It is not desirable to have it public, but it is needed
+               // to set XmlNamespaceManager to XPathExpression in the
+               // debugger. So, users who write custom breakpoint rules
+               // may also need it.
+               public XsltContext XsltContext {
+                       get { return xsltctx; }
+               }
+
+               public XPathNavigator StylesheetElement {
+                       get { return style; }
+               }
+       }
+}
+

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerException.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerException.cs  
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerException.cs  
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,22 @@
+using System;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltDebuggerException : ApplicationException
+       {
+               public XsltDebuggerException ()
+                       : this ("XSLT debugger exception is raised")
+               {
+               }
+
+               public XsltDebuggerException (string message)
+                       : this (message, null)
+               {
+               }
+
+               public XsltDebuggerException (string message, Exception 
innerException)
+                       : base (message, innerException)
+               {
+               }
+       }
+}

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerSession.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerSession.cs    
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltDebuggerSession.cs    
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,90 @@
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltDebuggerSession : IDisposable
+       {
+               XsltDebugger debugger;
+               XsltInjector injector;
+               XslTransform transform;
+               XmlNodeWriter output;
+               Hashtable custom_cache;
+
+               public XsltDebuggerSession (XsltDebugger debugger)
+               {
+                       this.debugger = debugger;
+                       Init ();
+               }
+
+               public XsltDebugger Debugger {
+                       get { return debugger; }
+               }
+
+               public XmlNode OutputNode {
+                       get { return output.Current; }
+               }
+
+               public XmlWriter Output {
+                       get { return output; }
+               }
+
+               public Hashtable CustomCache {
+                       get { return custom_cache; }
+               }
+
+               public void Dispose ()
+               {
+                       debugger = null;
+                       transform = null;
+                       output = null;
+               }
+
+               internal void Run ()
+               {
+                       custom_cache = new Hashtable ();
+                       transform = (XslTransform) Activator.CreateInstance 
(typeof (XslTransform), BindingFlags.NonPublic | BindingFlags.Instance | 
BindingFlags.CreateInstance, null, new object [] {injector}, 
CultureInfo.CurrentCulture);
+                       debugger.LoadStylesheet (transform);
+                       output = new XmlNodeWriter (false);
+                       debugger.Transform (transform, output);
+
+                       if (Completed != null)
+                               Completed (this, new XsltCompleteEventArgs ());
+               }
+
+               public XsltDebuggerContext CreateContext (XPathNodeIterator 
currentNodeset, XPathNavigator stylesheetElement, XsltContext xsltContext)
+               {
+                       return new XsltDebuggerContext (this, currentNodeset, 
stylesheetElement, xsltContext);
+               }
+
+               void Init ()
+               {
+                       injector = new XsltInjector (this);
+                       injector.Compiled += OnCompiled;
+                       injector.Executed += OnExecute;
+               }
+
+               void OnCompiled (object o, XsltCompileEventArgs e)
+               {
+                       if (Compiled != null)
+                               Compiled (o, e);
+               }
+
+               void OnExecute (object o, XsltExecuteEventArgs e)
+               {
+                       if (Executed != null)
+                               Executed (o, e);
+               }
+
+               public event XsltCompileEventHandler Compiled;
+               public event XsltExecuteEventHandler Executed;
+               public event XsltCompleteEventHandler Completed;
+       }
+}
+

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventArgs.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventArgs.cs   
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventArgs.cs   
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,21 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltExecuteEventArgs : EventArgs
+       {
+               XsltDebuggerContext ctx;
+
+               public XsltExecuteEventArgs (XsltDebuggerContext ctx)
+               {
+                       this.ctx = ctx;
+               }
+
+               public XsltDebuggerContext Context {
+                       get { return ctx; }
+               }
+       }
+}

Added: 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventHandler.cs
===================================================================
--- 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventHandler.cs
    2007-06-29 07:18:13 UTC (rev 81030)
+++ 
trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltExecuteEventHandler.cs
    2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,9 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public delegate void XsltExecuteEventHandler (object o, 
XsltExecuteEventArgs args);
+}

Added: trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltInjector.cs
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltInjector.cs       
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger/XsltInjector.cs       
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,37 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace Mono.XsltDebugger
+{
+       public class XsltInjector
+       {
+               XsltDebuggerSession session;
+
+               public XsltInjector (XsltDebuggerSession session)
+               {
+                       this.session = session;
+               }
+
+               public XsltDebuggerSession Session {
+                       get { return session; }
+               }
+
+               protected virtual void OnCompile (XPathNavigator 
stylesheetElement)
+               {
+                       if (Compiled != null)
+                               Compiled (this, new XsltCompileEventArgs 
(stylesheetElement));
+               }
+
+               protected virtual void OnExecute (XPathNodeIterator 
currentNodeset, XPathNavigator stylesheetElement, XsltContext xsltContext)
+               {
+                       if (Executed != null)
+                               Executed (this, new XsltExecuteEventArgs (new 
XsltDebuggerContext (session, currentNodeset, stylesheetElement, xsltContext)));
+               }
+
+               public event XsltCompileEventHandler Compiled;
+               public event XsltExecuteEventHandler Executed;
+       }
+}
+

Added: trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger.dll.sources
===================================================================
--- trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger.dll.sources   
2007-06-29 07:18:13 UTC (rev 81030)
+++ trunk/olive/class/Mono.XsltDebugger/Mono.XsltDebugger.dll.sources   
2007-06-29 08:45:11 UTC (rev 81031)
@@ -0,0 +1,17 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Assembly/AssemblyInfo.cs
+Mono.Xml/XmlNodeWriter.cs
+Mono.XsltDebugger/XsltCompileEventArgs.cs
+Mono.XsltDebugger/XsltCompileEventHandler.cs
+Mono.XsltDebugger/XsltCompleteEventArgs.cs
+Mono.XsltDebugger/XsltCompleteEventHandler.cs
+Mono.XsltDebugger/XsltDebugger.cs
+Mono.XsltDebugger/XsltDebuggerBreakpoint.cs
+Mono.XsltDebugger/XsltDebuggerContext.cs
+Mono.XsltDebugger/XsltDebuggerException.cs
+Mono.XsltDebugger/XsltDebuggerSession.cs
+Mono.XsltDebugger/XsltExecuteEventArgs.cs
+Mono.XsltDebugger/XsltExecuteEventHandler.cs
+Mono.XsltDebugger/XsltInjector.cs

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to