XMidi Changes for Version 1.4
Changes in the last version (1.2) can be found
The changes for version 1.4 are these:
The DOM approach to parsing has been replaced by SAX.
This makes the program faster, and capable of handling
No more "plug-in" parsers. The early version
was written before javax.xml.parsers was a part of the
JDK and I wanted to be sure that my code was not tied
to any one parser. I think I handled that particular
problem very well.
However, now the javax.xml.parsers is part of the JDK,
I see no reason not to use it. Particularly,
when it allows for at least two kinds of plug-ins.
Since the structure of the XMidi files corresponds
very closely with the structure of MIDI files,
I was able to use the "state" pattern
to handle tags in XM and MIDI events in MX.
The base class for all the tag classes is Tag
and there is a subclass for each different
element in the DTD.
These classes have methods which are invoked
from XM in the SAX methods (startElement, endElement,
and characters) and they have methods which are invoked
from the appropriate places in MX (createStartXML and
There is a State class, which is little more than a
collection of variables to be passed around to
This allows objects and methods to interact using the
variables they were expecting.
The old version of MX created a DOM tree as it was
reading the input, then traversed the tree and
wrote the output.
This has been replaced by writing the output
as the input is being read using the createStartXML
and createEndXML methods of the various Tag subclasses.
This is faster and allows larger files to be handled.
The prior version was not "thread safe".
This one is.
This has been accomplished by removing static (class)
variables (except for constants).