我在Firefox中遇到CDATA问题。 <newsDesc>
下的段落标记在除FF之外的每个浏览器中都被正确解析。但是,在任何浏览器中都不会解析<strong>
和<br/>
标记。我正在使用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>
答案 0 :(得分:3)
Firefox不支持您尝试使用的disable-output-escaping,因此通常无法使用Firefox或Mozilla浏览器。