Whatfettlexsi:type is Evil


Using a sad old cliché I hereby declare the train wreck that is xsi:type should be considered harmful:

  1. 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".
  2. 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".
  3. 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.
  4. It encourages people to want to switch "types" on the fly. Yikes, that's a manifesto to Monkey Patch (via Sam)
  5. It's intrinsically insecure, consider eviltude such as <getTime xsi:type="FireNuclearMissiles">.
  6. 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 an integer or a string, I'd rather keep that choice under my Kimono. thank you very much!
  7. 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 bounce xsi:type="xs:anyURI". Yes really. I may cry.
  8. It doesn't help the versioning story. Sorry. It just doesn't.

So don't touch it. It's eviil!

Technorati Tags: , , ,