Sign In/My Account | View Cart  
advertisement

Article:
 Escaped Markup Considered Harmful
Subject: We are pawns in this horrible game
Date: 2005-06-21 08:41:10
From: pgregg

To all the people demanding a workaround to escaping: There is nothing wrong with CDATA. It is extremely useful, as long as the XML parser considers it nothing more than syntactic shorthand for &-escaping. I don't believe this article was railing against XML writers who do escaping normally. It is calling out the XML vendors who support lazy XML authors who didn't even want to bother putting their garbage inside CDATA. Now XML application vendors have to support pre-emptive escaping. That leaves the rules around CDATA totally up in the air.


This creates huge problems, like the one I'm having right now. The XML parser on our test web server considers CDATA as simple escaping shorthand (correctly!). However, the XML parser on our new production server, for whatever reason, insists on escaping twice no matter what -- even when I set disable-output-escaping="yes". So even though I put <![CDATA[  ]]> in my XSLT file, it always gets rendered in the browser as   , not the simple two spaces that it ought to represent in HTML source. The only workaround I have now to do escaping is the longhand way: <xsl:text disable-output-escaping="yes">&nbsp;&nbsp;</xsl:text> . That's only 10 times as many characters. So basically because of excessively lazy XML app vendors who sympathized with excessively lazy XML authors, now I can't even use CDATA. They've ruined it for all of us.


There is no workaround -- you just have to keep doing what you're doing, and we all must hope that XML vendors withdraw from supporting this false laziness. See also http://carey.geek.nz/doc/xslt-cdata-escaping/ for additional commentary on what CDATA is really for.


Previous Message Previous Message   Next Message Next Message


Sponsored By: