Thomas Holder wrote, On 01/08/09 14:35:
as an alternative, we could do the same like with SVG files. There is a "promote_to_svg_namespace" function in xml/repr-io.cpp, so SVG files work fine with and without xmlns attribute.
patch applied that promotes the default namespace to all read XML files, not just SVG. What do you think about it? Still nasty?
Thomas
Index: src/xml/repr-io.cpp =================================================================== --- src/xml/repr-io.cpp (revision 20479) +++ src/xml/repr-io.cpp (working copy) @@ -362,16 +362,16 @@
namespace {
-void promote_to_svg_namespace(Node *repr) { +void promote_to_namespace(Node *repr, const gchar *prefix) { if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) { GQuark code = repr->code(); if (!qname_prefix(code).id()) { - gchar *svg_name = g_strconcat("svg:", g_quark_to_string(code), NULL); + gchar *svg_name = g_strconcat(prefix, ":", g_quark_to_string(code), NULL); repr->setCodeUnsafe(g_quark_from_string(svg_name)); g_free(svg_name); } for ( Node *child = sp_repr_children(repr) ; child ; child = sp_repr_next(child) ) { - promote_to_svg_namespace(child); + promote_to_namespace(child, prefix); } } } @@ -416,10 +416,9 @@ if (root != NULL) { /* promote elements of SVG documents that don't use namespaces * into the SVG namespace */ - if ( default_ns && !strcmp(default_ns, SP_SVG_NS_URI) - && !strcmp(root->name(), "svg") ) - { - promote_to_svg_namespace(root); + if ( default_ns && !strchr(root->name(), ':') ) { + const gchar *prefix = sp_xml_ns_uri_prefix(default_ns, NULL); + promote_to_namespace(root, prefix); } }