About Me

My photo
Web person at the Imperial War Museum, just completed PhD about digital sustainability in museums (the original motivation for this blog was as my research diary). Posting occasionally, and usually museum tech stuff but prone to stray. I welcome comments if you want to take anything further. These are my opinions and should not be attributed to my employer or anyone else (unless they thought of them too). Twitter: @jottevanger

Wednesday, February 04, 2009

Being for the benefit of Mr Shite

...like me. This is just a post for the poor .Net coder out there in some remote corner of the world who, like me, will find themselves wondering why the hell their XSL transformations using disable-output-escaping are ending up with their output being escaped. For me this meant invalid KML, where hte CDATA sections I needed weren't being output correctly. I knew the transformation worked just by putting the XML and XSL together, but my cheapo web service did the transformation via C# and was screwing it up.

So if you're that coder of modest capacity like myself, here's where I got my clues:

  • This thread told me that the XmlTextWriter which is part of my Transform class would be ignoring "disable-output-escaping", and that I should write to a stream instead.
  • Never having actually done much with streams, I found these utility methods perfect for cut-n-paste MemoryStream-to-string conversion

Job done.

If you happen to be wondering how you can output a CDATA section in your XSLT, I wanted to put that in here too but unsurprisingly Blogger doesn't like that code. I'll see if I can find a way around that. Google "disable-output-escaping CDATA", that should get you somewhere!

No comments: