CDATA 在 Firefox 中无法正确解析
我在 Firefox 中遇到 CDATA 问题。在除 FF 之外的每个浏览器中,
下的段落标签都能正确解析。但是, 和
标记在任何浏览器中都不会被解析。我正在使用 XSLT 转换 jQuery 插件。我已经包含了 HTML、XML 和 XSL 文件。
我已经盯着这个问题太久了,却毫无进展。我做了很多研究,但没有多大帮助。
任何建议将不胜感激。谢谢!
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<div id="pagecontent"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://daersystems.com/jquery/transform/js/jquery.transform.js"></script>
<script>
$(function() {
$("#pagecontent").transform({xml: "test.xml", xsl: "test.xsl"});
});
</script>
</body>
</html>
XML
<?xml version="1.0" encoding="windows-1252"?>
<news>
<newsRelease newsId="1341" category="PRD" subcategory="SPP">
<region>NA</region>
<site>MCA</site>
<country>US</country>
<status>P</status>
<headline>
<![CDATA[Lorem Ipsum]]></headline>
<subHeadline>
<![CDATA[Lorem™ <br />This is a headline.]]></subHeadline>
<location><![CDATA[New York, NY]]></location>
<language>English</language>
<releaseDate>January 05, 2011</releaseDate>
<releaseDate2></releaseDate2>
<publishDate>01/05/2011</publishDate>
<encrptSw>N</encrptSw>
<newsDesc>
<![CDATA[
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. </p>
<p>Curabitur at nisi nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean nisi erat, faucibus a posuere sed, blandit nec nisl. Fusce commodo vulputate tortor, at lacinia est porttitor et. Aliquam commodo nulla neque, nec fringilla felis. Sed sollicitudin aliquam mi, in egestas nunc suscipit sed. Donec sed odio massa, at auctor ipsum. Aenean vitae erat justo. Integer sed erat lectus, in faucibus dolor. </p>
<p>Proin molestie hendrerit auctor. Sed in quam libero. Quisque justo quam, vulputate a bibendum in, laoreet vel tortor. Praesent vel eros mi, at semper dolor. Praesent quis tincidunt justo.</p>
<p>Aenean varius, nisl quis tincidunt blandit, mi turpis laoreet ligula, at sagittis urna est ut sapien. Curabitur facilisis pharetra nisi quis imperdiet. Duis ac enim risus, in iaculis sapien. Fusce sit amet commodo felis. In eget nibh nisl, vel mollis magna. Praesent et velit quis erat suscipit malesuada.</p>
<p>Vestibulum imperdiet, elit at aliquet ullamcorper, odio orci posuere erat, sed facilisis sapien ipsum quis est. Suspendisse id mollis velit. Aenean tincidunt volutpat lacus ut dapibus. In tellus neque, lacinia sit amet feugiat id, venenatis vel sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
<p>For more on this feature, please visit: <br />
<a href="http://www.google.com">http://www.google.com</a></p>
]]>
</newsDesc>
<footers>
<footer>
<id>1381</id>
<footerTxt>
<![CDATA[<strong>About this Service<br /></strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. For more information, go to <a href="http://www.google.com">www.google.com</a>]]></footerTxt>
<displayOrder>1</displayOrder>
</footer>
<footer>
<id>1382</id>
<footerTxt>
<![CDATA[<strong>About this Product<br /></strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. For more information, please visit us at <a href="http://www.google.com">www.google.com</a>. ]]></footerTxt>
<displayOrder>2</displayOrder>
</footer>
</footers>
<multimedia>
<images></images>
<videos></videos>
<podcasts></podcasts>
<documents></documents>
</multimedia>
<rss url=""/>
</newsRelease>
</news>
XSL
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes" standalone="yes"/>
<xsl:output />
<xsl:template match="/news">
<xsl:variable name="pageTitle" select="newsRelease/seo/pageTitle"/>
<xsl:variable name="keywords" select="newsRelease/seo/keywords"/>
<xsl:variable name="description" select="newsRelease/seo/description"/>
<xsl:variable name="isImage" select="count(newsRelease/multimedia/images/image)"/>
<xsl:variable name="isDoc" select="count(newsRelease/multimedia/documents/document)"/>
<xsl:variable name="isIPOD" select="count(newsRelease/multimedia/podcasts/podcast)"/>
<xsl:variable name="isVideo" select="count(newsRelease/multimedia/videos/video)"/>
<h4 class="content-subtitle" style="width:250px;">Contacts</h4>
<xsl:for-each select="newsRelease/contacts/contact">
<xsl:variable name="emailAddr" select="email" />
<p><a style="font-size:11px; font-family: Arial, Verdana, Helvetica, sans-serif; color:#397984;" href="mailto:{$emailAddr}"><xsl:value-of select="name"/></a>, <xsl:value-of select="companyName"/>, <xsl:value-of select="phoneNumber" /></p>
</xsl:for-each>
<xsl:if test="$isDoc>0">
<div class="info-box right">
<h5>Related Information</h5>
<div id="info-padding"><strong>Document Download</strong></div>
<xsl:for-each select="newsRelease/multimedia/documents/document">
<div id="info-padding"><img src="../images/download_img.jpg" height="14" width="14" border="0" /> <xsl:variable name="documentSrc" select="@src" /><a href="{$documentSrc}"> download</a></div>
</xsl:for-each>
</div>
</xsl:if>
<div class="news-subtitle"><xsl:value-of select="newsRelease/headline" /></div> <br />
<strong><em><xsl:value-of select="newsRelease/subHeadline" /></em></strong>
<p> </p>
<p><em><strong><xsl:value-of select="newsRelease/location"/>, <xsl:value-of select="newsRelease/releaseDate"/></strong> - </em>
<xsl:value-of select="newsRelease/newsDesc" disable-output-escaping="yes" /></p>
<xsl:for-each select="newsRelease/footers/footer">
<p> <xsl:value-of select="footerTxt" /></p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I'm having an issue with CDATA in Firefox. The paragraph tags under the <newsDesc>
are correctly parsed in every browser except FF. However, <strong>
and <br/>
tags aren't being parsed at all in any browser. I am using a XSLT transform jQuery plugin. I've included my HTML, XML, and XSL files.
I've been staring at this issue for way too long and am getting nowhere. I've done quite a bit of research but it hasn't helped much.
Any suggestions would be greatly appreciated. Thanks!
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<div id="pagecontent"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://daersystems.com/jquery/transform/js/jquery.transform.js"></script>
<script>
$(function() {
$("#pagecontent").transform({xml: "test.xml", xsl: "test.xsl"});
});
</script>
</body>
</html>
XML
<?xml version="1.0" encoding="windows-1252"?>
<news>
<newsRelease newsId="1341" category="PRD" subcategory="SPP">
<region>NA</region>
<site>MCA</site>
<country>US</country>
<status>P</status>
<headline>
<![CDATA[Lorem Ipsum]]></headline>
<subHeadline>
<![CDATA[Lorem™ <br />This is a headline.]]></subHeadline>
<location><![CDATA[New York, NY]]></location>
<language>English</language>
<releaseDate>January 05, 2011</releaseDate>
<releaseDate2></releaseDate2>
<publishDate>01/05/2011</publishDate>
<encrptSw>N</encrptSw>
<newsDesc>
<![CDATA[
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. </p>
<p>Curabitur at nisi nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean nisi erat, faucibus a posuere sed, blandit nec nisl. Fusce commodo vulputate tortor, at lacinia est porttitor et. Aliquam commodo nulla neque, nec fringilla felis. Sed sollicitudin aliquam mi, in egestas nunc suscipit sed. Donec sed odio massa, at auctor ipsum. Aenean vitae erat justo. Integer sed erat lectus, in faucibus dolor. </p>
<p>Proin molestie hendrerit auctor. Sed in quam libero. Quisque justo quam, vulputate a bibendum in, laoreet vel tortor. Praesent vel eros mi, at semper dolor. Praesent quis tincidunt justo.</p>
<p>Aenean varius, nisl quis tincidunt blandit, mi turpis laoreet ligula, at sagittis urna est ut sapien. Curabitur facilisis pharetra nisi quis imperdiet. Duis ac enim risus, in iaculis sapien. Fusce sit amet commodo felis. In eget nibh nisl, vel mollis magna. Praesent et velit quis erat suscipit malesuada.</p>
<p>Vestibulum imperdiet, elit at aliquet ullamcorper, odio orci posuere erat, sed facilisis sapien ipsum quis est. Suspendisse id mollis velit. Aenean tincidunt volutpat lacus ut dapibus. In tellus neque, lacinia sit amet feugiat id, venenatis vel sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
<p>For more on this feature, please visit: <br />
<a href="http://www.google.com">http://www.google.com</a></p>
]]>
</newsDesc>
<footers>
<footer>
<id>1381</id>
<footerTxt>
<![CDATA[<strong>About this Service<br /></strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. For more information, go to <a href="http://www.google.com">www.google.com</a>]]></footerTxt>
<displayOrder>1</displayOrder>
</footer>
<footer>
<id>1382</id>
<footerTxt>
<![CDATA[<strong>About this Product<br /></strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu quam nulla. Morbi tellus leo, dignissim et euismod in, volutpat ut mi. Ut a pharetra odio. Mauris dui magna, eleifend eget pellentesque a, tempus eget mi. Praesent luctus, lorem at egestas rutrum, mi massa pulvinar enim, quis porttitor arcu felis non enim. Integer vel diam ac augue pretium gravida. Duis ut arcu a neque commodo sodales. Sed sit amet nisl arcu, eu pulvinar mauris. For more information, please visit us at <a href="http://www.google.com">www.google.com</a>. ]]></footerTxt>
<displayOrder>2</displayOrder>
</footer>
</footers>
<multimedia>
<images></images>
<videos></videos>
<podcasts></podcasts>
<documents></documents>
</multimedia>
<rss url=""/>
</newsRelease>
</news>
XSL
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes" standalone="yes"/>
<xsl:output />
<xsl:template match="/news">
<xsl:variable name="pageTitle" select="newsRelease/seo/pageTitle"/>
<xsl:variable name="keywords" select="newsRelease/seo/keywords"/>
<xsl:variable name="description" select="newsRelease/seo/description"/>
<xsl:variable name="isImage" select="count(newsRelease/multimedia/images/image)"/>
<xsl:variable name="isDoc" select="count(newsRelease/multimedia/documents/document)"/>
<xsl:variable name="isIPOD" select="count(newsRelease/multimedia/podcasts/podcast)"/>
<xsl:variable name="isVideo" select="count(newsRelease/multimedia/videos/video)"/>
<h4 class="content-subtitle" style="width:250px;">Contacts</h4>
<xsl:for-each select="newsRelease/contacts/contact">
<xsl:variable name="emailAddr" select="email" />
<p><a style="font-size:11px; font-family: Arial, Verdana, Helvetica, sans-serif; color:#397984;" href="mailto:{$emailAddr}"><xsl:value-of select="name"/></a>, <xsl:value-of select="companyName"/>, <xsl:value-of select="phoneNumber" /></p>
</xsl:for-each>
<xsl:if test="$isDoc>0">
<div class="info-box right">
<h5>Related Information</h5>
<div id="info-padding"><strong>Document Download</strong></div>
<xsl:for-each select="newsRelease/multimedia/documents/document">
<div id="info-padding"><img src="../images/download_img.jpg" height="14" width="14" border="0" /> <xsl:variable name="documentSrc" select="@src" /><a href="{$documentSrc}"> download</a></div>
</xsl:for-each>
</div>
</xsl:if>
<div class="news-subtitle"><xsl:value-of select="newsRelease/headline" /></div> <br />
<strong><em><xsl:value-of select="newsRelease/subHeadline" /></em></strong>
<p> </p>
<p><em><strong><xsl:value-of select="newsRelease/location"/>, <xsl:value-of select="newsRelease/releaseDate"/></strong> - </em>
<xsl:value-of select="newsRelease/newsDesc" disable-output-escaping="yes" /></p>
<xsl:for-each select="newsRelease/footers/footer">
<p> <xsl:value-of select="footerTxt" /></p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Firefox 不支持您尝试使用的禁用输出转义,因此通常 Firefox 或 Mozilla 浏览器无法使用该方法。
Firefox does not support disable-output-escaping you try to use so that approach is not possible with Firefox or Mozilla browsers in general.