扩展对象“urn:myDiscount”没有具有 1 参数的匹配“returnDiscount”方法。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Xml.Xsl.XslLoadException: 扩展对象“urn:myDiscount”没有具有 1 参数的匹配“returnDiscount”方法。源错误:
行 24: XsltSettings settings = new XsltSettings(false,true);
行 25: XslCompiledTransform transform = new XslCompiledTransform();
行 26: transform.Load(xslpath,settings,null);
行 27: transform.Transform(document ,null ,Response.Output);
行 28: 源文件: c:\Inetpub\wwwroot\chapter7\dd.aspx.cs 行: 26
Program:
protected void Page_Load(object sender, EventArgs e)
{
string xmlfile = @"C:\Inetpub\wwwroot\chapter7\book.xml";
string xslpath = @"C:\Inetpub\wwwroot\chapter7\XSLTFile.xsl"; XPathDocument document = new XPathDocument(xmlfile);
XsltSettings settings = new XsltSettings(false,true);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(xslpath,settings,null);//???此句有错误
transform.Transform(document ,null ,Response.Output);}相关的XSL代码:
<td> <xsl:value-of select="myDiscount:returnDiscount(price)"/></td>
<msxsl:script language="c#" implements-prefix="myDiscount" >
<![CDATA[
public string ReturnDiscount(string price)
{
decimal priceValue =Convert.ToDecimal(price);
return (priceValue * 15/100).ToString();
}
]]>
</msxsl:script>
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Xml.Xsl.XslLoadException: 扩展对象“urn:myDiscount”没有具有 1 参数的匹配“returnDiscount”方法。源错误:
行 24: XsltSettings settings = new XsltSettings(false,true);
行 25: XslCompiledTransform transform = new XslCompiledTransform();
行 26: transform.Load(xslpath,settings,null);
行 27: transform.Transform(document ,null ,Response.Output);
行 28: 源文件: c:\Inetpub\wwwroot\chapter7\dd.aspx.cs 行: 26
Program:
protected void Page_Load(object sender, EventArgs e)
{
string xmlfile = @"C:\Inetpub\wwwroot\chapter7\book.xml";
string xslpath = @"C:\Inetpub\wwwroot\chapter7\XSLTFile.xsl"; XPathDocument document = new XPathDocument(xmlfile);
XsltSettings settings = new XsltSettings(false,true);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(xslpath,settings,null);//???此句有错误
transform.Transform(document ,null ,Response.Output);}相关的XSL代码:
<td> <xsl:value-of select="myDiscount:returnDiscount(price)"/></td>
<msxsl:script language="c#" implements-prefix="myDiscount" >
<![CDATA[
public string ReturnDiscount(string price)
{
decimal priceValue =Convert.ToDecimal(price);
return (priceValue * 15/100).ToString();
}
]]>
</msxsl:script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货