diff --git a/include/DOM/Simple/DocumentImpl.hpp b/include/DOM/Simple/DocumentImpl.hpp index ed67dcd3..dc6153ec 100644 --- a/include/DOM/Simple/DocumentImpl.hpp +++ b/include/DOM/Simple/DocumentImpl.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -527,28 +526,6 @@ class DocumentImpl : public DOM::Document_impl, throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); } // checkChildType - void checkName(const stringT& str) const - { - if(string_adaptorT::length(str) == 0) - throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); - typedef typename string_adaptorT::const_iterator const_iterator; - const_iterator i = string_adaptorT::begin(str); - const_iterator ie = string_adaptorT::end(str); - for( ; i != ie; ++i) - if(!XML::is_name_char(*i)) - throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); - } // checkName - - void checkChars(const stringT& str) const - { - typedef typename string_adaptorT::const_iterator const_iterator; - const_iterator i = string_adaptorT::begin(str); - const_iterator ie = string_adaptorT::end(str); - for( ; i != ie; ++i) - if(!XML::is_char(*i)) - throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); - } // checkChars - private: DOMElement_implT* documentElement_; DOMDocumentType_implT* documentType_; diff --git a/include/DOM/Simple/ElementImpl.hpp b/include/DOM/Simple/ElementImpl.hpp index 2e58c999..bc722b1b 100644 --- a/include/DOM/Simple/ElementImpl.hpp +++ b/include/DOM/Simple/ElementImpl.hpp @@ -51,6 +51,7 @@ class ElementImpl : public DOM::Element_impl, virtual void setAttribute(const stringT& name, const stringT& value) { + checkName(name); attributes_.setAttribute(name, value); } // setAttribute @@ -88,6 +89,7 @@ class ElementImpl : public DOM::Element_impl, virtual void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value) { + checkName(qualifiedName); attributes_.setAttributeNS(namespaceURI, qualifiedName, value); } // setAttributeNS diff --git a/include/DOM/Simple/NodeImpl.hpp b/include/DOM/Simple/NodeImpl.hpp index 136a77c0..c0bc0fc4 100644 --- a/include/DOM/Simple/NodeImpl.hpp +++ b/include/DOM/Simple/NodeImpl.hpp @@ -3,12 +3,11 @@ //////////////////////////// // C++ DOM definition -// -// $Id$ //////////////////////////// #include #include +#include #include #include @@ -205,6 +204,28 @@ class NodeImpl : virtual public DOM::Node_impl } // throwIfReadOnly protected: + void checkName(const stringT& str) const + { + if(string_adaptorT::length(str) == 0) + throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); + typedef typename string_adaptorT::const_iterator const_iterator; + const_iterator i = string_adaptorT::begin(str); + const_iterator ie = string_adaptorT::end(str); + for( ; i != ie; ++i) + if(!XML::is_name_char(*i)) + throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); + } // checkName + + void checkChars(const stringT& str) const + { + typedef typename string_adaptorT::const_iterator const_iterator; + const_iterator i = string_adaptorT::begin(str); + const_iterator ie = string_adaptorT::end(str); + for( ; i != ie; ++i) + if(!XML::is_char(*i)) + throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR); + } // checkChars + NodeImplT* parentNode_; DocumentImplT* ownerDoc_; NodeImplT* prevSibling_;