]> git.sesse.net Git - xml-template/blobdiff - c++0x/simple.cpp
Fix namespace support for t:id in C++0x.
[xml-template] / c++0x / simple.cpp
index a5e7894ccfe0d66cc82d61dfe97b68bd884b96a9..69480e9c4abf21bb3ea619a554d7c2e77c6fc40c 100644 (file)
@@ -34,24 +34,19 @@ class Substitute : public Directive {
                        bool processed = false;
 
                        if (child->type == XML_ELEMENT_NODE) {
-                               xmlElement *elem = reinterpret_cast<xmlElement *>(child);
-
                                // Find the ID, if any.
                                string id;
-#if 0
-                               for (xmlAttribute *attr = elem->attributes; attr != NULL; attr = attr->nexth) {
-                                       // FIXME: namespace
-                                       if (strcmp(reinterpret_cast<const char *>(attr->name), "id") != 0) {
-                                               continue;
+                               for (xmlAttr *attr = child->properties; attr != NULL; attr = attr->next) {
+                                       if (strcmp(reinterpret_cast<const char *>(attr->ns->href), "http://template.sesse.net/") == 0 &&
+                                           strcmp(reinterpret_cast<const char *>(attr->name), "id") == 0) {
+                                               id = reinterpret_cast<const char *>(xmlNodeGetContent(attr->children));
                                        }
-                                       id = xmlNodeGetContent(attr->content);
                                }
-#endif
 
                                // Check all substitutions to see if we found anything appropriate.
                                for (auto it : substitution_map) {
                                        if (it.first == reinterpret_cast<const char *>(child->name) ||
-                                           (!id.empty() && ("#" + it.first) == id)) {
+                                           (!id.empty() && it.first == ("#" + id))) {
                                                it.second->process(child, clean);
                                                processed = true;
                                                break;