Pro-tip: Outputting 'Invalid' XML with XSLT

17 May 2012

It's been quite a while since I've done any serious hardcore XSLT (not really since my work stopped using it as part of their platform), but I had a situation today where I was working with a Content Query Web Part in SharePoint and needed to update the itemstyles XML so it would conditionally wrap part of the output in an anchor tag. Of course, this involves trying to render a closing tag on its own, which is invalid XML, which causes the xslt processor to break down and cry. I'd done this before but forgotten how to do so until I came across this helpful blogpost reminding me to use CData, XML variables and disable-output-escaping. Pretty easy! Hope it helps you out :)

Tags: HTML, XML, XSLT

Add a Comment

No Comments