Editing it the Cheap Way: EditorMaker
July 19, 1999
Conceptually, EditorMaker from IBM's
alphaWorks
group is very similar to Xeena. Given an input DTD, it creates a
custom XML editor. However, rather than creating the editor
instance at runtime (like Xeena), EditorMaker uses a two pass
process. First, it reads the DTD and generates a set of Java
classes that implement the specific editor, and then it
compiles the Java code and produces a .jar (Java Archive) file.
In the second pass, you invoke java runtime with the new .jar
in your path and the name of the previously generated specific
editor class.
For example, to generate the Java classes for a DTD named
ORDER.dtd
(a sample provided by IBM),
the following .bat file should do the trick.
(Note that IBM's xml4j and BeanMaker are also required.)
set savedCLASSPATH=%CLASSPATH%
set XML4J=C:\XML\alphaWorks\xml4j-1-1-9\xml4j_1_1_9.jar
set MAKERS=..\beanmaker\beanmaker.jar;.\editormaker.jar
set CLASSPATH=%XML4J%;%MAKERS%;%CLASSPATH%
java EditorMaker ORDER.dtd
set CLASSPATH=%savedCLASSPATH%
This will create a sources directory (folder)
containing the source code for the specific
editor, an ORDER\editor directory containing
the class files, and a jar directory containing
ORDER.editor.jar.
For the second pass, we need to add the new .jar to our CLASSPATH
and point java at the Editor class that corresponds to the first
element in the DTD.
set savedCLASSPATH=%CLASSPATH%
set XML4J=C:\XML\alphaWorks\xml4j-1-1-9\xml4j_1_1_9.jar
set MAKERS=..\beanmaker\beanmaker.jar;.\editormaker.jar
set OURS=.\jar\ORDER.editor.jar
set CLASSPATH=%XML4J%;%OURS%;%MAKERS%;%CLASSPATH%
java order.editor.OrderEditor
set CLASSPATH=%savedCLASSPATH%
Unfortunately, it appears that EditorMaker works only with
JDK 1.1.6. I tried both JDK 1.1.7a and JDK 1.2.1 and was unable
to successfully compile the code generated using the
ORDER.dtd
example. The error (below) concerned StringTokenizer
which should be in java.util,
a package not imported in the generated code. Your results may
differ. Email me if you can get this example to work.
C:\XML\alphaWorks\editormaker>java EditorMaker ORDER.dtd
Compiling with: javac -d . sources\ORDER\editor\*.java
sources\ORDER\editor\OrderEditor.java:425:
Class ORDER.editor.StringTokenizer not found.
EditorMaker: compilation generated warning or error
EditorMaker: ORDER.editor.jar successfully generated in
editor directory
Here is ORDER.dtd:
<!ELEMENT Order (Customer,Manifest,Receipt)>
<!ELEMENT Customer EMPTY>
<!ATTLIST Customer ID CDATA #IMPLIED>
<!ELEMENT Manifest EMPTY>
<!ATTLIST Manifest MID NMTOKENS #IMPLIED>
<!ELEMENT Receipt EMPTY>
<!ATTLIST Receipt RID CDATA #IMPLIED>
Editing it the Cheap Way: Xeena
Doing It With XML, Part 2
Adding a Touch of Style: CSS
|