我正在升级asp.net v3.5网络应用程序.到v4,我在XmlDataSource对象上使用的XSLT转换遇到了一些问题.
XSLT文件的一部分:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:HttpUtility="ds:HttpUtility">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/Menus">
<MenuItems>
<xsl:call-template name="MenuListing" />
</MenuItems>
</xsl:template>
<xsl:template name="MenuListing">
<xsl:apply-templates select="Menu" />
</xsl:template>
<xsl:template match="Menu">
<MenuItem>
<xsl:attribute name="Text">
<xsl:value-of select="HttpUtility:HtmlEncode(MenuTitle)"/>
</xsl:attribute>
<xsl:attribute name="ToolTip">
<xsl:value-of select="MenuTitle"/>
</xsl:attribute>
</MenuItem>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
问题似乎就在于此
<xsl:value-of select="HttpUtility:HtmlEncode(MenuTitle)"/>
Run Code Online (Sandbox Code Playgroud)
删除它并用普通文本替换它,它将工作.我设置XML数据源的方式:
xmlDataSource.TransformArgumentList.AddExtensionObject("ds:HttpUtility", new System.Web.HttpUtility());
xmlDataSource.Data = Cache.FetchPageMenu();
Run Code Online (Sandbox Code Playgroud)
我一直在微软页面上搜索v4的任何变化,但找不到任何变化.所有这些在v3.5(以及v2之前)中运行良好.没有收到任何错误,数据只是没有显示.