#include <qfile.h>
#include <qtextstream.h>

#include <kaboutdata.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <klocale.h>

#include <khtml_part.h>
#include <khtmlview.h>
#include <kparts/browserextension.h>
#include <kparts/part.h>

#include "dom/dom_doc.h"
#include "dom/dom_element.h"
#include "dom/dom_string.h"

#include "query.h"
#include "value.h"
#include "xpath_node.h"
#include "xpath_tests.h"

int main(int argc, char **argv)
{
    static KCmdLineOptions options[] = {
        { "+file", I18N_NOOP( "URL of a document to load" ), 0 },
        { 0, 0, 0 }
    };

    KAboutData about("xpathtest", I18N_NOOP("XPathTest"), "Pre-0.0",
                     I18N_NOOP("Test XPath"),
                     KAboutData::License_Unknown,
                     I18N_NOOP("(c) 2003 Richard Moore"));
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;

    KHTMLPart *html = new KHTMLPart;
    KParts::URLArgs uargs( html->browserExtension()->urlArgs() );
    uargs.serviceType = "text/xml";
    html->browserExtension()->setURLArgs( uargs );

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    QString fn = args->arg(0);
    QFile file( fn );
    if ( !file.open( IO_ReadOnly ) )
	return false;

    QTextStream ts( &file );

    html->begin();
    html->write( ts.read() );
    html->end();

//    interactive( html );
    XPath::Tests::test_ast( html );
}



