Process (and Change) the XML before the XSLT stylesheet is applied to it. (i.e. Gives you the choice of doing things in Java using JDOM or your favourite XML parsing tool , or using XSLT if you prefer!)