+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()
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;
this.keys = keys;
this.outputs = outputs;
this.decimalFormats = decimalFormats;
+ this.msScripts = msScripts;
}
public Hashtable Variables {get{return globalVariables;}}
public XslStylesheet Style { get { return style; }}
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;
}
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; }
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 {
CSharp
}
+ public object GetExtensionObject (string ns)
+ {
+ return scripts [ns];
+ }
+
class MSXslScript {
ScriptingLanguage language = ScriptingLanguage.JScript; // i think this is the default
string implementsPrefix = null;
public string Code {
get { return code; }
}
+
+ public object Compile ()
+ {
+ throw new NotImplementedException ();
+ }
}
}
}
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;
// [QName]=>XslKey
Hashtable keys = new Hashtable();
- MSXslScriptManager msScripts = new MSXslScriptManager ();
XslTemplateTable templates;
// stylesheet attributes
get { return parameters; }
}
- public MSXslScriptManager ScriptManager{
- get { return msScripts; }
- }
-
public XPathNavigator StyleDocument {
get { return c.Input; }
}
switch (n.LocalName)
{
case "script":
- msScripts.AddScript (n);
+ c.ScriptManager.AddScript (n);
break;
}
break;
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;}}
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;