Add xsi:nil support to objects.
[shibboleth/xmltooling.git] / xmltooling / base.h
index 4936a8a..b6d3ba3 100644 (file)
         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
             if (!ptr) \
-                throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
+                throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); \
+            if (ptr->nil() && (ptr->hasChildren() || ptr->getTextContent())) \
+               throw xmltooling::ValidationException("Object has nil property but with children or content.")
 
 /**
  * Begins the declaration of a Schema Validator specialization subclass.
         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
             if (!ptr) \
-                throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
+                throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()));
 
 /**
  * Ends the declaration of a Validator specialization.