Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] XSWT Schema

> For XSWT which now uses the specific XML format, whenever a 
> person adds a third-party component, how is the additional 
> XML element type supported, or added to the XSWT schema?

XSWT is defined entirely in terms of reflection.  So the new XML elements
are automatically supported whenever new classes are added to the classpath.
If a schema is also desired/needed, given that all of XSWT has a 1:1 mapping
to the underlying Java, it should be possible to write a program to
automatically generate the XML schema from a list of SWT and Java classes.

This would definitely be a cool thing to add.  It just hasn't been a high
priority because none of the open source Eclipse XML editors support XML
schemas yet, so none of us have needed a schema yet.

> I was reading the XSWT Requirements document, and came across 
> the argument between the generic XML format, and the more 
> specific XML format which uses XML elements specific to 
> Sweet/SWT components.  The generic XML format allows a person 
> to add a new component type without changes to the schema. 

Actually, when I first saw XSWT, I had the same reaction: The schema should
be constant!  But as I worked with the format, I realized that making a
generic schema would have an enormous cost in human readability/writability.

The current XSWT format is roughly 33% more compact than the Java code to
describe the exact same layout.  (This number is based on measurements of
real code from Eclipse itself as well as from my own work.)  Also, the XML
hierarchy explicitly describes the SWT containership hierarchy but you have
to follow the logic of the Java code to deduce this with a Java
implementation, so XSWT is significantly more readable than the equivalent
Java code.  For anyone who prefers the human and machine-readable format to
be the same, this is a significant advantage.

On the other hand, Using a generic schema would both increase the length of
the XML file as compared to the equivalent Java code and reduce the
readability of the XML file.  The effect would be to negate a significant
part of the advantage XSWT currently enjoys over hand-written Java.

Consequently, since a schema can be generated mechanically by Java
reflection, it seems that there is little or no advantage to be gained by
moving to a design that uses a fixed XML schema; at the same time there
would be a significant cost associated with the same.


Regards,

Dave


Back to the top