Before reading this, and getting too alarmed, this blog of caution really only applies to those who use XSLT templates (either using the XSLT Mediator or traditional XSLT Component Templates). Although it may have a wider impact that I am not aware of.
I just upgraded a client implementation to 2011 SP1, and mysteriously some of my components were failing to publish. At first this seemed to be a template issue, but on further inspection it became apparent that components that had been made before the SP1 upgrade were fine, and those create or edited after the upgrade were failing.
In one of our XSLT Template Building Blocks, we essentially copy the XML of the Component in order to make all the data available to the presentation code. In addition to copying the nodes, we also add some additional attributes.
<image>
<image xlink:type="simple" xlink:href="tcm:0-114344" xlink:title="ross" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</image>
Gets transformed by our template to
<image Orientation="portrait" Photographer="- Not applicable" Illustrator="">
<caption>Some Caption</caption>
<image type="pub148w" height="148" width="60" src="tcm:417-117248" uri="tcm:417-117248" /
<image type="pubArticleFull" height="480" width="640" src="tcm:417-117248" uri="tcm:417-117248"/>
</image>
This was working perfectly from version 5.3 up until 2011 GA. However we discover that the XML of components saved using SDL Tridion 2011 had changed
GA XML
<image><image xlink:type="simple" xlink:href="tcm:0-114344" xlink:title="ross" xmlns:xlink="http://www.w3.org/1999/xlink" /></image>
SP1 XML
<image> <image xlink:type="simple" xlink:href="tcm:0-114344" xlink:title="ross" xmlns:xlink="http://www.w3.org/1999/xlink" /> </image>
The additional whitespace was being added to the image node by my XSLT template, and it was preventing me from adding the Orientation, Photographer and Illustrator attributes to the element (you can not add attributes with XSLT to a node after adding text, whitespace or nodes)
To get around this I have added <xsl:strip-space elements=”*”/> to the top of my XSLT which fixes our problem, but it does mean we now need to validate the output of all our templates to make sure we are not stripping out any whitespace that we actually need.
Lesson of the day: Never write an XSLT thinking whitespace is irrelevant.
You decide whether you think this is a bug or not, but in the meantime, I hope this post might help you debug any XML related woes you stumble upon after upgrading to SP1.