Apr 02

Ugh…chalk this up to one of those relatively obscure problems where you’ve got this crazy idea (using XSLT to generate the HTML for a page based on an XML file) so you don’t have to code up a full blown server-side page that has to hand build the page (correction: you’ve got to hand build it).

Anyway, I wanted to pass HTML through from the XML element to the final output. Of course, as we’re in the uber-strict world of XML, that will either: a) cause issues or b) get escaped and output to the user as HTML. I had the latter.

Off I went to find a solution (the usual time sink that it was) and found a couple ideas:

1) CDATA the content and use the xml:output’s cdata-section-elements tag to have the template ignore it. Didn’t work.

2) Use the xml:value-of and xml:text elements’ disable-output-escaping. Worked for IE but failed miserably in FF3.

So, I bang my head on my keyboard as I’m prone to do and I then search for why FF hates me so when I do #2 above.

Turns out…it has something to do with the way FF processes the XML so they don’t support the attribute. Doh! But wait…what’s this just a few search results below the top? Switch xml:value-of to xml:copy-of and lo and behold that sucker starts outputting your element’s contents verbatim!

Ahhh…now I can go back the the tedious task of converting my basic form (not HTML) data into XML to use my newly minted solution!!!

kn

Bookmark and Share

Leave a Reply

All original content © 2008-2009, Ken Nakai. All others © by their respective owners.