=begin
/*
$Id: qt/examples/xml/tagreader-with-features/tagreader.cpp   2.2.4   edited 2001-01-22 $
*/
=end
require "qt2"
include Qt2
require "structureparser.rb"

    app = QApplication.new( [$0]+ARGV )

    xmlFile = File.new((ARGV.size == 1 ? ARGV[0]: "fnord.xml") , "r")  #QFilexmlFile( argc == 2 ? argv[1] : "fnord.xml" )
    source = QXmlInputSource.new
    source.setData(xmlFile.read )
    reader = QXmlSimpleReader.new

    container = QGrid.new( 3 )

    nameSpace = QListView.new( container, "table_namespace" )
    handlerNamespace = StructureParser.new
    handlerNamespace.setListView( nameSpace )
    reader.setContentHandler( handlerNamespace )
    reader.parse( source )

    namespacePrefix = QListView.new( container, "table_namespace_prefix" )
    handlerNamespacePrefix = StructureParser.new
    handlerNamespacePrefix.setListView( namespacePrefix )
    reader.setContentHandler( handlerNamespacePrefix )
    reader.setFeature( "http://xml.org/sax/features/namespaces", true )
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", true )
    reader.parse( source )

    prefix = QListView.new( container, "table_prefix")
    handlerPrefix = StructureParser.new
    handlerPrefix.setListView( prefix )
    reader.setContentHandler( handlerPrefix )
    reader.setFeature( "http://xml.org/sax/features/namespaces", false )
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", true )
    reader.parse( source )

    namespaceLabel = QLabel.new( (
                             "Default:\n"+ "http://xml.org/sax/features/namespaces: true\n"+ "http://xml.org/sax/features/namespace-prefixes: false\n"),
                             container )

    namespacePrefixLabel = QLabel.new((
                             "\n" + "http://xml.org/sax/features/namespaces: true\n"+ "http://xml.org/sax/features/namespace-prefixes: true\n"),
                             container )

    prefixLabel = QLabel.new((
                             "\n"+ "http://xml.org/sax/features/namespaces: false\n"+ "http://xml.org/sax/features/namespace-prefixes: true\n"),
                             container )


    app.setMainWidget( container )
    container.show()
    app.exec()

