Extend the Java Functionality of an Existing Framework (Document Type)
Use Case
You want to change the way a DocBook 4 <xref>
displays in Author mode based on what element is at the
@linkend
.
Solution
Follow these steps:
-
Create a Maven Java project and add a dependency on the Oxygen XML Editor classes:
<dependency> <groupId>com.oxygenxml</groupId> <artifactId>oxygen-sdk</artifactId> <version>${oxygen.version}</version> </dependency>
where
${oxygen.version}
is the version of Oxygen XML Editor.Alternatively, if the project does not use Maven, all the transitive dependencies of the above Maven artifact need to be added to the classpath of the project.
- Also add the [OXYGEN_INSTALL_DIR]\frameworks\docbook\docbook.jar to the class path of the project.
- Create a class that extends ro.sync.ecss.extensions.docbook.DocBook4ExtensionsBundle and overwrites the method: ro.sync.ecss.extensions.api.ExtensionsBundle#createLinkTextResolver().
- For your custom resolver implementation you can start from the Java sources of the ro.sync.ecss.extensions.docbook.link.DocbookLinkTextResolver (the Java code for the entire DocBook customization is present in a subfolder in the Oxygen SDK).
- Pack your extension classes in a JAR file. Copy the JAR to: [OXYGEN_INSTALL_DIR]\frameworks\docbook\custom.jar.
- Start Oxygen XML Editor.
- Open the Preferences dialog box and go to Document Type Association. Edit the DocBook 4 document type. In the Classpath list add the path to the new JAR. In the extensions list select your custom extension instead of the regular DocBook one.
- You can rename the document type and the docbook framework folder to something else (such as custom_docbook) and share it with others. A document type can also be installed using the add-on support.