我正在尝试在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中给出它的绝对路径吗?
答案 0 :(得分:0)
尝试从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>