0

XML > XSLT > XHTML > Oops

I meant to blog this earlier, but forgot about it until I read Dave Schuck's post about XML issues he's run into with respect to configuration files. My troubles had nothing to do with his except that they involved XML and an end tag; nonetheless, it reminded me to get this out there.

I was seeing what I could do with XSLT as means of allowing users to more easily customize the presentation of data in an application and was putting together some sample transformations. Since I wanted the transformations to output valid XHTML it seemed like a good idea to set the XSLT to produce its output in XML format rather than HTML using . That way, the transformation itself would be responsible for ensuring that the output was well-formed and if I made a mistake of that nature in my markup it would be adjusted before the browser ever saw it.

Turns out it was one of those good ideas that doesn't survive the implementation phase. A few of these transformations produced form controls and at least one of those form controls was a textarea. See where I'm going with this? In my XSLT, I drew up the textarea as <textarea ...></textarea>. My XSLT, though, had a better idea. When rendering the output, my carefully crafted textarea code became <textarea ... /> because it had no value. Oops. Browsers don't like that syntax much. The textarea either disappeared all together or was rendered with the remainder of the source code as its value.

In hindsight it may have been a stupid idea, but since that result was completely unexpected to me, it took me longer than it should have to track it down. Maybe someone else can benefit from my good intentions...


Search

Rob  Wilkerson