【问题标题】:How to use xml entity reference in eclipse如何在eclipse中使用xml实体引用
【发布时间】:2013-03-15 21:00:36
【问题描述】:

我正在尝试在 Eclipse Indigo 的工作区中使用 XML 实体引用,但无法按预期引用 xml 文件。我正在使用以下语法:

<?xml version="1.0"?>
<!DOCTYPE doc 
[
 <!ENTITY planName SYSTEM "/planName.xml">
 <!-- planName.xml is in the same folder as the current xml i.e. C:\Users\Workspaces\projectA -->
]>

  <commands>    
    <name>&planName;</name> 
  </commands>

当我尝试使用此文件时,我收到以下错误:

  java.io.FileNotFoundException: C:\Users\Desktop\Softwares\IndigoEclipse\planName.xml (The system cannot find the file specified)

另一方面,如果我给出 xml 文件的绝对路径,我可以按预期使用该文件

<?xml version="1.0"?>
<!DOCTYPE doc 
[
 <!ENTITY planName SYSTEM "C:\Users\Workspaces\projectA\planName.xml">
 <!-- absolute path of workspace executes normally -->
]>

  <commands>    
    <name>&planName;</name> 
  </commands>

我可以在不给出 Eclipse 中的绝对路径的情况下引用一个实体吗?

【问题讨论】:

  • 重要的是 Java 代码,而不是你用来编写它的 IDE。
  • 谢谢 JB。我验证了代码,但我不确定 IDE 中是否有任何安全设置需要调整才能修复此问题

标签: xml eclipse entity


【解决方案1】:

尝试从SYSTEM "/planName.xml" 中删除斜线。

例子:

<!DOCTYPE doc [
<!ENTITY planName SYSTEM "planName.xml">
<!-- planName.xml is in the same folder as the current xml i.e. C:\Users\Workspaces\projectA -->
]>
<commands>    
  <name>&planName;</name> 
</commands>

【讨论】:

  • 谢谢丹尼尔,但这也无济于事。事实上,我已经尝试了许多地址的变体,但它总是将根文件夹作为我提到的 eclipse 安装路径。
猜你喜欢
  • 2011-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-24
  • 1970-01-01
  • 2012-10-02
相关资源
最近更新 更多