我正在开发我的第一个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 /目录,我该怎么做?