10

我正在尝试从 Web 服务器提供动态生成的 xml 页面,并从同一 Web 服务器提供自定义、静态、xslt,它将处理卸载到客户端 Web 浏览器中。

直到最近,我在 Firefox 2、3、IE5、6 和 Chrome 中都能正常工作。不过,最近发生了一些变化,Firefox 3 现在只显示源代码中的文本元素。

页面源代码是这样开始的:

<?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 显示正在加载 Root.xsl 文件,并且它的响应标头包括该行

Content-Type    text/xml

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

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

显示问题的 Firefox 版本是 3.0.3

有什么想法我可能做错了吗?

4

5 回答 5

6

只显示文本元素是您从空的 XSL 样式表中得到的行为。

对我来说,这表明您的 xpath 表达式有问题,并且 xsl:template/@match 属性与源文档不匹配。

您没有提供足够的信息来进一步诊断,所以我只能提供这种盲目的猜测。

编辑:原来的问题是 IE 和 Chrome 默默地接受一个节点集作为string-length的参数,而 FF3 没有。请注意,规范要求使用可选的字符串参数,并且没有指定节点集参数的行为。

于 2008-10-23T21:03:28.443 回答
4

如果您使用的是 NoScript,这也会禁用 XSL 样式表,直到您Allow <site>.

于 2013-04-24T12:02:02.037 回答
3

根据后续调查回答我自己的问题。ddaa引导我朝着正确的方向前进。

Firefox 似乎对 xslt 转换非常挑剔。仔细检查您的 xslt 以确保它没有被 IE 和 Chrome 屏蔽的错误。

XML Spy 是一个不错的产品,虽然并不便宜,但它会突出 xslt 中的一系列错误。它似乎至少解决了与 Firefox 渲染器一样多的问题。

不幸的是,您似乎不能依靠 Web Developer 扩展来解决问题。

于 2008-10-24T08:48:21.890 回答
3

我只是为了后代而写在这里-我有同样的症状,也有 Firefox 3。但是在我的情况下,问题是另一个:

Firefox 似乎真的非常不喜欢 XSL 文件_的名称中包含下划线。我的 XSLT 文件被称为my_super_nice_xslt_which_loads_in_opera_and_ie.xsl.

所以,人们,我们不要使用下划线。请改用连字符(减号): my-super-nice-xslt-which-loads-in-opera-and-ie.xsl.

然后它也将加载到 Firefox 中。我想从现在开始,我将只使用带有字母和数字的简单名称。你知道这句话,“一次被咬,两次害羞”。(就我而言,我被咬了两次,但忘记了第一次,所以这一次让我害羞了四倍。)

于 2010-10-13T15:48:03.433 回答
0

尝试将其作为 application/xml 而不是 text/xml

于 2008-10-21T23:59:14.610 回答