Sunday, December 5, 2010

Elements of XSD reusability

If you define a type in a XSD:



you can reuse this type definition in another XSD:



The key is the "xs:import" statement with the association to the same namespace as in the targetNamespace used for the myxsd1.xds.

What I really don't like in XSD is the habit of defining a type as an element:

xs:element ... xs:complexType

this is plain stupid since you cannot reuse this type definition.

I mean, once you have defined an element A as of complexType sequence bla,
you cannot define an element B saying "make it just like element A".

The only way to reuse it is by including an object of type A inside the object B using the "ref" construct:

xs:element name="PVElement3" ... xs:complexType ... xs:sequence... xs:element ref="PVElement2"

This is like going back a century in the art of programming.

I keep wondering what the Fathers of XML had smoked when they got together to define the Foundation of the Second Biggest Blunder of the Century - the First being HTML.

No comments: