How to write a plugin
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 4
- Joined: Fri Jul 02, 2004 9:47 am
How to write a plugin
Hi,
I'm using the standalone version of oxygen 4 under linux and tried to write a simple Plugin (called HtmlToXsl). (No Eclipse, no oxygen eclipse-plugin).
I got the documentation from this site (pdf) and created the structure as told:
oxygen/plugins/HtmlToXsl, copied and changed the plugin.xml from the Comment-Plugin, created lib and lib/htmltoxsl and 2 Java-Files in there:
1 for the HtmlToXslPlugin and for the HtmlToXslPluginExtension.
I used the code from the comment plugin out of the documentations and added a simple
import ro.sync.exml.plugin.*; to HtmlToXslPlugin.java, and
import ro.sync.exml.plugin.selection.*; to HtmlToXslPluginExtension.java.
So far: I'm able to compile it (with -classpath /opt/oxygen/lib/oxygen.jar) and get the class-files - no errors, no warnings - and created the jar.
When I start Oxygen I get the message:
java.lang.NoClassDefFoundError
/opt/oxygen/plugins/HtmlToXsl - htmltoxsl/HtmlToXslPluginExtension (wrong name: HtmlToXslPluginExtension)
There are no mis-spells (upper-lower-case), I checked it several times and even copied the text out of the text-console from the path.
Any ideas? BTW: Java is not my favorite language; call me a beginner in java.
Are there any code templates for creating SelectionPlugins (maybe I forgot something in my java-files).
Greetings
Kassi
I'm using the standalone version of oxygen 4 under linux and tried to write a simple Plugin (called HtmlToXsl). (No Eclipse, no oxygen eclipse-plugin).
I got the documentation from this site (pdf) and created the structure as told:
oxygen/plugins/HtmlToXsl, copied and changed the plugin.xml from the Comment-Plugin, created lib and lib/htmltoxsl and 2 Java-Files in there:
1 for the HtmlToXslPlugin and for the HtmlToXslPluginExtension.
I used the code from the comment plugin out of the documentations and added a simple
import ro.sync.exml.plugin.*; to HtmlToXslPlugin.java, and
import ro.sync.exml.plugin.selection.*; to HtmlToXslPluginExtension.java.
So far: I'm able to compile it (with -classpath /opt/oxygen/lib/oxygen.jar) and get the class-files - no errors, no warnings - and created the jar.
When I start Oxygen I get the message:
java.lang.NoClassDefFoundError
/opt/oxygen/plugins/HtmlToXsl - htmltoxsl/HtmlToXslPluginExtension (wrong name: HtmlToXslPluginExtension)
There are no mis-spells (upper-lower-case), I checked it several times and even copied the text out of the text-console from the path.
Any ideas? BTW: Java is not my favorite language; call me a beginner in java.
Are there any code templates for creating SelectionPlugins (maybe I forgot something in my java-files).
Greetings
Kassi
-
- Posts: 63
- Joined: Fri Dec 12, 2003 6:34 pm
- Contact:
Post by iulian_velea »
Hi,
If you are sure that there are no mistakes in the filename that contains the compiled class (lower case letters instead of upper case etc.), then look at the directory structure where your classes are found. This structure must reflect the java package structure, and when you build your jar you must build it including this complete directory structure.
Example:
From your post i can see that you changed the package declaration to "htmltoxsl". If you try to build your jar file from the two classes you reffer to then they must be located in the directory "htmltoxsl/", and the command line for creating jar can be for example:
If you use instead the command:
then you will get the exception java.lang.NoClassDefFoundError because the classes in the jar are not located in the package indicated by the package declaration.
For more options and parameters you can look at the jar command help.
Also you must write the plugin.xml file correctly, as described in the pdf document with the plugin extensions documentation.
For a test you can try the plugin example provided with the documentation, create a jar and run Oxygen with it. Then if you succed try your plugin in the same manner.
You could also send us your code and/or jar to test.
Best regards,
Iulian.
If you are sure that there are no mistakes in the filename that contains the compiled class (lower case letters instead of upper case etc.), then look at the directory structure where your classes are found. This structure must reflect the java package structure, and when you build your jar you must build it including this complete directory structure.
Example:
From your post i can see that you changed the package declaration to "htmltoxsl". If you try to build your jar file from the two classes you reffer to then they must be located in the directory "htmltoxsl/", and the command line for creating jar can be for example:
The last parameter represents the directory where the two classes are found. This command creates the jar file with complete directory structure.C:\jdk1.4.2\bin>jar cvf htmltoxsl.jar htmltoxsl
If you use instead the command:
C:\jdk1.4.2\bin>jar cvf htmltoxsl.jar HtmlToXslPlugin.class HtmlToXslPluginExtension.class
then you will get the exception java.lang.NoClassDefFoundError because the classes in the jar are not located in the package indicated by the package declaration.
For more options and parameters you can look at the jar command help.
Also you must write the plugin.xml file correctly, as described in the pdf document with the plugin extensions documentation.
For a test you can try the plugin example provided with the documentation, create a jar and run Oxygen with it. Then if you succed try your plugin in the same manner.
You could also send us your code and/or jar to test.
Best regards,
Iulian.
-
- Posts: 4
- Joined: Fri Jul 02, 2004 9:47 am
Ok, after a very long time (no time left to spend), and after getting more information about java programming, I got it working.
In the documentation / example-plugin there was no
After inserting.. everything worked fine.
In the documentation / example-plugin there was no
Code: Select all
package <pluginname>;
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