System.Xml.Xsl.XslLoadException: 未定义前缀“myDiscount”。
异常详细信息: System.Xml.Xsl.XslLoadException: 未定义前缀“myDiscount”。
源错误:
行 32: Discount discount = new Discount();
行 33: argumentlist.AddExtensionObject("urn:myDiscount", discount);
行 34: transform.Load(xslPath);
行 35: transform.Transform(docutment, argumentlist, Response.Output);
行 36:
源文件: c:\Inetpub\wwwroot\chapter7\ccc.aspx.cs 行: 34
Program:
protected void Page_Load(object sender, EventArgs e)
{
string xmlfile = @"C:\Inetpub\wwwroot\chapter7\book.xml";
string xslPath = @"C:\Inetpub\wwwroot\chapter7\Books_with_Extensions.xsl";
XPathDocument docutment = new XPathDocument(xmlfile);
XslCompiledTransform transform = new XslCompiledTransform();
XsltArgumentList argumentlist = new XsltArgumentList();
Discount discount = new Discount();
argumentlist.AddExtensionObject("urn:myDiscount", discount);
transform.Load(xslPath);
transform.Transform(docutment, argumentlist, Response.Output);
}
Books_with_Extensions.xsl:
<td>
<xsl:value-of select="myDiscount:returnDiscount(price)"/>
</td>