This table illustrates several products that are sold in random locations along with the various prices for each location. loc1 loc2 loc3 loc4 ------------------------- prod1 | 10.00 12.00 prod2 | 11.00 11.00 10.00 prod3 | 12.00 The XML for this table is: 10.00 12.00 11.00 11.00 10.00 12.00 I can apply a template on and would like to do so on , but how do I fill-in the location cells that do not have a value. I've used the algorithm listed below, but THERE HAS TO BE A BETTER WAY! (BTW, the alorithm below is an example of my procedural thinking.) Any ideas? template select="prod" value-of select="prod/@name" choose when select="loc[@name="loc1"] value-of "loc[@name="loc1]/price /when other   /other /choose choose when select="loc[@name="loc2"] value-of "loc[@name="loc2]/price /when other   /other /choose choose when select="loc[@name="loc3"] value-of "loc[@name="loc3]/price /when other   /other /choose choose when select="loc[@name="loc4"] value-of "loc[@name="loc4]/price /when other   /other /choose /template