tobyandlauren.id.au

BLOG PROJECTS FAMILY TREE
Subscribe by RSS feed

Safari doesn’t display valid XSLT and XML!!

Actually, it’s not Safari’s fault. This has happened to me, and has sat in the too-hard basket for a few weeks, but finally I decided to fix the problem. It’s actually really easy.

The problem:

  • You have an XML file, a custom DTD, and an XSLT-transform document.
  • The W3C Validator has given it all the green tick.
  • It works perfectly in Firefox.
  • But when you try to load it in Safari, you get a blank page and no errors.

Weird, innit? I spent a while trying to discover why Safari had a bug. Turned out it wasn’t Safari, it was my DTD, but W3 and Firefox happily parsed it with no warnings at all.My simple mistake was that I had put <!ELEMENT elementtag(children)> instead of <!ELEMENT elementtag (children)>

Note the space between elementtag and (children)! W3 had no qualms validating this, but I only picked it up thanks to Validome’s validator.

I put the space in where the space should be, and hey presto, now Safari is happily transforming XML as it should be.