[Petal] Documentation RE xmlns:metal

Kurt Stephens kstep at pepsdesign.com
Mon May 9 02:29:39 BST 2005


Hi All,

I finally got around to working with METAL, and came across a
minor annoyance that I thought was a bug, but turns out to be
more a matter of missing documentation.  This includes the
section on the petal and metal namespaces in the current (2.16)
Petal cookbook.

First of all, I am using METAL to build the boilerplate HTML
around a Petal template that uses metal:fill-slot to provide the
content.  The included METAL master page itself uses Petal
commands for such things as the page title.

In order to get Petal and METAL to work together, you must
define the namespace for both.  I expected this and without
reading the docs I tried the following, which turns out to be
almost exactly what the cookbook says to do under "Fixing
invalid templates".  Actually, the cookbook places semicolons
after the xmlns attributes, leading me to believe that William
must be spending too much time hacking Perl ;)

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:petal="http://purl.org/petal/1.0/"
    xmlns:metal="http://purl.org/petal/1.0/"
    metal:define-macro="master">

As a result, Petal ignores any petal: commands called within the
master template.  My first thought was to change the metal:
namespace.  Again, without consulting the docs I changed it to
the following:

xmlns:metal="http://purl.org/petal/1.0/" <= WRONG!

Everything now works, except for the fact that the xmlns:metal
attribute is not stripped from the final output.  As I said in
the beginning, a minor annoyance.  I started looking at Petal.pm
to try to figure out why this was happening and noticed the
following lines:

our $MT_NS       = 'metal';
our $MT_NS_URI   = 'http://xml.zope.org/namespaces/metal';

Problem solved.  To correctly define the petal and metal
namespaces, use the following:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:petal="http://purl.org/petal/1.0/"
    xmlns:metal="http://xml.zope.org/namespaces/metal">

We should correct the section in the Petal cookbook and add this
to the main documentation in Petal.pm.  I will post a patch
against the current 2.16 code so that we can add this whenever
the next version comes out.

Cheers,

Kurt Stephens



More information about the Petal mailing list