2013-03-15 60 views
0

我想在Eclipse Indigo的工作區中使用XML實體引用,並且無法按預期方式引用xml文件。我使用的語法如下:如何在eclipse中使用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

重要的是Java代碼,而不是你用來寫它的IDE。 – 2013-03-15 21:04:35

+0

謝謝JB。我驗證了代碼,但是我不確定是否需要調整IDE中的任何安全設置以便修復此問題 – hbabbar 2013-03-15 21:08:04

回答

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> 
+0

感謝Daniel,但這也無濟於事。 實際上,我已經嘗試了許多地址變體,但它總是將根文件夾作爲eclipse安裝路徑,正如我所提到的。 – hbabbar 2013-03-17 18:56:06

相關問題