JavaScript libraries and application/xhtml+xml

It's too bad to discover that a big amount of JavaScript libraries don't support application/xhtml+xml, that is, the natural content type for XHTML. They fail spectacularly, returning a neverending list of DOM errors, mainly due to the junk content inserted into strings. SyntaxHighlighter falls into this category. But why bother? Because we want something more than tag soup, don't we? Basically, there are two kind of problems when dealing with an XML-based content type:

  1. well-formed markup

    All the markup inserted through the innerHTML property must be well-formed. Otherwise, everything fails silently.

  2. characters and entities

    All characters must be mapped to their corresponding XML entities. You cannot insert junk content into a DOMString without seeing an error. Further, you must be aware of the encoding used on your pages and code accordingly.

jQuery and other libraries work well, though. That's because they were designed for returning standard content.

Leave a Reply

Note: Only a member of this blog may post a comment.