Robin Berjon

For Whom The Belle Trolls

XML Bad Practices

Reusing the Useless

Robin Berjon - # -

At times it feels like the XML family of technologies is just that: one big family. And you wouldn't want to forget anyone when your baby language is born.

That feeling (and a general sense that reuse is good) leads people to want to reuse as many parts of the XML stack as possible when creating a new language. That is a good feeling, and certainly one that should be listened to carefully — there are indeed many good and useful technologies to reuse.

However not all of them fall in that basket. One such example is XLink. For certain, it sounds like a good idea that the links in any XML document should be understandable so that generic processors could spider the whole XML Web. But that only works if everyone plays, and furthermore the cost of using XLink has to be taken into account. First, a whole new namespace is needed. Second, the distinction between href and src requires a second attribute. And then there are issues with parts of XLink being useless for (or detrimental to) one's needs, which entails specifying that parts of it should be used but not others, or that on such and such element when one XLink attribute isn't present it defaults to something specific not in the XLink specification, etc.. At the end of the day you've added cost, and it's likely turned out to be more complex to specify the deltas (which largely nullifies the value of reuse anyway) than it would have been to start from scratch. When that happens, scrap it and don't be ashamed to invent your own wheel of the right size, colour, and curvature.

Originally I have nothing against XLink, but SVG used it and experience shows that it was a bad idea. It confused users, it pushed SVG into defaulting attributes in ways that aren't entirely kosher, and it introduced a dependency on a specification that few really understand. As it turns out, very few people use XLink. Core XML specification produced by the W3C such as XSLT or XML Schema don't use it even though they have linking elements. I don't believe that anyone implements much in the way of generic link processing.

Reuse of other languages should be done where needed, and when the cost does not exceed that of reinvention. The fuzzy feeling and friendly accolades one gets from reusing another technology should not be part of the balance.

This article is part of a series on XML Bad Practices.