Carlsbad Cubes Wolf Paulus

java

XML Schema for Swixml
By Wolf Paulus <wolf@wolfpaulus.com>

Posted Saturday, March 03rd, 2007

xsd Writing a Swixml declaration file is not that hard, if you know your javax.swing components. However, getting a little support from your XML-Editor or IDE certainly doesn't hurt.
Getting IntelliSense help sometimes doesn't require much more than pointing your editor to a DTD or XML Schema to pop-up element and attribute names as needed; or simply adding an xsi:schemaLocation attribute to the root element might do the trick.
Anyway, I've generated the XML-Schema for all built-in Swixml elements and attributes and made it available here: http://www.swixml.org/2007/swixml.xsd
It is complete, concerning elements and their attributes, and while the schema already has more than 2700 lines (which tells a story about the complexity of Swing), it does not include containment-rules, e.g. that you shouldn't add a button into a label, nor does it validate the attribute values other than booleans.

Here is how you would associate the XML Schema to an Swixml XML descriptor:



After that's done, some tool may make writing the descriptors somewhat easier. Oxygen XML Editor for instance has code competitions for elements and attributes:
IntelliSense in OxygenXML


IntelliSense in OxygenXML

With IntelliJ-IDEA on the other hand, even after registering the URI in System/Settings/Resources, I could only get completion for elements but not for the attributes to work:

IntelliSense in OxygenXML

Give it a try and let me know what you think and how we should improve the xsd. Again, the schema can be downloaded here: http://www.swixml.org/2007/swixml.xsd
The XML-Schema for Swixml is obviously generated using Java Reflection and the code will be made available in the upcoming Swixml 1.6. The cool thing about this is that you can generate your own XSD after you have registered all your own and 3rd party components. That way your Schema will allow you to use IntelliSense on your own elements just like it works on the built-in ones.



Disclosure: This blog is written and edited by me, it contains my words and my opinions only, and does not contain any content which might present a conflict of interest.
I am not compensated to provide opinion on products, services, websites and various other topics. This blog does not accept any form of cash advertising, sponsorship, or paid topic insertions. However, I will and do accept and keep free products, services, and other forms of compensation from companies and organizations. All advertising is in the form of advertisements generated by a third party ad network and identified as such.
I will only endorse products or services that I believe, based on my expertise, are worthy of such endorsement. Any product claim, statistic, quote or other representation about a product or service should be verified with the manufacturer or provider.

Published on: Saturday, March 03rd, 2007  •  Category: [java]

Article URL : http://wolfpaulus.com/journal/java/swixmlxsd.html