但是其他浏览器可以

但是其他浏览器可以

本文介绍了Firefox 3不适用我的xslt样式表,但是其他浏览器可以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从web服务器动态生成xml页面,并从同一个web服务器提供一个自定义的静态xslt,将处理转移到客户端的web浏览器中。



直到最近,我在Firefox 2,3,IE5,6和Chrome中都能正常工作。最近,虽然有些变化,Firefox 3现在只显示源文本元素。



页面源代码如下所示:

 <?xml version =1.0encoding =UTF-8?> 
<! - Firefox 2.0和Internet Explorer 7使用简单的提要嗅探来覆盖此提要的所需呈现行为,因此我们有义务插入此评论,这是一个不幸的带宽浪费。这应该确保以下样式表处理指令得到这些新的浏览器版本的支持。对于一些更多的背景,您可能想要访问以下错误报告:https://bugzilla.mozilla.org/show_bug.cgi?id = 338621 - >
<?xml-stylesheet type =text / xslhref =/ WebObjects / SantaPreview.woa / Contents / WebServerResources / Root.xsl?>
< wrapper xmlns =http://www.bbc.co.uk/ContentInterface/Contentxmlns:cont =http://www.bbc.co.uk/ContentInterface/ContentsceneId = T2a_INDEXserviceName =DSat_T2>
....

Firebug显示正在加载Root.xsl文件,它的响应标题包括行

  Content-Type text / xml 

我也试过用application / xml作为内容类型,但是没有区别: - (



Web Developer Extension也会显示正确的生成源代码,如果您保存并在Firefox中加载页面,它将正确显示。



显示问题的Firefox版本是3.0.3



任何想法我可能做错了吗?



对我来说,这意味着你的xpath表达式会有些腥意,xsl:template / @ match属性与源文档不匹配。



你不能提供足够的信息进一步诊断,所以这个盲目的猜测是我可以提供的。

编辑:原来的问题是,IE和Chrome静静地接受一个节点集作为参数字符串长度,而FF3不。请注意,规范要求一个可选的字符串参数,并且不指定具有nodeset参数的行为。


I'm trying to serve dynamically generated xml pages from a web server, and provide a custom, static, xslt from the same web server, that will offload the processing into the client web browser.

Until recently, I had this working fine in Firefox 2, 3, IE5, 6 and Chrome. Recently, though, something has changed, and Firefox 3 now displays just the text elements in the source.

The page source starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Firefox 2.0 and Internet Explorer 7 use simplistic feed sniffing to override desired presentation behavior for this feed, and thus we are obliged to insert this comment, a bit of a waste of bandwidth, unfortunately. This should ensure that the following stylesheet processing instruction is honored by these new browser versions. For some more background you might want to visit the following bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=338621 -->
<?xml-stylesheet type="text/xsl" href="/WebObjects/SantaPreview.woa/Contents/WebServerResources/Root.xsl"?>
<wrapper xmlns="http://www.bbc.co.uk/ContentInterface/Content" xmlns:cont="http://www.bbc.co.uk/ContentInterface/Content" sceneId="T2a_INDEX" serviceName="DSat_T2">
    ....

Firebug shows that the Root.xsl file is being loaded, and the response headers for it include the line

Content-Type    text/xml

I've also tried it with application/xml as the content type, but it makes no difference :-(

The Web Developer Extension shows the correct generated source too, and if you save this and load the page in Firefox, it displays correctly.

The version of Firefox displaying the problem is 3.0.3

Any ideas what I might be doing wrong?

解决方案

Displaying just the text elements is the behavior you would get out of an empty XSL stylesheet.

To me, that suggests that something fishy is going on with your xpath expressions, and that the xsl:template/@match attributes do not match the source document.

You do not provide enough information to diagnose further, so this blind guess is all I can offer.

EDIT: It turned out the problem was that IE and Chrome silently accept a nodeset as argument to string-length, while FF3 does not. Note that the specification mandates an optional string argument and does not specify behavior with a nodeset argument.

这篇关于Firefox 3不适用我的xslt样式表,但是其他浏览器可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:53