代码之家  ›  专栏  ›  技术社区  ›  Bill Michell

Firefox3不应用我的xslt样式表,但其他浏览器会应用

  •  10
  • Bill Michell  · 技术社区  · 17 年前

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

    直到最近,我在Firefox2、3、IE5、6和Chrome中都能很好地实现这一点。不过,最近有些变化,Firefox3现在只显示源代码中的文本元素。

    页面源的启动方式如下:

    <?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作为内容类型,但没有区别:-(

    WebDeveloper扩展也显示了正确生成的源代码,如果保存此代码并在Firefox中加载页面,它将正确显示。

    显示问题的Firefox版本是3.0.3

    5 回复  |  直到 17 年前
        1
  •  6
  •   ddaa    17 年前

    仅显示文本元素是从空XSL样式表中获得的行为。

    对我来说,这表明您的xpath表达式有可疑之处,xsl:template/@match属性与源文档不匹配。

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

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

        2
  •  4
  •   Thomas Leonard    13 年前

    如果您使用的是NoScript,那么在您 Allow <site> .

        3
  •  3
  •   Bill Michell    9 年前

    根据随后的调查回答我自己的问题。 ddaa

    Firefox似乎对xslt转换非常挑剔。仔细检查xslt,确保它没有IE和Chrome掩盖的错误。

    不幸的是,您似乎不能依靠Web开发人员扩展来解决这个问题。

        4
  •  3
  •   Prof. Falken    15 年前

    我的 在这种情况下,问题是另一个:

    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 .

    (就我而言,我被咬了两次,但第一次忘了,所以这次我有四次害羞。)

        5
  •  0
  •   ThePants    17 年前