User:Michaeltwofish/xml templating

From Habari Project

Jump to: navigation, search

The aim of this page is to record thoughts and issues about using a theme engine and templates to create Atom and AtomPub output, rather than building them bit by bit using SimpleXML (as we do now) or DOM (because SimpleXML writing behaviour is inconsistent across PHP versions that we support).


  • Simplify Atom and AtomPub processing.
  • Produce output for Atom and AtomPub in the same way other output is created.
  • Explore the creation of a theme engine based upon XML templates that uses a serializer for output, and can output either HTML, XML, or other serializable formats. Assuming that's something we want to do


This is unlikely to be an exhaustive list of issues.

From conversation with gsnedders on #habari:

  • If we want pure XML output we then have to parse the posts' HTML on every load, and the DOM extension's HTML parser isn't particularly nice. Is Habari's HTMLTokenizer usable for this parsing? This might be addressed with caching.
  • If we ever want to store foreign content (from Atom, for example), we can't store data as HTML.

We need to know the type of every string (i.e., whether it is HTML, XML, plain text, etc.) to be able to serailize it appropriately. We can probably default the PHP string type to text (which is the only really safe type, as the others can contain scripting). gsnedders 14:46, 6 June 2009 (UTC)

We need decent serializers. For XML, neither DOM nor XML writer (yet alone SimpleXML) can actually be relied upon to output data that is well-formed XML. Equally, if we want it to be usable for HTML, we need a usable HTML serializer (though the libxml2 one in the DOM extension is mostly usable). gsnedders 14:46, 6 June 2009 (UTC)


Note that I'm not talking about the XHTML_vs_HTML debate, but some of that discussion might be relevant. Similarly, the long debate on -dev has some useful discussion (and a lot of people getting more upset than is good for them). Of particular interest is the message from Mark Pilgrim containing a lot of advice and references.

gsnedders has written about making Habari output XML.

Take a look at Genshi, a template engine for Python which uses a serializer. gsnedders 14:46, 6 June 2009 (UTC)

gsnedders talking on IRC

Personal tools