Late-breaking news (2001-04-07) - Koala Object Markup Language (KOML) appears to do what this page advocates except for supporting custom filters based on a schema.
XML can be used as a data storage format or data transmission format (a.k.a. "wire format"), whether or not encapsulated in a formal RPC mechanism.
An XML format is specified without any strong bias toward ease of use with Java. Java code, like code in any language, has to work with this externally-imposed XML format using a parser.
Rather than forcing all languages to suffer equally with an externally-imposed XML format that must be parsed by hand, use an XML format that is automatically generated and parsed in at least one modern language (Java). Other languages can parse by hand or can implement a similar automatic mechanism.
(This proposal is quite different from XML-RPC.)
The XJSF format encodes Java class names as XML tags and provides for all Java primitive types à la XML-RPC. Java FilterInputStream
and FilterOutputStream
subclasses are provided so that these new XML languages are nearly as easy to use in Java as are the wire formats they represent. These 6 filters are provided:
XJSFInputFilter
XJSFOutputFilter
XRMIWPInputFilter
XRMIWPOutputFilter
XIIOPInputFilter
XIIOPOutputFilter
XJSFOutputStream
example:
Instead of this:
FileOutputStream out = new FileOutputStream("theTime");
ObjectOutputStream s = new ObjectOutputStream(out);
s.writeObject("Today");
s.writeObject(new Date());
s.flush();You do this:
FileOutputStream out = new FileOutputStream("theTime");
XJSFOutputFilter xjos = new XJSFOutputFilter(out);
ObjectOutputStream s = new ObjectOutputStream(xjos);
s.writeObject("Today");
s.writeObject(new Date());
s.flush();
You can write a pair of custom filters to make an externally-imposed XML format as painless as possible in Java. In the second example above, you would replace XJSFOutputFilter
with OurCustomOutputFilter
. Presumably such a filter would use something like the emerging XML Schema standard.
The point of the proposal here is that although that solution would be nice, the ultimate in transparency in Java is to be able to use a single, off-the-shelf pair of filters. Still, the custom filter approach has the attraction that it leverages the work that is already done for you by Java's serialization mechansm: the transient
keyword, the built-in methods for serialization, the marker interfaces, the version tagging of serialized data to prevent mismatches with incompatible code, etc.
The above approach suggests another tack. What if we treated JSF as a kind of binary XML? Instead of filtering it into XML so other languages like C++ can parse it, what if we implemented a DOM parser for JSF? A C++ programmer comfortable with XML can use this parser and not care whether the actual communication format is XJSF or JSF. The application can be easily changed to use the XML representation if needed. This approach saves the performance cost at both ends of filtering to-from human-readable form (XML). And if a programmer ever needs to look at the JSF data, they can simply use a tool that filters between XJSF and JSF to look at the data in XML format.