some work on msxml script
authorBen Maurer <benm@mono-cvs.ximian.com>
Thu, 27 Nov 2003 20:15:36 +0000 (20:15 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Thu, 27 Nov 2003 20:15:36 +0000 (20:15 -0000)
svn path=/trunk/mcs/; revision=20551

mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
mcs/class/System.XML/Mono.Xml.Xsl/MSXslScriptManager.cs
mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
mcs/class/System.XML/Mono.Xml.Xsl/XsltCompiledContext.cs

index 47e8a6f2c5b500dcfcfe756b2b91631d7ed258e0..d88548543e91c7dacdd783bd1f0c13215a5e2815 100644 (file)
@@ -1,3 +1,11 @@
+2003-11-27 Ben Maurer  <bmaurer@users.sourceforge.net>
+
+       * Compiler.cs
+       * MSXslScriptManager.cs
+       * XslStylesheet.cs
+       * XslTransformProcessor.cs
+       * XsltCompiledContext.cs: Some work on msxsl script.
+
 2003-11-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
 
        (in general: cdata-section-elements support, correct document() 
index 323abb3e020fae05b0375c066fd32d4eb372559b..e9189365fb092d46a7dcdb665f1d7928bf1ee1ee 100644 (file)
@@ -36,8 +36,10 @@ namespace Mono.Xml.Xsl {
                Hashtable keys;
                Hashtable outputs;
                Hashtable decimalFormats;
+               MSXslScriptManager msScripts;
                
-               public CompiledStylesheet (XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, ExpressionStore exprStore, XmlNamespaceManager nsMgr, Hashtable keys, Hashtable outputs, Hashtable decimalFormats)
+               public CompiledStylesheet (XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, ExpressionStore exprStore, XmlNamespaceManager nsMgr, Hashtable keys, Hashtable outputs, Hashtable decimalFormats,
+                       MSXslScriptManager msScripts)
                {
                        this.style = style;
                        this.globalVariables = globalVariables;
@@ -47,6 +49,7 @@ namespace Mono.Xml.Xsl {
                        this.keys = keys;
                        this.outputs = outputs;
                        this.decimalFormats = decimalFormats;
+                       this.msScripts = msScripts;
                }
                public Hashtable Variables {get{return globalVariables;}}
                public XslStylesheet Style { get { return style; }}
@@ -55,6 +58,11 @@ namespace Mono.Xml.Xsl {
                public Hashtable Keys {get { return keys;}}
                public Hashtable Outputs { get { return outputs; }}
                
+               public MSXslScriptManager ScriptManager {
+                       get { return msScripts; }
+               }
+               
+               
                public XslDecimalFormat LookupDecimalFormat (QName name)
                {
                        XslDecimalFormat ret = decimalFormats [name] as XslDecimalFormat;
@@ -117,9 +125,15 @@ namespace Mono.Xml.Xsl {
                        }
                        this.rootStyle = new XslStylesheet (this);
                        
-                       return new CompiledStylesheet (rootStyle, globalVariables, attrSets, exprStore, nsMgr, rootStyle.Keys, outputs, decimalFormats);
+                       return new CompiledStylesheet (rootStyle, globalVariables, attrSets, exprStore, nsMgr, rootStyle.Keys, outputs, decimalFormats, msScripts);
                }
                
+               MSXslScriptManager msScripts = new MSXslScriptManager ();
+               public MSXslScriptManager ScriptManager {
+                       get { return msScripts; }
+               }
+               
+               
 #region Input
                public XPathNavigator Input {
                        get { return currentInput; }
index 1ca0e5fa03cdc90a39d926bab662b753cb52c76e..9a11d970e9d108de0767715b51d45f74996019d3 100644 (file)
@@ -18,23 +18,14 @@ using System.Xml.Xsl;
 namespace Mono.Xml.Xsl {
 
        public class MSXslScriptManager {
-               ArrayList jsScripts = new ArrayList ();
-               ArrayList vbScripts = new ArrayList ();
-               ArrayList csScripts = new ArrayList ();
+               Hashtable scripts = new Hashtable ();
                
                public MSXslScriptManager () {}
                
                public void AddScript (XPathNavigator nav)
                {
                        MSXslScript s = new MSXslScript (nav);
-                       switch (s.Language) {
-                               case ScriptingLanguage.JScript:
-                                       jsScripts.Add (s); break;
-                               case ScriptingLanguage.VisualBasic:
-                                       vbScripts.Add (s); break;
-                               case ScriptingLanguage.CSharp:
-                                       csScripts.Add (s); break;
-                       }
+                       scripts.Add (s.ImplementsPrefix, s.Compile ());
                }
                
                enum ScriptingLanguage {
@@ -43,6 +34,11 @@ namespace Mono.Xml.Xsl {
                        CSharp
                }
                
+               public object GetExtensionObject (string ns)
+               {
+                       return scripts [ns];
+               }
+               
                class MSXslScript {
                        ScriptingLanguage language = ScriptingLanguage.JScript;  // i think this is the default
                        string implementsPrefix = null;
@@ -89,6 +85,11 @@ namespace Mono.Xml.Xsl {
                        public string Code {
                                get { return code; }
                        }
+                       
+                       public object Compile ()
+                       {
+                               throw new NotImplementedException ();
+                       }
                }
        }
 }
index ce81646bda0f313c12841cd259429e84075b81e9..e17e5c20cf8329ef2b498998bf3c1b1dda07daa1 100644 (file)
@@ -27,7 +27,7 @@ namespace Mono.Xml.Xsl {
 
        public class XslStylesheet {
                public const string XsltNamespace = "http://www.w3.org/1999/XSL/Transform";
-               public const string MSXsltNamespace = "urn:schemas-microsoft-com:xslt::script";
+               public const string MSXsltNamespace = "urn:schemas-microsoft-com:xslt";
                
                Compiler c;
 
@@ -43,7 +43,6 @@ namespace Mono.Xml.Xsl {
                // [QName]=>XslKey
                Hashtable keys = new Hashtable();
 
-               MSXslScriptManager msScripts = new MSXslScriptManager ();
                XslTemplateTable templates;
 
                // stylesheet attributes
@@ -100,10 +99,6 @@ namespace Mono.Xml.Xsl {
                        get { return parameters; }
                }
 
-               public MSXslScriptManager ScriptManager{
-                       get { return msScripts; }
-               }
-
                public XPathNavigator StyleDocument {
                        get { return c.Input; }
                }
@@ -233,7 +228,7 @@ namespace Mono.Xml.Xsl {
                                switch (n.LocalName)
                                {
                                case "script":
-                                       msScripts.AddScript (n);
+                                       c.ScriptManager.AddScript (n);
                                        break;
                                }
                                break;
index fa22f2de54b8747c9f86a2fc782ce0fe699f074d..2c05e68a6656efc38ffb043de3065d6e3a3374bf 100644 (file)
@@ -84,6 +84,11 @@ namespace Mono.Xml.Xsl {
                public CompiledStylesheet CompiledStyle { get { return compiledStyle; }}
                public XsltArgumentList Arguments {get{return args;}}
                
+               public MSXslScriptManager ScriptManager {
+                       get { return compiledStyle.ScriptManager; }
+               }
+
+               
                #region Document Resolution
                public XmlResolver Resolver {get{return resolver;}}
                
index b93894979594f5dc2134a3ef8cfd130147cab354..38556777dc5a51b26e438b0aafd6d6f4a1d89e42 100644 (file)
@@ -51,25 +51,35 @@ namespace Mono.Xml.Xsl {
 
                        string ns = name.Namespace;
 
-                       if (ns == null || p.Arguments == null) return null;
+                       if (ns == null) return null;
 
-                       object extension = p.Arguments.GetExtensionObject (ns);
+                       object extension = null;
+                       
+                       if (p.Arguments != null)
+                               p.Arguments.GetExtensionObject (ns);
+                       
+                       bool isScript = false;
+                       if (extension == null) {
+                               extension = p.ScriptManager.GetExtensionObject (ns);
+                               if (extension == null)
+                                       return null;
                                
-                       if (extension == null)
-                               return null;                    
+                               isScript = true;
+                       }
+                       
                        
-                       MethodInfo method = FindBestMethod (extension.GetType (), name.Name, argTypes);
+                       MethodInfo method = FindBestMethod (extension.GetType (), name.Name, argTypes, isScript);
                        
                        if (method != null) 
                                return new XsltExtensionFunction (extension, method);
                        return null;
                }
                
-               MethodInfo FindBestMethod (Type t, string name, XPathResultType [] argTypes)
+               MethodInfo FindBestMethod (Type t, string name, XPathResultType [] argTypes, bool isScript)
                {
                        int free, length;
                        
-                       MethodInfo [] mi = t.GetMethods (BF.Public | BF.Instance | BF.Static);
+                       MethodInfo [] mi = t.GetMethods ((isScript ? BF.Public | BF.NonPublic : BF.Public) | BF.Instance | BF.Static);
                        if (mi.Length == 0)
                                return null;