我使用VS 2008,.net 3.5使用XSLT生成页面html。替换 r n使用XSLT和.NET的换行符VS 2008
我有信息,包含\ r \ n(新行)
我在XSL文件中使用此:
<b>Message: </b><xsl:value-of select="Message"/><br/>
我需要<br/>
在XSL替换\ r \ n。我见过几个引用,但对我的问题没有得到解决:
我使用此代码C#之前,我打电话变换XSLT,但不正确的:
m = m.Replace(@"\r\n", "
");
m = m.Replace(@"\n", "
");
//m = System.Web.HttpUtility.HtmlDecode(m);
m = m.Replace(@"\r\n", "<br/>");
m = m.Replace(@"\n", "<br/>");
msg = "<Exception>"
+ "<Description>" + d + "</Description>"
+ "<Message>" + m + "</Message>"
+ "<DateTime>" + localTimeString + "</DateTime>"
+ "</Exception>";
我用这个引用,而不是解决方案
Interpreting newlines with xsl:text?
XSLT Replace function not found
的替换功能只在XSLT 2.0版可用,而不是在版本sion 1.0是Visual Studio使用的。仅仅因为你指定了version =“2.0”并不意味着Visual Studio支持它。
我用这个像的最后一个引用,但我得到的错误:
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="Message"/>
<xsl:with-param name="replace" select="\r\n"/>
<xsl:with-param name="by" select="<br/>"/>
</xsl:call-template>
建议,任何示例代码工作?
好问题(+1)。查看我的答案以解释问题和完整的解决方案。 :) – 2010-08-22 15:13:41