W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

Making <template> play nice with XML and tags-and-text

From: Adam Barth <w3c@adambarth.com>
Date: Wed, 18 Jul 2012 09:19:43 -0700
Message-ID: <CAJE5ia_RNKmwScwC5J0YpaGcvk-Cik_N3UEMP1X9GgHDpJyr=A@mail.gmail.com>
To: WebApps WG <public-webapps@w3.org>
Cc: Henri Sivonen <hsivonen@iki.fi>, Ian Hickson <ian@hixie.ch>, Adam Klein <adamk@chromium.org>, Rafael Weinstein <rafaelw@chromium.org>
Inspired by a conversation with hsivonen in #whatwg, I spend some time
thinking about how we would design <template> for an XML world.  One idea I
had was to put the elements inside the template into a namespace other than
http://www.w3.org/1999/xhtml.  For example, consider the following XML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Title of document</title>
<template xmlns="http://www.w3.org/2012/xhtml-template">
    alert("This script will not run because of its namespace");

Unlike the existing "wormhole" <template> semantics, in this approach the
tags-and-text inside <template> would translate into DOM as usual for XML.
 We'd get the "inert" behavior for free because we'd avoid defining any
behavior for elements in the
http://www.w3.org/2012/xhtml-templatenamespace (just as no behavior is
defined today).

Whatever mechanism instantiates the templates would then
create corresponding elements in the
http://www.w3.org/1999/xhtmlnamespace, as usual.

Now that we have a working XML version of <template>, we can consider how
to port the element to HTML.  Fortunately, that's easy.  We just treat
<template> as triggering foreign content, analogous to how <svg> causes the
HTML parser to create elements in the http://www.w3.org/2000/svg namespace.

Received on Wednesday, 18 July 2012 16:20:47 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 11 February 2015 14:37:00 UTC