SAX/C++ vs. SAX2

Vilya Harvey vilya at
Mon Dec 6 15:48:32 GMT 1999

Lars Marius Garshol wrote:
> * Vilya Harvey
> |
> | Just a thought: why not take a leaf out of the DOM's book and write
> | the canonical version of the SAX interfaces in a language-neutral
> | format like IDL?
> This may sound like a good idea, but it has its drawbacks in that one
> is immediately forced into a lowest common denominator design where it
> is impossible to make use of the features that really make each
> language what they are.

Ray Whitmer basically said what I wanted to say in his response to your
post (thanks Ray!) so I won't repeat that; just consider me in agreement
with the points he made. :-)

> Also, IDL does not have convenient ways of mapping to C++ streams,
> Java InputStream, Python dictionary-like objects and file-like objects
> etc etc

In theory though, you would simply define the functionality you required
from a stream (to use your example) in an interface then make use of the
appropriate "native" stream class in your implementation. That's not
terribly inconvenient, and it needn't be inefficient either in a
reasonable implementation.

> Another problem is that exceptions are first-class objects in SAX
> (which is exploited by the Java and Python mappings), but not in IDL.

The only problem I see is that IDL doesn't allow exceptions to have
inheritance. That would mean some slight changes to the API (although the
implementations could still inherit from one another), but nothing really
serious. Other than that, IDL only allows exceptions to declare member
data (no methods); I don't see that as a real limitation though, since I
have yet to see a *useful* example of an exception object with any methods
other than getters/setters (which IDL member data gets mapped to) and

> Nor are language naming conventions respected. (startElement should
> really be startElement (in Java), start_element (in C++, Python, IDL)
> and start-element (in Common Lisp/Scheme) and there may even be more
> variations.

Not everyone using a particular language follows the same naming
conventions anyway, so I really don't think that should be a factor. As an
aside, I disagree with you about the C++ name: I think it should be
startElement not start_element. :-) Also as an aside, I haven't seen any
IDL to Lisp or Scheme converters - does such a tool exist?

> As a general reference and statement of intent it might have some
> value, but I really think translation should be done by humans.

I agree with you about this.

> The main advantage feature of IDL, cross-process and cross-language
> interoperability, is not really all that valuable for SAX anyway.

I would argue that since SAX appears to be intended as a cross-language
API, the main advantage of IDL would be its language neutrality. It would
mean that the API would not be developed with the capabilities of one
particular language in mind, as has happened with SAX 1.0. Of course
whether or not that would be a real advantage is debatable but it would
help avoid situations such as we currently have, where several
incompatible C++ bindings have sprung up. Surely that's a good thing?

(Not speaking for my employer.)
Vilya Harvey  <vilya at>    Wilkinson House  Mob: +44  961 106 505
Computational Mathematics Group   Jordan Hill Road   Wk: +44 1865 511 245
NAG Limited                    Oxford  UK  OX2 8DR  Fax: +44 1865 311 205

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list