Dutch Webguidelines and XDV trickery

written on 2011-01-25

With Plone's new theming mechanism it is a breeze to conform to a strict doctype necessary for the Dutch Web-guidelines (Webrichtlijnen Overheid). This post is actually long overdue since I've done this at least half a year ago, but still, better late then never.

I'll start of giving the rules.xml used to do it and then I'll explain the parts of it.

<?xml version="1.0" encoding="UTF-8"?> <xdv:rules xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xdv="http://namespaces.plone.org/xdv" xmlns:css="http://namespaces.plone.org/xdv+css" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Strict will need rules to fix plone Transitional differences --> <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" method="xhtml" />

<!-- Remove whitespace because of line ends breaking validation.``--> <xsl:strip-space elements="ul ol dl" />

<!-- Remove name attribute from forms --> <xdv:drop content="//form/attribute::name" /> </xdv:rules> As you can see, I start of namespacing the different dialects in the rule file. A lot of the online tutorials don't show it this way. They generally have the xdv namespace as the default. I started of like that but it caused validation errors because the default namespace got the namespace added to some of the tags. Namespacing everything explicitly solved this.

<xdv:rules xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xdv="http://namespaces.plone.org/xdv" xmlns:css="http://namespaces.plone.org/xdv+css" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> The next step is to change the output doctype. I've focussed on getting the code to comply to xhtml 1.0 strict, but in theory it is also possible to turn it into html4.01 stict. For plone it's easier to go for xhtml since it' s already xhtml 1.0 transitional.

<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" method="xhtml" />

<!-- For html 4.01 you would use this code, the other rules on this page won't work to help validate that though, you'd have to find out for yourself what works. --> <!--xsl:output doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd"/--> Now our doctype for the XDV themed part of the site is shtml 1.0 strict. The content source is still transitional though. For the content to be valid we also need to make some changes to it. First off, the xsl transform caused whitespace characters to show up in places they were not allowed to show up. The issue was with character &13;.

I've solved this by selectively stripping whitespace. For now it is just stripped between list items. This is however a growing list. So far I haven't run in to the problem anymore, but if I will I'll update the items that need their whitespace stripped. Another option would be to strip all whitespace, but with this you would be risking stripping significant whitespace. <!-- Remove whitespace because of line ends breaking validation.

This rule will only remove whitespace between li, dt and dd elements. <xsl:strip-space elements="ul ol dl" />

The rules below will remove them all, which could cause trouble if there is significant whitespace without text between two elements. <xsl:strip-space elements="*" /> <xsl:preserve-space elements="pre" /> --> <xsl:strip-space elements="ul ol dl" /> Another validation error was caused by the name attribute on forms. This was an easy strip. Most Plone forms already have an id. If you're in a situation this is not the case you could decide, instead of dropping it, to set from name to id.

<!-- Remove name attribute from forms --> <xdv:drop content="//form/attribute::name" /></xdv:rules>

Pagination