Implemented yp2::xml::check_empty that serves as default
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Jan 2006 14:58:28 +0000 (14:58 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Jan 2006 14:58:28 +0000 (14:58 +0000)
configure method for filter (in which case no XML config is
allowed).

src/filter.cpp
src/test_router_flexml.cpp
src/xmlutil.cpp
src/xmlutil.hpp

index 02c6ff4..ecbec46 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter.cpp,v 1.5 2006-01-11 13:13:49 adam Exp $
+/* $Id: filter.cpp,v 1.6 2006-01-11 14:58:28 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -11,7 +11,7 @@
 
 void yp2::filter::Base::configure(const xmlNode * ptr)
 {
-    
+    yp2::xml::check_empty(ptr);
 }
 
 /*
index 99aa27c..b1b79a1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: test_router_flexml.cpp,v 1.14 2006-01-11 11:51:50 adam Exp $
+/* $Id: test_router_flexml.cpp,v 1.15 2006-01-11 14:58:28 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -45,9 +45,7 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 )
             "    <filter id=\"log_cout1\" type=\"log\">\n"
             "      <message>my msg</message>\n"
             "    </filter>\n"
-            "    <filter id=\"tfilter_id\" type=\"tfilter\">\n"
-            "      <someelement/>\n"
-            "    </filter>\n"
+            "    <filter id=\"tfilter_id\" type=\"tfilter\"/>\n"
             "    <filter id=\"log_cout2\" type=\"log\">\n"
             "      <message>other</message>\n"
             "    </filter>\n"
index 600ba5c..d4026b9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xmlutil.cpp,v 1.3 2006-01-11 13:13:49 adam Exp $
+/* $Id: xmlutil.cpp,v 1.4 2006-01-11 14:58:28 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -94,6 +94,17 @@ const xmlNode* yp2::xml::jump_to(const xmlNode* node,
     return node;
 }
 
+void yp2::xml::check_empty(const xmlNode *node)
+{
+    if (node)
+    {
+        const xmlNode *n;
+        for (n = node->children; n; n = n->next)
+            if (n->type == XML_ELEMENT_NODE)
+                throw yp2::XMLError("No child elements allowed inside element "
+                                    + std::string((const char *) node->name));
+    }
+}
 
 /*
  * Local variables:
index db8636f..fca73fa 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xmlutil.hpp,v 1.3 2006-01-11 13:13:49 adam Exp $
+/* $Id: xmlutil.hpp,v 1.4 2006-01-11 14:58:28 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -27,6 +27,9 @@ namespace yp2 {
         const xmlNode* jump_to_next(const xmlNode* node, int node_type);
         
         const xmlNode* jump_to_children(const xmlNode* node, int node_type);
+
+        void check_empty(const xmlNode *node);
+
     }
     class XMLError : public std::runtime_error {
     public: