Using a sad old cliché I hereby declare the train wreck that is xsi:type should be considered harmful:
- First of all it assumes the receiver has a W3C XML Schema. Wrong! Schemas are just one of a number of different ways I might have used to describe the XML. You might be using a description I gave you in RelaxNG, on the back of an envelope, whatever. You might have constructed your own model. I don't care so long as you send me the right elements, attributes and content. You know, the right "stuff".
- Sticking the Schema abstract type into a message is at best verbose, worst expects me to understand how you're thinking about the data. I don't care. Really. Just send me the "stuff".
- Whilst Schema is wishy-washy about things such as where a schema is located, here we don't have a hint. No, it's an assertion. You will obey
xsi:type
. - It encourages people to want to switch "types" on the fly. Yikes, that's a manifesto to Monkey Patch (via Sam)
- It's intrinsically insecure, consider eviltude such as
<getTime xsi:type="FireNuclearMissiles">
. - Dynamic languages don't need it, OK, maybe it's useful when a repeated list has only one item, but otherwise Duck Typing is what I like and if I want to process my
accountNo
as aninteger
or astring
, I'd rather keep that choice under my Kimono. thank you very much! - It doesn't work with many existing static language tools, for example a number of JAXB2 implementations take an
xs:anyURI
, generate a Java string, but then bouncexsi:type="xs:anyURI"
. Yes really. I may cry. - It doesn't help the versioning story. Sorry. It just doesn't.
So don't touch it. It's eviil!
Technorati Tags: databinding, Schema, w3c, XML