]> git.sesse.net Git - xml-template/commitdiff
Fix #id handling in the C++0x version.
authorsgunderson@bigfoot.com <>
Wed, 21 Sep 2011 19:23:59 +0000 (21:23 +0200)
committersgunderson@bigfoot.com <>
Wed, 21 Sep 2011 19:23:59 +0000 (21:23 +0200)
c++0x/simple.cpp

index a5e7894ccfe0d66cc82d61dfe97b68bd884b96a9..c95bc437c6bc81fc51d5faf8d613d9485b66683b 100644 (file)
@@ -34,24 +34,20 @@ class Substitute : public Directive {
                        bool processed = false;
 
                        if (child->type == XML_ELEMENT_NODE) {
                        bool processed = false;
 
                        if (child->type == XML_ELEMENT_NODE) {
-                               xmlElement *elem = reinterpret_cast<xmlElement *>(child);
-
                                // Find the ID, if any.
                                string id;
                                // Find the ID, if any.
                                string id;
-#if 0
-                               for (xmlAttribute *attr = elem->attributes; attr != NULL; attr = attr->nexth) {
+                               for (xmlAttr *attr = child->properties; attr != NULL; attr = attr->next) {
                                        // FIXME: namespace
                                        if (strcmp(reinterpret_cast<const char *>(attr->name), "id") != 0) {
                                                continue;
                                        }
                                        // FIXME: namespace
                                        if (strcmp(reinterpret_cast<const char *>(attr->name), "id") != 0) {
                                                continue;
                                        }
-                                       id = xmlNodeGetContent(attr->content);
+                                       id = reinterpret_cast<const char *>(xmlNodeGetContent(attr->children));
                                }
                                }
-#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) ||
 
                                // 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;
                                                it.second->process(child, clean);
                                                processed = true;
                                                break;