0

我正在开发我的第一个 Eclipse 插件。除其他外,该插件使用以下代码执行 XSLT 转换:

Bundle bundle = Activator.getDefault().getBundle();
IPath smrlSsPath = new Path("/addins/smrl/smrl4odf2shore.xslt");
URL smrlSsUrl = FileLocator.find(bundle, smrlSsPath, Collections.EMPTY_MAP);
File smrlStylesheet = new File(FileLocator.toFileURL(smrlSsUrl).toURI());
xsltSource = new StreamSource(smrlStylesheet);
transFact = TransformerFactory.newInstance();
trans = transFact.newTransformer(xsltSource);
trans.setParameter("smrl.file", smrlFile.getAbsolutePath());
trans.transform(xmlSource, new StreamResult(outputTempFile));

文件 smrl4odf2shore.xslt 包括其他 XSLT 文件:

<xsl:include href="odf2shore.xslt"/>

这在开发过程中工作正常。不幸的是,当我导出插件并将其部署在 Eclipse 实例中时,会出现错误:

ERROR:  'C:\Programy\eclipse\configuration\org.eclipse.osgi\bundles\837\1\.cp\addins\smrl\odf2shore.xslt (The system cannot find the file specified)'
FATAL ERROR:  'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet

我检查了错误指定的路径,发现只有文件:smrl4odf2shore.xslt。样式表 (odf2shore.xslt) 中包含的文件不存在。我已经在 /plugins/ 目录中检查了我的插件的 JAR 并且两个文件都在那里,所以似乎该文件仅从 /bundles/ 目录中丢失(eclipse 仅移动了代码中提到的文件,而不是样式表中的文件)。

你能告诉我我应该怎么做才能让 eclipse 将所有文件从 JAR 移动到 /boundles/ 目录?

4

0 回答 0