xml_tokenizer.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _XML_Tokenizer_h_
00025 #define _XML_Tokenizer_h_
00026
00027 #include <qxml.h>
00028 #include <qptrlist.h>
00029 #include <qobject.h>
00030 #include "misc/loader_client.h"
00031
00032 class KHTMLView;
00033
00034 namespace khtml {
00035 class CachedObject;
00036 class CachedScript;
00037 };
00038
00039 namespace DOM {
00040 class DocumentImpl;
00041 class NodeImpl;
00042 class HTMLScriptElementImpl;
00043 class DocumentPtr;
00044 class HTMLScriptElementImpl;
00045 };
00046
00047 class XMLHandler : public QXmlDefaultHandler
00048 {
00049 public:
00050 XMLHandler(DOM::DocumentPtr *_doc, KHTMLView *_view);
00051 virtual ~XMLHandler();
00052
00053
00054 QString errorProtocol();
00055
00056
00057 bool startDocument();
00058 bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts);
00059 bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName);
00060 bool startCDATA();
00061 bool endCDATA();
00062 bool characters(const QString& ch);
00063 bool comment(const QString & ch);
00064 bool processingInstruction(const QString &target, const QString &data);
00065
00066
00067
00068 bool attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value);
00069 bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId);
00070 bool internalEntityDecl(const QString &name, const QString &value);
00071
00072
00073 bool notationDecl(const QString &name, const QString &publicId, const QString &systemId);
00074 bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString ¬ationName);
00075
00076 bool enterText();
00077 void exitText();
00078
00079 QString errorString();
00080
00081 bool fatalError( const QXmlParseException& exception );
00082
00083 unsigned long errorLine;
00084 unsigned long errorCol;
00085
00086 private:
00087 QString errorProt;
00088 DOM::DocumentPtr *m_doc;
00089 KHTMLView *m_view;
00090 DOM::NodeImpl *m_currentNode;
00091 DOM::NodeImpl *m_rootNode;
00092
00093 enum State {
00094 StateInit,
00095 StateDocument,
00096 StateQuote,
00097 StateLine,
00098 StateHeading,
00099 StateP
00100 };
00101 State state;
00102 };
00103
00104 class Tokenizer : public QObject
00105 {
00106 Q_OBJECT
00107 public:
00108 virtual void begin() = 0;
00109
00110
00111
00112
00113 virtual void write( const QString &str, bool appendData) = 0;
00114 virtual void end() = 0;
00115 virtual void finish() = 0;
00116 virtual void setOnHold(bool ) {}
00117
00118 signals:
00119 void finishedParsing();
00120
00121 };
00122
00123 class XMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
00124 {
00125 public:
00126 XMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
00127 virtual ~XMLTokenizer();
00128 virtual void begin();
00129 virtual void write( const QString &str, bool );
00130 virtual void end();
00131 virtual void finish();
00132
00133
00134 void notifyFinished(khtml::CachedObject *finishedObj);
00135
00136 protected:
00137 DOM::DocumentPtr *m_doc;
00138 KHTMLView *m_view;
00139
00140 void executeScripts();
00141 void addScripts(DOM::NodeImpl *n);
00142
00143 QString m_xmlCode;
00144 QPtrList<DOM::HTMLScriptElementImpl> m_scripts;
00145 QPtrListIterator<DOM::HTMLScriptElementImpl> *m_scriptsIt;
00146 khtml::CachedScript *m_cachedScript;
00147 };
00148
00149 #endif
This file is part of the documentation for kdelibs Version 3.1.0.