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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of document</title>
</head>
<body>
Hello!
<template xmlns="http://www.w3.org/2012/xhtml-template">
  <script>
    alert("This script will not run because of its namespace");
  </script>
</template>
</body>
</html>

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.

Adam
Received on Wednesday, 18 July 2012 16:20:47 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:54 GMT