I haven’t been concentrating on CSS much lately. I’ve been immersed in the world of XSL and recovering from bad televison. I did come across a very confusing problem in XSL the other day and a co-worker was able to point me to the answer.
XSL allows you to take raw XML and convert it to HTML, PDF files, or maybe even paper airplanes that can fly for miles. However, this chunk of XML that I was working with had HTML in a field that I needed to insert into my new, shiny XHTML pages. Further, the HTML was wrapped in a CDATA comment. (CDATA comments allow you to insert code that isn’t pretty and not throw the validators for a looop. And this code wasn’t pretty!)
The resulting pages had unprocessed HTML tags, i.e. links and br tags. How was I going to take this chunk and turn it into happy, shiny people-friendly elements? I tried the standard tools but the CDATA wrapping was blocking my every effort.
Ned suggests using a set of attributes to force the XSL to convert the HTML tags into elements and then uses XPATH to select the text node of the XML element instead of the entire element. Therefore, we are skipping the CDATA statement, grabbing the text within it, and displaying it to the world.
Here’s the final snippet
<xsl:value-of disable-output-escaping="yes" select="braincells/caffeine_powered/text()"/>
Am I barking up the wrong tree?
Is my logic correct? I hope this is the logic behind this solution. If not, please leave a comment to set the record straight.