Robin Berjon

XML Bad Practices

Inconsistency

Inconsistent naming

This is one of the simplest to get right and yet is often wrong as the result of things being specified on the fly and not revisited later. The typical example is SVG having circle, path, ellipse, etc. but rect instead of rectangle. It rarely has a serious impact, but it does make a language harder to learn.

Incoherent features

One thing that is difficult when introducing a new feature inside a language is to make sure that it works coherently with all the rest of the language's features. Such errors are often difficult to detect without extensive testing.

A good example is the different treatment applied to shapes and animations in SVG. The following will work and display a second rectangle inside the g.


  
    
  
  
    
    
  
]]>

But the following, while valid, will not cause the g element to be animated:


  
    
  
  
    
    
  
]]>

Instead the defs will be animated, which will do nothing. This sort of discrepancy confuses authors, many of whom will try the latter at some point. While extensive testing is often too costly to put into effect, one low-tech approach that can help is to have a matrix tabulating all the features against all the others, and for each one that is added to look at how they interact. This would have made it apparent that animations applied to use work (they can animate it), but use applied to animations doesn't. How to address this, if only by clearly documenting it, is then a matter that will depend on the situation.

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