lihaoyi/scalatags — pull request #22 by mysticfall (2014-06-14 21:33:33+00:00)
Title: Proposed namespace support and SVG rendering fix.

Hi,

I extended my previous attempt at fixing SVG rendering problem to possible future enhancement regarding general namespace support.

Currently, tags and attributes can only render with local names, but I suppose I better ask your opinion and confirmation as to how we should handle namespaces in future.

For example, typical SVG file includes ```metadata``` tags which normally include elements defined in _Dublin Core_ or _Creative Commons_ namespace as below :

```xml

```
In that case, users might want some way to controll what tags and attributes should be rendered in qualified manner(i.e. ```dc:creator```) and or in unqualified form(i.e. ```metadata```).

Furthermore, _Scalatags_ currently has ```xmlns``` attribute defined in ```Attr``` class, but as shown from above example, it can't handle such cases like ```xmlns:rdf```.

Note that the above example can be rewritten as below, by moving namespace declarations to one of ```svg``` tag's child nodes :

```xml

```
It's a perfectly valid case, and some people might actually prefer this style too, so I guess we need to consider supporting this use case also.

I thought about writing something that will collect all child tags/attributes before rendering itself to decide what descendant elements are in different namespace than the self, so need to be rendered in a qualified form. However, in that case it might be problematic if one wants to render fragments of the document tree, like rendering the ```dc:creator``` subtree without adding it to the parent first.

I'd appreciate your thoughts on this, and hope we could build something on top of it to implement more general namespace support for the project.

Thanks!