Saturday, February 11, 2012

Some validation weirdness with Office Core

This one had me stumped for a bit.  I'm putting together some walkthroughs with Office Core on Sitecore 6.4.1 build 5, and whenever I tried to publish, I would get stopped in my tracks by the following validation error:

Looking at the page source shows that there is an unclosed link element.
<link href="/css/blue.css" rel="stylesheet"><script type="text/javascript" src="/starterkit.js"></script>
This is getting generated by the the Starter Kit file "Html head include.xslt", which has the link element properly closed:
  <link href="/css/{sc:fld('css file',$theme)}" rel="stylesheet"/>

What's Doing?

It turns out the culprit is the output directive:

<xsl:output method="html" indent="no" encoding="UTF-8" />

It seems that XSLT has the dubious feature of breaking perfectly closed elements if the output is set to html. So the fix is to change the xsl:output element to "xml", or to remove the xsl:output directive altogether, since "xml" is the default if there is no "html" element in the output.

A few links

Thanks to this thread for leading me out of the wilderness.   W3 schools also documents the xsl:output element, but doesn't mention this gotcha   Finally, this post has a recommended way of enforcing conformant XHTML.

The Starter Kit is no longer on SDN, so Sitecore probably knows about these issues. Though since Office Core is baked into much of their documentation, they should probably get it working.


Changing the xsl:output revealed a torrent of additional XHTML validation errors, so I ended up shutting this off in my sample site, by adding Standard Values to the "/sitecore/templates/Office Core/Meta Data" template and adding the XHTML validator GUID to the "Suppressed Validation Rules" field. This shuts off the rule for all Office Core items.

No comments:

Post a Comment