0

我有一个 XULRunner 应用程序。它大部分都在工作,但是我有一个问题。应用程序中有一些以 HTML 表单形式实现的报告。用户的选项之一是输出为 CSV 格式。在 Firefox 中,用户被要求保存文件或打开它(在 Excel 或其他中)。在 XULRunner 应用程序中,我得到一个弹出窗口,其中包含:

XML 解析错误:未定义实体
位置:chrome://mozapps/content/downloads/unknownContentType.xul
第 30 行,第 18 列:&intro.label;

这似乎与此处讨论的品牌有关:

我想我已经按照说明进行了。它们在某些地方有点模糊。这是我所拥有的:

chrome/chrome.manifest包含:

locale branding en-US chrome/locale/branding/
content branding chrome/branding/

chrome/branding/包含这些文件:about.png, icon48.png,icon64.png

chrome/locale/branding/brand.dtd包含:

<!ENTITY  brandShortName        "ArcaMax EC">
<!ENTITY  brandFullName         "ArcaMax EC">
<!ENTITY  vendorShortName       "ArcaMax">
<!ENTITY  trademarkInfo.part1   " ">

chrome/locale/branding/brand.properties包含:

brandShortName=EC4
brandFullName=ArcaMax EC4
vendorShortName=ArcaMax

homePageSingleStartMain=Firefox Start, a fast home page with built-in search
homePageImport=Import your home page from %S

homePageMigrationPageTitle=Home Page Selection
homePageMigrationDescription=Please select the home page you wish to use:

syncBrandShortName=Sync

chrome/locale/branding/unknownContentType.dtd包含:

<!ENTITY  intro.label                 "You have chosen to open">
<!ENTITY  from.label                  "from:">
<!ENTITY  actionQuestion.label        "What should &brandShortName; do with this file?">

<!ENTITY  openWith.label              "Open with">
<!ENTITY  openWith.accesskey          "o">
<!ENTITY  other.label                 "Other…">

<!ENTITY  saveFile.label              "Save File">
<!ENTITY  saveFile.accesskey          "s">

<!ENTITY  rememberChoice.label        "Do this automatically for files like this from now on.">
<!ENTITY  rememberChoice.accesskey    "a">

<!ENTITY  whichIsA.label              "which is a:">

<!ENTITY  chooseHandlerMac.label      "Choose…">
<!ENTITY  chooseHandlerMac.accesskey  "C">
<!ENTITY  chooseHandler.label         "Browse…">
<!ENTITY  chooseHandler.accesskey     "B">

<!ENTITY  unknownPromptText.label     "Would you like to save this file?">

添加chrome/locale/branding/unknownContentType.dtd是我的猜测。我在 firefox 源代码树中找到了该文件。

有任何想法吗?

4

1 回答 1

2

看起来您的猜测是正确的,并且问题与品牌有关。unknownContentType.xul加载三个语言环境文件:

<!DOCTYPE dialog [
  <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
  %brandDTD;
  <!ENTITY % uctDTD SYSTEM "chrome://mozapps/locale/downloads/unknownContentType.dtd" >
  %uctDTD;
  <!ENTITY % scDTD SYSTEM "chrome://mozapps/locale/downloads/settingsChange.dtd" >
  %scDTD;
]>

brand.dtd是唯一不属于 XULRunner 的,它必须由应用程序提供。但是,加载它显然会失败,并且还会阻止加载其他 DTD 文件(XULRunner 抱怨对话框中的第一个实体)。

Now you don't need to put unknownContentType.dtd into your extension, it is already part of XULRunner. Other than that you've done everything correctly. However, the paths in chrome.manifest should be relative to the manifest, not to the application root. So the path probably should be locale/branding/ rather than chrome/locale/branding/. You should open chrome://branding/locale/brand.dtd in your application to verify that it has been set up correctly.

The other common issue: DTD files have to be saved in UTF-8 format without a byte order mark (BOM). If your editor saves a BOM by default then you need to reconfigure it. XULRunner will consider files starting with a BOM invalid and ignore them.

于 2012-09-21T06:46:15.950 回答