XSL禁用输出转义不起作用 [英] XSL disable-output-escaping not working

查看:55
本文介绍了XSL禁用输出转义不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中提取参数

I am pulling a parameter from the database

<xsl:param name="theMessage"></xsl:param>

通过html提取的数据如下:

The data that is pulled html like below:

<style type="text/css">#container {width:100%; margin-top:20px; text-align:center; font-family: Verdana, arial; font-size:100%; font-weight:normal; }</style><div id="container"><b>Text here</b></div>

XSL:

<xsl:value-of select="$theMessage" disable-output-escaping="yes" />

它显示为代码而不是所需的输出.对我要去哪里有任何想法吗?是在xsl方面,还是在数据库中需要CDATA等?

And it displays as the code and not the output desired. Any ideas on where I am going wrong? Is it on the xsl side or do I need CDATA in the database etc?

谢谢.

推荐答案

虽然过去对我有用的输出转义功能,但它并未对这串数据执行此操作,因为该数据包含需要转义的'标记.

While output escaping has worked for me in the past, it did not do so on this string of data because the data contained ' marks which needed to be escaped.

所以字符串就这样(在Java中).

so the string was as such (in java).

returnStr = returnStr.replace("'","\\'"); - this escaped those pesky tic marks, or single quotes

并且returnStr等于:< style type ="text/css"> #container {width:100%;margin-top:20px;text-align:center;字体家族:Verdana,arial;字体大小:100%;font-weight:normal;}</style>< div id ="container">< b>此处的文本</b></div> ...以及更多的html代码和文本

And the returnStr was equal to:<style type="text/css">#container {width:100%; margin-top:20px; text-align:center; font-family: Verdana, arial; font-size:100%; font-weight:normal; }</style><div id="container"><b>Text here</b></div>...plus a lot more html code and text

xsl参数相同:

<xsl:param name="theMessage"></xsl:param>

在样式表上,新代码如下所示:

And on the stylesheet the new code looked as such:

<div id="bilbo"></div>
    <script type="text/javascript">
    var outputString = '<xsl:value-of select="$theMessage" />'
    document.getElementById('bilbo').innerHTML = outputString;
    </script>  

从数据库中提取数据,除去单引号,将字符串设置为xsl参数,将参数设置为js变量,然后将其放在div中作为需要的html-作为输出.

That pulled the data from the database, stripped out the single quotes, set the string to an xsl parameter, set the parameter to a js variable, then put it inside a div as the html it needed to be - as output.

这篇关于XSL禁用输出转义不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆