4

I'm trying to display SVG, using <object>, in Firefox.

If I load the index.xhtml locally, rather than through a HTTP server, the page loads correctly.

However, if I load through a HTTP server, Firefox displays nothing, but rather informs me a plugin is required.

I've spent about two hours looking for and trying different solutions, to no avail. I'm now extraordinarily annoyed and frustrated.

This is the page;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:svg="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink">
  <head>
    <title>Daily Agera Stats</title>
  </head>

  <body>
    <table cellpadding="4" style="margin-left:auto; margin-right:auto">
      <tr>
        <td><object data="clicks_with_data_per_day_all_sources.svg" type="image/svg+xml"></object></td>
        <td><object data="clicks_with_data_per_day_criteo_only.svg" type="image/svg+xml"></object></td>
        <td><object data="impressions_per_day_with_data.svg" type="image/svg+xml"></object></td>
        <td><object data="impressions_per_day_with_data_from_clickers.svg" type="image/svg+xml"></object></td>
      </tr>

      <tr>
        <td><object data="referrer_urls.svg" type="image/svg+xml"></object></td>
        <td><object data="conversions_per_day_with_data.svg" type="image/svg+xml"></object></td>
        <td><object data="conversions_per_day_with_data_from_clickers.svg" type="image/svg+xml"></object></td>
        <td></td>
      </tr>
    </table>
  </body>
</html>

Note that the WWW server (lighttpd) has been configured to serve .xhtml as "application/xhtml+xml".

Given the page works off-line, I'm guessing this is a MIME issue of some kind. The total absence of meaningful documentation or error messages or anything one might consider an intuitive solution is INCREDIBLY ANNOYING.

The SVG is generated by GnuPlot and is quite long. The head looks like this;

<?xml version="1.0" encoding="utf-8"  standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg 
 width="320" height="256" 
 viewBox="0 0 320 256"
 xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink"
>

<title>Gnuplot</title>
<desc>Produced by GNUPLOT 4.6 patchlevel 0 </desc>

Any help deeply appreciated.


My psychic debugging powers tell me that because you tagged this as C++ you're compiling C++ code. I also guess that you used slightly different options to compile libraries A and B, causing their name decoration and/or ABI to be incompatible, and thus the method(s) can't be found.

Have you considered just letting the linker apply all the shared objects to your application rather than using dlopen? Then you'd know straight away that there was a problem because the linker couldn't match the symbols.

Alternately perhaps Linux just doesn't like your circular library references: can you refactor your libraries to eliminate the circular dependency?

4

1 回答 1

3

我找到了答案。

尽管在 <object> 标记中指定了 MIME 类型,您还必须配置 HTTP 服务器以为 .svg 提供该 MIME 类型。

我当然几乎在一开始就看到了这一点,但我认为 - 哈!- 因为我实际上是在指定类型,所以浏览器会知道该怎么做。

如果浏览器忽略它,type 属性的意义何在?

于 2012-05-02T16:18:53.503 回答