Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用XSLT解码HTML编码的内容_Html_Xml_Xslt_Escaping - Fatal编程技术网

使用XSLT解码HTML编码的内容

使用XSLT解码HTML编码的内容,html,xml,xslt,escaping,Html,Xml,Xslt,Escaping,我有一个网页,在点击链接时执行一些javascript。链接是: <a href="javascript:void(0)" onclick="XsltTransform('category.xml','category.xslt');">Latest news</a> 我希望解码的HTML块在渲染时被编码,我的印象是这就是禁用输出转义所允许的 如何使这个非常原始的XML再次成为真正的HTML?并非所有XSLT处理器都支持禁用输出转义。Firefox就是其中一个不

我有一个网页,在点击链接时执行一些javascript。链接是:

<a
  href="javascript:void(0)"
  onclick="XsltTransform('category.xml','category.xslt');">Latest news</a>
我希望解码的HTML块在渲染时被编码,我的印象是这就是禁用输出转义所允许的


如何使这个非常原始的XML再次成为真正的HTML?

并非所有XSLT处理器都支持
禁用输出转义。Firefox就是其中一个不这么做的


Firefox有一个开放的bug,它缺乏对它的支持:

并非所有XSLT处理器都支持
禁用输出转义。Firefox就是其中一个不这么做的


Firefox有一个开放的bug,它缺乏对它的支持:

在转换ATOM XML时遇到了类似的问题,其中帖子的内容包含转义的HTML标记。禁用输出转义似乎适用于大多数浏览器,但不适用于Firefox。因此,作为一种解决方法,我在XSLT中向所有有问题的输出节点添加class=“renderhtml”属性,作为javascript的提示。然后在转换后添加以下代码

// work around for XSLT disable-output-escaping="yes" not working in Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1) {
  // get all "renderhtml" hints (HTML escaped within CDATA/text) nodes, then unescape and render HTML code
  var nodes = document.getElementsByClassName("renderhtml");
  for (var i = nodes.length - 1; i >= 0; i--) {
    nodes[i].innerHTML = nodes[i].textContent;
  }
}

在转换ATOM XML时遇到了类似的问题,其中帖子的内容包含转义的HTML标记。禁用输出转义似乎适用于大多数浏览器,但不适用于Firefox。因此,作为一种解决方法,我在XSLT中向所有有问题的输出节点添加class=“renderhtml”属性,作为javascript的提示。然后在转换后添加以下代码

// work around for XSLT disable-output-escaping="yes" not working in Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1) {
  // get all "renderhtml" hints (HTML escaped within CDATA/text) nodes, then unescape and render HTML code
  var nodes = document.getElementsByClassName("renderhtml");
  for (var i = nodes.length - 1; i >= 0; i--) {
    nodes[i].innerHTML = nodes[i].textContent;
  }
}

您在样式表中将输出元素设置为html了吗?您在样式表中将输出元素设置为html了吗?您会推荐其他浏览器吗?最终,我实际上是在为iOS构建一个web应用程序,所以这将由mobile safari执行,但我们不允许在这里安装桌面safari…您会推荐其他浏览器吗?最终,我正在为iOS构建一个web应用程序,所以这将由mobile safari执行,但我们不允许在这里安装桌面safari。。。
  <xsl:template match="/">
    <p>
      <xsl:value-of select="*/*/Body" disable-output-escaping="yes" />
    </p>
  </xsl:template>
&lt;p&gt;It may have taken over 12 years
// work around for XSLT disable-output-escaping="yes" not working in Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1) {
  // get all "renderhtml" hints (HTML escaped within CDATA/text) nodes, then unescape and render HTML code
  var nodes = document.getElementsByClassName("renderhtml");
  for (var i = nodes.length - 1; i >= 0; i--) {
    nodes[i].innerHTML = nodes[i].textContent;
  }
}