本文整理汇总了C++中QXmlSimpleReader::setDTDHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlSimpleReader::setDTDHandler方法的具体用法?C++ QXmlSimpleReader::setDTDHandler怎么用?C++ QXmlSimpleReader::setDTDHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlSimpleReader
的用法示例。
在下文中一共展示了QXmlSimpleReader::setDTDHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finish
void XMLTokenizer::finish()
{
// parse xml file
XMLHandler handler(m_doc,m_view);
QXmlInputSource source;
source.setData(m_xmlCode);
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.setLexicalHandler( &handler );
reader.setErrorHandler( &handler );
reader.setDeclHandler( &handler );
reader.setDTDHandler( &handler );
bool ok = reader.parse( source );
// ### handle exceptions inserting nodes
if (!ok) {
kdDebug(6036) << "Error during XML parsing: " << handler.errorProtocol() << endl;
int exceptioncode;
while (m_doc->hasChildNodes())
static_cast<NodeImpl*>(m_doc)->removeChild(m_doc->firstChild(),exceptioncode);
// construct a HTML page giving the error message
// ### for multiple error messages, display the code for each
QTextIStream stream(&m_xmlCode);
unsigned long lineno;
for (lineno = 0; lineno < handler.errorLine-1; lineno++)
stream.readLine();
QString line = stream.readLine();
m_doc->appendChild(m_doc->createElementNS("http://www.w3.org/1999/xhtml","html"),exceptioncode);
NodeImpl *body = m_doc->createElementNS("http://www.w3.org/1999/xhtml","body");
m_doc->firstChild()->appendChild(body,exceptioncode);
NodeImpl *h1 = m_doc->createElementNS("http://www.w3.org/1999/xhtml","h1");
body->appendChild(h1,exceptioncode);
h1->appendChild(m_doc->createTextNode(i18n("XML parsing error")),exceptioncode);
h1->renderer()->close();
body->appendChild(m_doc->createTextNode(handler.errorProtocol()),exceptioncode);
body->appendChild(m_doc->createElementNS("http://www.w3.org/1999/xhtml","hr"),exceptioncode);
NodeImpl *pre = m_doc->createElementNS("http://www.w3.org/1999/xhtml","pre");
body->appendChild(pre,exceptioncode);
pre->appendChild(m_doc->createTextNode(line+"\n"),exceptioncode);
unsigned long colno;
QString indent = "";
for (colno = 0; colno < handler.errorCol-1; colno++)
indent += " ";
pre->appendChild(m_doc->createTextNode(indent+"^"),exceptioncode);
pre->renderer()->close();
body->renderer()->close();
m_doc->applyChanges();
m_doc->updateRendering();
end();
}
else {
addScripts(m_doc);
m_scriptsIt = new QListIterator<HTMLScriptElementImpl>(m_scripts);
executeScripts();
}
}