Template <html>/root elements are full of crufty attributes

Bug #180980 reported by Matthew Paul Thomas
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

The <html> and/or root element in every Launchpad page template contains a lot of XML fluff. For example:
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:tal="http://xml.zope.org/namespaces/tal"
  xmlns:metal="http://xml.zope.org/namespaces/metal"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  xml:lang="en"
  lang="en"
  dir="ltr"
  metal:use-macro="context/@@main_template/master"
  i18n:domain="launchpad"
>

Or:
<tal:root
  xmlns:tal="http://xml.zope.org/namespaces/tal"
  omit-tag="">
<tal:tag condition="view/update"/>
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:metal="http://xml.zope.org/namespaces/metal"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  xml:lang="en"
  lang="en"
  dir="ltr"
  metal:use-macro="context/@@main_template/master"
  i18n:domain="launchpad"
>

The only attribute here that helps end users is metal:use-macro=, because it determines the page layout. The others are unnecessary, and their duplication in every template invites accidental mangling.
* xmlns=, xmlns:metal=, and xml:lang= reportedly exist only to convince xmllint to validate the templates using XML element nesting rules. Apparently this can be achieved with a Relax-NG schema instead.
* xml:lang=, lang=, and dir= are overridden by main-template.pt, so never have any effect.
* xmlns:i18n= and i18n:domain= are obsolete (see bug 3896).

Revision history for this message
James Henstridge (jamesh) wrote :

The xmlns attributes are necessary to make the document well formed XML. A RELAX-NG schema is not going to help you validate a badly formed XML file.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

xmlns:metal, xmlns:tal are needed by Zope to execute the PageTemplate correctly.

xmlns:i18n and i18n:domain are still required in some parts of Launchpad were we still plan to support multiple languages (Answers for example).

Changed in launchpad:
status: New → Won't Fix
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

I removed xmlns:metal and xmlns:tal from a page template, and it worked fine. So I don't think it's correct to say they're needed by Zope to execute the PageTemplate correctly. (Indeed, Launchpad ran successfully for a couple of years without them.)

Even if they were needed, that would still be brittle code duplication, which should be fixed in Zope so that the duplication could be removed from Launchpad.

Changed in launchpad:
status: Won't Fix → New
Revision history for this message
Joey Stanford (joey) wrote :

I had to add some of these in when I was updating login.launchpad.net. The inclusion of html caused make lint to fail when using

metal:use-macro="context/@@main_template/master"

I do agree it would be better if we could just make the headers standard and include them somehow rather than have this code repeated in each template.

Curtis Hovey (sinzui)
Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
Curtis Hovey (sinzui)
visibility: private → public
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.