Opened 11 years ago

Last modified 11 years ago

#5179 enhancement new

twisted.web.template might not implement XML namespaces properly

Reported by: indigo Owned by:
Priority: normal Milestone:
Component: web Keywords:
Cc: indigo Branch:


Say I have a template like this:


and then fillMeUp is a render function that loads another template and inserts it into the <html> element. That template is defined like this:


the result might be a document like this:

<html xmlns=''>

The problem here is that the <body> element has magically changed namespaces. Because the XML document that contained it didn't define any namespaces, <body> was in the null namespace. By sticking it inside <html>, it's now in a different namespace, ''.

I don't know if there's anything in the XML standards that calls this illegal, but it's not the way most namespace aware XML applications will work, and so violates the principle of least surprise. For example, if one were to merge these two documents with XSLT, the result would be this:

<html xmlns=''>
  <body xmlns=''>woo!</body>

The first step towards fixing this problem probably involves altering the template DOM to be more in line with the data model typically used by XML applications. See for example the data model for xpath which is used by reference in the W3C standard for XSLT and probably others. See in particular the bit about "namespace nodes".

Change History (1)

comment:1 Changed 11 years ago by indigo

Cc: indigo added
Component: coreweb
Note: See TracTickets for help on using tickets.