Tutorial :C# script in XSLT: “msxsl:script cannot be empty” error



Question:

I have an XSLT with a C# script in it:

<msxsl:script language="C#" implements-prefix="user">    <msxsl:using namespace="System.Xml"/>    <msxsl:using namespace="System.Xml.XPath"/>    <![CDATA[      public string GetMenuPath(XPathNodeIterator node)      {               XPathNavigator dataSourceNode = node.Current;        return dataSourceNode.Name;      }    ]]>  </msxsl:script>  

And somewhere in the XSLT this function is called:

<xsl:value-of select="user:GetMenuPath(current())"/>  

But as I try to run the XSLT transformation on the XML input (the input does not matter), it stop immediately with the error "msxsl:script cannot be empty".

I have absolutely no idea why... I use nxslt with .NET Framework.

Thank you for help !


Solution:1

Thank you for your answers, I found out the origin of the problem now. It was because I was using the "style" tag instead of "nxslt" for calling the XSLT transformation. "style" works as long as there is no extension script.

<nxslt style="transformation.xsl" in="input.xml" out="output.xls" verbose="true">  


Solution:2

Does it give you the line that the transformation stops on? Is it where it is calling from or in the script tag?


Solution:3

Have you tried putting your extension method into a separate assembly and referencing it that way?

Marc


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »