[Mono-bugs] [Bug 46282][Nor] New - Xslt processor expects ArrayList parameter when calling extension object method

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 13 Jul 2003 23:56:49 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jc@manoli.net.

http://bugzilla.ximian.com/show_bug.cgi?id=46282

--- shadow/46282	Sun Jul 13 23:56:49 2003
+++ shadow/46282.tmp.29651	Sun Jul 13 23:56:49 2003
@@ -0,0 +1,168 @@
+Bug#: 46282
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jc@manoli.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Xslt processor expects ArrayList parameter when calling extension object method
+
+Description of Problem:
+-----------------------
+On mono 0.25, when the xslt processor calls a method from an extension 
+object, an exception is thrown if the method's parameter is not 
+System.Collections.ArrayList.
+
+On the .NET Frameowrk 1.0 or 1.1, methods with other types of parameters 
+can be called from the xslt.
+
+
+Steps to reproduce the problem:
+-------------------------------
+1. save the source code at the end of this message on your disk as 
+XsltBug.cs
+
+2. enter:  mcs -t:exe -out:XsltBug.exe XsltBug.cs
+
+3. enter:  mono XsltBug.exe
+
+
+Actual Results:
+---------------
+Unhandled Exception: System.Xml.XmlException: No applicable function for 
+Process
+This takes (System.Collections.ArrayList)
+in <0x00238> 00 .ReflectedExtensionFunction:Function (object[])
+in <0x0004a> 01 System.MulticastDelegate:invoke_object_object[] (object[])
+in <0x002c4> 00 .ExtensionFunctionWrapper:Function (intptr,int)
+in <0x00035> 05 .ExtensionFunctionWrapper:Function (intptr,int)
+in (unmanaged) 06 System.Xml.Xsl.XslTransform:xsltApplyStylesheetUser 
+(intptr,in
+tptr,string[],string,intptr,intptr)
+in <0x00004> 06 System.Xml.Xsl.XslTransform:xsltApplyStylesheetUser 
+(intptr,intp
+tr,string[],string,intptr,intptr)
+in <0x009e6> 00 System.Xml.Xsl.XslTransform:ApplyStylesheet (intptr,string
+[],Sys
+tem.Collections.Hashtable)
+in <0x00028> 00 System.Xml.Xsl.XslTransform:ApplyStylesheetAndGetString 
+(intptr,
+string[],System.Collections.Hashtable)
+in <0x00446> 00 System.Xml.Xsl.XslTransform:Transform 
+(System.Xml.XPath.XPathNav
+igator,System.Xml.Xsl.XsltArgumentList,System.IO.TextWriter)
+in <0x00043> 00 System.Xml.Xsl.XslTransform:Transform 
+(System.Xml.XPath.XPathNav
+igator,System.Xml.Xsl.XsltArgumentList,System.Xml.XmlWriter)
+in <0x00066> 00 System.Xml.Xsl.XslTransform:Transform 
+(System.Xml.XPath.IXPathNa
+vigable,System.Xml.Xsl.XsltArgumentList,System.Xml.XmlWriter)
+in <0x0016a> 00 XsltExtensionTest.EntryPoint:Main (string[])
+
+
+Expected Results:
+-----------------
+The correct result is obtained when run on the .NET Framework:
+
+                Items:
+                @name=plop,
+                @name=glop,
+
+
+How often does this happen?
+---------------------------
+Always
+
+
+Additional Information:
+-----------------------
+XsltBug.cs source code:
+
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.Xsl;
+using System.Xml.XPath;
+using System.Reflection;
+
+namespace XsltExtensionTest
+{
+	/// <summary>
+	/// A test case for xslt extension objects problem.
+	/// </summary>
+	class EntryPoint
+	{
+		const string myxslt = 
+@"<?xml version=""1.0"" encoding=""UTF-8"" ?>
+<xsl:stylesheet version=""1.0"" 
+xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" 
+xmlns:MyExt=""urn:MyExt"">
+	<xsl:template match=""data"">
+		Items:
+		<xsl:for-each select=""item"">
+			<xsl:value-of select=""MyExt:ProcessThis
+(@name)"" />, 
+		</xsl:for-each>
+	</xsl:template>
+</xsl:stylesheet>";
+
+		const string myxml = 
+@"<?xml version=""1.0"" encoding=""utf-8"" ?> 
+<data>
+	<item name=""plop"" />
+	<item name=""glop"" />
+</data>";
+
+		/// <summary>
+		/// The main entry point.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{
+			//load the stylesheet
+			TextReader reader = new StringReader(myxslt);
+			XslTransform xslt = new XslTransform();
+			xslt.Load(new XmlTextReader(reader));
+
+			//load the xml file
+			reader = new StringReader(myxml);
+			XPathDocument doc = new XPathDocument(reader);
+
+			//create XsltArgumentList with extension object.
+			XsltArgumentList xslArg = new XsltArgumentList();
+			SimpleExtension ext = new SimpleExtension();
+			xslArg.AddExtensionObject("urn:MyExt", ext);
+
+			//create an XmlTextWriter to output to the 
+console.             
+			XmlTextWriter writer = new XmlTextWriter
+(Console.Out);
+
+			//transform the file.
+			xslt.Transform(doc, xslArg, writer);
+			writer.Close();
+
+			Console.Read();
+		}
+	}
+
+	/// <summary>
+	/// A dummy extension object for my xslt.
+	/// </summary>
+	public class SimpleExtension
+	{
+		public string ProcessThis(string name)
+		{
+			return "@name=" + name;
+		}
+	}
+}