Plugin - access files bundled with plugin
Post here questions and problems related to oXygen frameworks/document types.
Plugin - access files bundled with plugin
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
-
- Site Admin
- Posts: 120
- Joined: Wed Dec 12, 2018 5:33 pm
Re: Plugin - access files bundled with plugin
Post by Cosmin Duna »
Hi Christian,
For obtaining the plugin directory you should get the instance of the class that extends "ro.sync.exml.plugin.Plugin" and from this instance, get the "PluginDescriptor" using the "getDescriptor" method. From this object you can find the plugin's directory using the "ro.sync.exml.plugin.PluginDescriptor.getBaseDir()" method.
For example:
Also, make sure that the "xsl" folder will be packed into the jar file of the add-on. For this you should add the following fileset element into the "assembly.xml" file:
Best regards,
Cosmin
For obtaining the plugin directory you should get the instance of the class that extends "ro.sync.exml.plugin.Plugin" and from this instance, get the "PluginDescriptor" using the "getDescriptor" method. From this object you can find the plugin's directory using the "ro.sync.exml.plugin.PluginDescriptor.getBaseDir()" method.
For example:
Code: Select all
File baseDir = CTEImportPlugin.getInstance().getDescriptor().getBaseDir();
File teiXsl = new File (baseDir, "xsl/tei.xsl");
Code: Select all
<fileSet>
<directory>xsl</directory>
<outputDirectory>xsl</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service