home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / xml / tagreader-with-features / tagreader.cpp < prev    next >
C/C++ Source or Header  |  2001-10-11  |  2KB  |  76 lines

  1. /****************************************************************************
  2. ** $Id:  qt/tagreader.cpp   3.0.0   edited Jun 22 13:24 $
  3. **
  4. ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
  5. **
  6. ** This file is part of an example program for Qt.  This example
  7. ** program may be used, distributed and modified without limitation.
  8. **
  9. *****************************************************************************/
  10.  
  11. #include "structureparser.h"
  12. #include <qapplication.h>
  13. #include <qfile.h>
  14. #include <qxml.h>
  15. #include <qlistview.h>
  16. #include <qgrid.h>
  17. #include <qmainwindow.h>
  18. #include <qlabel.h>
  19.  
  20. int main( int argc, char **argv )
  21. {
  22.     QApplication app( argc, argv );      
  23.  
  24.     QFile xmlFile( argc == 2 ? argv[1] : "fnord.xml" );
  25.     QXmlInputSource source( &xmlFile );
  26.  
  27.     QXmlSimpleReader reader;
  28.  
  29.     QGrid * container = new QGrid( 3 );
  30.  
  31.     QListView * nameSpace = new QListView( container, "table_namespace" );    
  32.     StructureParser * handler = new StructureParser( nameSpace );
  33.     reader.setContentHandler( handler );
  34.     reader.parse( source );
  35.  
  36.     QListView * namespacePrefix = new QListView( container, 
  37.                                                  "table_namespace_prefix" );    
  38.     handler->setListView( namespacePrefix );
  39.     reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", 
  40.                        TRUE );
  41.     source.reset();
  42.     reader.parse( source );
  43.  
  44.     QListView * prefix = new QListView( container, "table_prefix");    
  45.     handler->setListView( prefix );
  46.     reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE );
  47.     source.reset();
  48.     reader.parse( source );
  49.  
  50.     // namespace label
  51.     (void) new QLabel( 
  52.              "Default:\n"
  53.              "http://xml.org/sax/features/namespaces: TRUE\n"
  54.              "http://xml.org/sax/features/namespace-prefixes: FALSE\n",
  55.              container );
  56.  
  57.     // namespace prefix label
  58.     (void) new QLabel( 
  59.              "\n"
  60.              "http://xml.org/sax/features/namespaces: TRUE\n"
  61.              "http://xml.org/sax/features/namespace-prefixes: TRUE\n",
  62.              container );
  63.  
  64.     // prefix label
  65.     (void) new QLabel( 
  66.              "\n"
  67.              "http://xml.org/sax/features/namespaces: FALSE\n"
  68.              "http://xml.org/sax/features/namespace-prefixes: TRUE\n",
  69.              container );
  70.  
  71.  
  72.     app.setMainWidget( container );
  73.     container->show();
  74.     return app.exec();      
  75. }
  76.