Plugin - access files bundled with plugin
Posted: Tue Nov 15, 2022 1:39 am
Hi!
I'm writing a plugin for importing files from classical text editor to (TEI-) XML. In the plugin, I'd like to access an XSLT stylesheet bundled in the plugin. It is in the plugins folder xsl/tei.xsl.
I'd like to pass this stylesheet to a Saxon transformer the plugin instantiates. But I don't know how to get the file path from my java extension class. Here is what I've tried:
The xsl variable points to /opt/oxygenxml/Oxygen%20XML%20Editor%2024/lib/xsl/tei.xsl, but I would expect it to be /opt/oxygenxml/Oxygen%20XML%20Editor%2024/plugins/oxygen-cte-importer/xsl/tei.xsl , as I have installed the plugin directory oxygen-cte-importer by sym-linking it to OXYGEN_INSTALL_DIR/plugin.
How can I access the stylesheet?
Kind regards,
Christian
I'm writing a plugin for importing files from classical text editor to (TEI-) XML. In the plugin, I'd like to access an XSLT stylesheet bundled in the plugin. It is in the plugins folder xsl/tei.xsl.
I'd like to pass this stylesheet to a Saxon transformer the plugin instantiates. But I don't know how to get the file path from my java extension class. Here is what I've tried:
Code: Select all
...
import java.nio.file.Paths;
...
public class CTEImportPluginExtension implements WorkspaceAccessPluginExtension {
public static String getExtensionRoot() {
// get the URL of the jar file
File jarFile = new File(WorkspaceAccessPluginExtension.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String path = jarFile.getParent();
return path;
}
private static String xsl = Paths.get(getExtensionRoot(), "xsl", "tei.xsl").toString();
...
}
The xsl variable points to /opt/oxygenxml/Oxygen%20XML%20Editor%2024/lib/xsl/tei.xsl, but I would expect it to be /opt/oxygenxml/Oxygen%20XML%20Editor%2024/plugins/oxygen-cte-importer/xsl/tei.xsl , as I have installed the plugin directory oxygen-cte-importer by sym-linking it to OXYGEN_INSTALL_DIR/plugin.
How can I access the stylesheet?
Kind regards,
Christian