don't blow up when parsing DTDs

This commit is contained in:
jez 2006-08-04 09:49:58 +00:00
parent 56b1aff551
commit 205fd30cf0
2 changed files with 8 additions and 7 deletions

View file

@ -32,9 +32,9 @@ class DocumentType : public SimpleDOM::DocumentTypeImpl<stringT, string_adaptorT
BaseDT::addNotation(notation);
} // addNotation
void addElement(SimpleDOM::ElementImpl<stringT, string_adaptorT>* element)
void addElement(const stringT& name)
{
BaseDT::addElement(element);
BaseDT::addElement(new SimpleDOM::ElementImpl<stringT, string_adaptorT>(BaseDT::ownerDoc_, name));
} // addElement
void addDefaultAttr(const stringT& elementName, const stringT& attributeName, const stringT& attributeValue)
@ -42,8 +42,8 @@ class DocumentType : public SimpleDOM::DocumentTypeImpl<stringT, string_adaptorT
SimpleDOM::ElementImpl<stringT, string_adaptorT>* elem = dynamic_cast<SimpleDOM::ElementImpl<stringT, string_adaptorT>*>(BaseDT::getElements()->getNamedItem(elementName));
if(elem == 0)
{
elem = new SimpleDOM::ElementImpl<stringT, string_adaptorT>(0, elementName);
addElement(elem);
addElement(elementName);
elem = dynamic_cast<SimpleDOM::ElementImpl<stringT, string_adaptorT>*>(BaseDT::getElements()->getNamedItem(elementName));
}
SimpleDOM::AttrImpl<stringT, string_adaptorT>* attr = new SimpleDOM::AttrImpl<stringT, string_adaptorT>(BaseDT::ownerDoc_, attributeName);
attr->setValue(attributeValue);

View file

@ -54,8 +54,9 @@ class Parser : protected SAX::basic_DefaultHandler2<stringT>
{
typename Features::iterator f = features_.find(name);
if(f == features_.end())
throw SAX::SAXNotRecognizedException(std::string("Feature not recognized ") + string_adaptorT::asStdString(name));
f->second = value;
features_.insert(std::make_pair(name, value));
else
f->second = value;
} // setFeature
bool getFeature(const stringT& name) const
@ -324,7 +325,7 @@ class Parser : protected SAX::basic_DefaultHandler2<stringT>
// DeclHandler
virtual void elementDecl(const stringT& name, const stringT& model)
{
documentType_->addElement(new ElementT(0, name));
documentType_->addElement(name);
} // elementDecl
virtual void attributeDecl(const stringT& elementName,