Part I. Extending XMLmind XML Editor

XXE has many extension points. They can be categorized by the way you'll register them with XXE:

Extensions declared in .xxe configuration files by the means of configuration elements

A .xxe configuration file customizes the behavior of XXE for a given type of document. Such configuration files contain many different kinds of descriptors. For example, a binding configuration element in XMLmind XML Editor - Configuration and Deployment specifies which command to invoke when a certain combination of keys is pressed by the user. The command invoked by the binding element is itself specified using a command configuration element.

Custom commands are by far the most useful kind of XXE extension. However, there are several other kinds of extensions also declared in configuration files:

Validation hook

Performs semantic validation beyond what can be done using a DTD or schema alone. Declared by the validateHook configuration element.

Custom attribute editor

Custom dialog box extending the Attributes tool when a given attribute is being edited. Declared by the attributeEditor configuration element.

Inclusion scheme

Specifies how some contents found in document A can be included in document B. Declared by the inclusionScheme configuration element in XMLmind XML Editor - Configuration and Deployment. Writing an inclusion scheme in Java™ is a complex task. This task will not be described in this document.

Link type

A generalization of the ID/IDREF/IDREFS mechanism for use in modular documents. Declared by the linkType configuration element in XMLmind XML Editor - Configuration and Deployment. Writing a link type in Java™ is almost never needed, thanks to expressiveness of the linkType configuration element. This task will not described in this document.

Prior to learning how to write a custom command, you need to get familiarized with XMLmind XML Editor Document Object Model (DOM) and with its XPath API.

Extensions declared in CSS style sheets

A style sheet extension allows to overcome some of the limitations of CSS. Such extension is declared in a .css file by the means of the @extension proprietary CSS directive.

Extensions declared in customize.xxe_gui files

The GUI of XXE is not hardwired. It's possible to extend it, for example, add a custom pane below the Edit tool, by writing a custom part and declaring this part in a customize.xxe_gui file.

Self-registering extensions

Self-registering extensions are called plug-ins. There are three types of plug-ins: XSL-FO processor plug-in, image toolkit plug-in, virtual drive plug-in. The code of a plug-in is found in a .jar file defining a service. For example, the service definition file is META-INF/services/com.xmlmind.xmledit.imagetoolkit.ImageToolkit for an image toolkit plug-in. It's this service definition file which allows the plug-in to register itself with XXE.

All the above extensions are easier to deploy if you package them for XMLmind XML Editor integrated add-on manager (menu item OptionsInstall Add-ons). The last chapter of this part explains how to do this.

Table of Contents

2. Programming the Document Object Model
1. The sample program
2. Compiling and running the sample program
3. Names and Namespaces
4. Document nodes
5. Document traversal
6. Loading and saving a document
7. XML node properties
3. Using XPath
1. The two implementations of XPath contained in XMLmind XML Editor
2. Compiling and running the sample program
3. Compiling and evaluating an XPath expression
3.1. XNode
3.2. Two steps: parse and evaluate
3.3. ExprContext
4. XPath value types
4.1. evalAsNumber
4.2. evalAsBoolean
4.3. evalAsNodeSet
4.4. evalAsVariant
5. Matching a node against an XPath pattern
4. Writing a command
1. Compiling and running the code sample
2. What is a command?
2.1. The CommandBase base class.
3. A sample command: ConvertCaseCmd
3.1. First step: prepare
3.2. Second step: execute
3.3. Reporting errors from commands
5. More commands
1. Highlighting text
1.1. Marks other than dot, mark, selected and selected2
1.2. Description of prepare
1.3. Step by step description of execute
2. A validating command
2.1. ElementEditor
2.2. Step by step description of prepare
2.3. Step by step description of execute
3. How to avoid writing a validating command
3.1. Delegating node insertion to the ubiquitous Paste command
3.2. Step by step description of prepare
3.3. Step by step description of execute
4. Recordable commands
6. Writing a validateHook
1. What is a validation hook?
2. Compiling and running the code sample
3. Implementing the ValidateHook interface
7. Writing a custom attribute editor
1. What is a custom attribute editor?
2. Compiling and running the code sample
3. A custom editor for the bgcolor attribute
8. Writing style sheet extensions
1. The problem
2. The solution
2.1. Solution of problem #1: invoke a custom method computing a CSS property value
2.1.1. The StyleSheetExtension class
2.1.2. The localize method
2.2. Solution of problem #2: implement a StyleSpecs which knows how to style nested emphasis elements
2.2.1. The implementation of interface StyleSpecs
2.3. Solution of problem #3: invoke a custom method computing the number of a listitem and use a BasicElementObserver to update orderedlists when needed to
2.3.1. Interface BasicElementObserver
2.3.2. The implementation of interface BasicElementObserver
2.4. Solution of problem #4: implement an AttributeValueEditor
2.4.1. Passive custom views
2.4.2. Active custom views: specialized editors embedded in the DocumentView
3. Compiling and testing the sample style sheet extensions
9. Extending the GUI of XMLmind XML Editor
1. A framework for creating XML editors
2. High-level building blocks
3. Compiling and running the code sample
4. A custom About dialog box
5. A custom tool which counts the words found in the active document
5.1. How to count words in an XML document?
5.2. Best strategy
5.3. The word counter tool
6. A custom preferences sheet which parametrizes the word counter
10. Writing a plug-in
1. What is a plug-in?
2. Steps needed to write, package and deploy a plug-in
11. Packaging an add-on for XMLmind XML Editor integrated add-on manager
1. Why packaging add-ons?
2. Creating useful add-on descriptors