diff options
Diffstat (limited to 'doc/html/xml-sax-walkthrough.html')
-rw-r--r-- | doc/html/xml-sax-walkthrough.html | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/doc/html/xml-sax-walkthrough.html b/doc/html/xml-sax-walkthrough.html index 4703e6cba..d1c4a50f2 100644 --- a/doc/html/xml-sax-walkthrough.html +++ b/doc/html/xml-sax-walkthrough.html @@ -47,10 +47,10 @@ The element names are indented corresponding to their nesting level. <p> As mentioned in <a href="xml.html#sax2Intro">Introduction to SAX2</a> we have to implement the functions of the handler classes that we are interested in. In our case these are only three: -<a href="qxmlcontenthandler.html#startDocument">TQXmlContentHandler::startDocument</a>(), -<a href="qxmlcontenthandler.html#startElement">TQXmlContentHandler::startElement</a>() and -<a href="qxmlcontenthandler.html#endElement">TQXmlContentHandler::endElement</a>(). -<p> For this purpose we use a subclass of the <a href="qxmldefaulthandler.html">TQXmlDefaultHandler</a> (remember +<a href="tqxmlcontenthandler.html#startDocument">TQXmlContentHandler::startDocument</a>(), +<a href="tqxmlcontenthandler.html#startElement">TQXmlContentHandler::startElement</a>() and +<a href="tqxmlcontenthandler.html#endElement">TQXmlContentHandler::endElement</a>(). +<p> For this purpose we use a subclass of the <a href="tqxmldefaulthandler.html">TQXmlDefaultHandler</a> (remember that the special handler classes are all abstract and the default handler class provides an implementation that does not change the parsing behavior): <p> <pre>/**************************************************************************** @@ -66,16 +66,16 @@ provides an implementation that does not change the parsing behavior): #ifndef STRUCTUREPARSER_H #define STRUCTUREPARSER_H -#include <<a href="qxml-h.html">ntqxml.h</a>> +#include <<a href="tqxml-h.html">tqxml.h</a>> class TQString; -class StructureParser : public <a href="qxmldefaulthandler.html">TQXmlDefaultHandler</a> +class StructureParser : public <a href="tqxmldefaulthandler.html">TQXmlDefaultHandler</a> { public: bool startDocument(); bool startElement( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>& , - const <a href="qxmlattributes.html">TQXmlAttributes</a>& ); + const <a href="tqxmlattributes.html">TQXmlAttributes</a>& ); bool endElement( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>& ); private: @@ -96,8 +96,8 @@ get indentation right, there is nothing special about our new #include <stdio.h> #include <<a href="qstring-h.html">ntqstring.h</a>> </pre> -<p> First we overload <a href="qxmlcontenthandler.html#startDocument">TQXmlContentHandler::startDocument</a>() with a non-empty version. -<p> <pre> <a name="x2137"></a>bool StructureParser::<a href="qxmlcontenthandler.html#startDocument">startDocument</a>() +<p> First we overload <a href="tqxmlcontenthandler.html#startDocument">TQXmlContentHandler::startDocument</a>() with a non-empty version. +<p> <pre> <a name="x2137"></a>bool StructureParser::<a href="tqxmlcontenthandler.html#startDocument">startDocument</a>() { indent = ""; return TRUE; @@ -110,10 +110,10 @@ Also we return TRUE so that the parser continues without reporting an error. <p> Because we want to be informed when the parser comes accross a start tag of an element and subsequently print it out, we -have to overload <a href="qxmlcontenthandler.html#startElement">TQXmlContentHandler::startElement</a>(). -<p> <pre> <a name="x2138"></a>bool StructureParser::<a href="qxmlcontenthandler.html#startElement">startElement</a>( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, +have to overload <a href="tqxmlcontenthandler.html#startElement">TQXmlContentHandler::startElement</a>(). +<p> <pre> <a name="x2138"></a>bool StructureParser::<a href="tqxmlcontenthandler.html#startElement">startElement</a>( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>& qName, - const <a href="qxmlattributes.html">TQXmlAttributes</a>& ) + const <a href="tqxmlattributes.html">TQXmlAttributes</a>& ) { printf( "%s%s\n", (const char*)indent, (const char*)qName ); indent += " "; @@ -130,8 +130,8 @@ it should be indented. Therefore we add four spaces to the <p> Finally we return TRUE in order to let the parser continue without errors. <p> The last functionality we need to add is the parser's behaviour when an -end tag occurs. This means overloading <a href="qxmlcontenthandler.html#endElement">TQXmlContentHandler::endElement</a>(). -<p> <pre> <a name="x2136"></a>bool StructureParser::<a href="qxmlcontenthandler.html#endElement">endElement</a>( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>& ) +end tag occurs. This means overloading <a href="tqxmlcontenthandler.html#endElement">TQXmlContentHandler::endElement</a>(). +<p> <pre> <a name="x2136"></a>bool StructureParser::<a href="tqxmlcontenthandler.html#endElement">endElement</a>( const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>&, const <a href="ntqstring.html">TQString</a>& ) { indent.remove( (uint)0, 4 ); return TRUE; @@ -145,7 +145,7 @@ program. <p> <pre> #include "structureparser.h" #include <<a href="qfile-h.html">ntqfile.h</a>> - #include <<a href="qxml-h.html">ntqxml.h</a>> + #include <<a href="tqxml-h.html">tqxml.h</a>> #include <<a href="qwindowdefs-h.html">ntqwindowdefs.h</a>> int main( int argc, char **argv ) @@ -160,21 +160,21 @@ line to examine. <p> <pre> StructureParser handler; </pre> <p> The next step is to create an instance of the <em>StructureParser</em>. -<p> <pre> <a href="qxmlsimplereader.html">TQXmlSimpleReader</a> reader; - <a name="x2140"></a> reader.<a href="qxmlreader.html#setContentHandler">setContentHandler</a>( &handler ); +<p> <pre> <a href="tqxmlsimplereader.html">TQXmlSimpleReader</a> reader; + <a name="x2140"></a> reader.<a href="tqxmlreader.html#setContentHandler">setContentHandler</a>( &handler ); </pre> <p> After that we set up the reader. As our <em>StructureParser</em> -class deals with <a href="qxmlcontenthandler.html">TQXmlContentHandler</a> functionality only +class deals with <a href="tqxmlcontenthandler.html">TQXmlContentHandler</a> functionality only we simply register it as the content handler of our choice. <p> <pre> for ( int i=1; i < argc; i++ ) { </pre> <p> Successively we deal with all files given as command line arguments. <p> <pre> <a href="ntqfile.html">TQFile</a> xmlFile( argv[i] ); - <a href="qxmlinputsource.html">TQXmlInputSource</a> source( &xmlFile ); + <a href="tqxmlinputsource.html">TQXmlInputSource</a> source( &xmlFile ); </pre> <p> Then we create a -<a href="qxmlinputsource.html">TQXmlInputSource</a> for the XML file to be parsed. -<p> <pre> <a name="x2139"></a> reader.<a href="qxmlsimplereader.html#parse">parse</a>( source ); +<a href="tqxmlinputsource.html">TQXmlInputSource</a> for the XML file to be parsed. +<p> <pre> <a name="x2139"></a> reader.<a href="tqxmlsimplereader.html#parse">parse</a>( source ); </pre> <p> Now we take our input source and start parsing. <p> <pre> } @@ -206,7 +206,7 @@ animals <p> It will however refuse to produce the correct result if you e.g. insert a whitespace between a < and the element name in your test-XML file. To prevent such annoyances -you should always install an error handler with <a href="qxmlreader.html#setErrorHandler">TQXmlReader::setErrorHandler</a>(). This allows you to report +you should always install an error handler with <a href="tqxmlreader.html#setErrorHandler">TQXmlReader::setErrorHandler</a>(). This allows you to report parsing errors to the user. <p> <p>See also <a href="step-by-step-examples.html">Step-by-step Examples</a>. |