#define PROC_TYPED_CHILD(proper,namespaceURI,force) \
if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
- if (typesafe) { \
- set##proper(typesafe); \
+ if (typesafe && !m_##proper) { \
+ typesafe->setParent(this); \
+ *m_pos_##proper = m_##proper = typesafe; \
return; \
} \
}
#define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
- if (typesafe) { \
- set##proper(typesafe); \
+ if (typesafe && !m_##proper) { \
+ typesafe->setParent(this); \
+ *m_pos_##proper = m_##proper = typesafe; \
return; \
} \
}
*/
#define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
- set##proper(childXMLObject); \
- return; \
+ if (!m_##proper) { \
+ childXMLObject->setParent(this); \
+ *m_pos_##proper = m_##proper = childXMLObject; \
+ return; \
+ } \
}
/**
*/
#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
XMLTOOLING_DOXYGEN(Builder for cname objects.) \
- class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
+ class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
public: \
virtual ~cname##Builder() {} \
XMLTOOLING_DOXYGEN(Default builder.) \
*/
#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
XMLTOOLING_DOXYGEN(Builder for cname objects.) \
- class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
+ class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
public: \
virtual ~cname##Builder() {} \
XMLTOOLING_DOXYGEN(Default builder.) \
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.