[ZPT] Proposal: add a 'prolog' property to templates

Tres Seaver tseaver at palladion.com
Thu Mar 22 07:24:36 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rationale
- ---------

Lots of templates in use have the following ugly hack, or some version
of it, in order to avoid repeating DTD, etc.:

  <tal:wrap metal:define-macro="page"
  ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html>
  ...
  </html>
  </tal:wrap>

There are a couple of issues here:

  - First, this is nasty, and it makes the document itself unparseable
    (since SGML requires the DTD to appear *first*).

  - Second, the presence of an HTML DTD in the source template, even
    without the <tal:wrap> hack, is a lie:  the templates themselves
    do not conform to the DTD, because they have namespaced elements,
    even though the rendered output might be conformant once the ZPT
    engine strips them all away.

  - The presence of the DTD in the rendered output is, however, a
    requirement in order to get the browsers (IE, in particular) to
    render it properly.

For templates aimed at producing XML, the issue is less severe, as fewer
documents need or want DTDs declared.  There might be a problems where
includng the <?xml...?> prolog or other processing instructions would be
problematic in the source template.

Proposal
- --------

Give templates an optional 'prolog' attribute, which, if present, would
be prepended to the rendered output.


Details
- -------

- - The prolog would likely need to be ASCII, as it appears before any of
  the inline encoding hints.  ZPT might not need to enforce this
  constraint.

- - Persistent templates would expose this attribute as a property (in
  the Zope2 ZMI) or as part of their schema (IZPTPage, or whatever).

- - Filesystem-based templtes would have to keep the prolog in an
  ancillary file (e.g., the CMF's '.metadata' file).


Thoughts?


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGAmd0+gerLs4ltQ4RAkjvAJ9eulH90oDJfaVBemyc07D98NEYUgCfR71E
tm1Iszglqi0EjyIvnBtu4CA=
=2V2K
-----END PGP SIGNATURE-----



More information about the ZPT mailing list