XHTML and ‘

It took me about 2 hours to work this one out, but it I ended up getting there at the end.

I had ‘'’ in comments on this blog, and they were written as ‘'’ in the source, yet they didn’t want to come up as apostraphes.

So I’m scratching my head, and I’m thinking –

  1. ‘'’ is a valid XML element.
  2. XHTML is valid XML
  3. Hence – ‘'’ should display correctly.

That would all be well and good (according to my deductive reasoning) except for the fact that – ' IS NOT VALID HTML.

So – on that note, if you are displaying something on an HTML page – don’t use XMLFormat(), as it will escape your apostraphes into a very annoying ‘'’. Use HTMLEditFormat() instead.

That also being said, if you are pulling in text from XML feeds, you may wish to filter out the ‘'’ and replace them with real apostraphes, as quite obviously they won’t display correctly.

Just thought I would share this one.

You can see some more at: XHTML 1.0 – HTML Compatibility Guidelines

EDIT :::
I just discovered, that ' actually works as intended in Mozilla based browsers, however not in IE.  I’m not totally surprised mind you.  Just something else to factor into the mix.

Leave a Comment

Comments

  • ColdFusion programmer | January 7, 2009

    ' is actually not a valid *XML* escape sequence. Only 4 character escape sequences are both necessary and supported:
    & &
    < &lt;
    > &gt;
    " &quot;

    This means ColdFusion’s XMLFormat() is incorrectly changing ‘ to &apos;

  • ColdFusion programmer | January 7, 2009

    Ok, what I wrote above is wrong. &apos; is an XML entity and should be processed when an XML document is parsed.

    Refer to http://www.w3.org/TR/xml11/#sec-predefined-ent