Home

testxml

This package's example directory contains a command-line tool called testxml. This tool is useful if you want to see if there are any differences in the way a file is parsed by QXmlSimpleReader and by QtLibxmlReader.

testxml reads an xml file and parses it first with QtLibxmlReader, then with QXmlSimpleReader. For each parser, testxml prints out a trace of all activated SAX callbacks and their arguments.

 > testxml data.xml
 QtLibxmlReader returned 1
 setDocumentLocator(locator={columnNumber=1, lineNumber=1})
 startDocument()
    startDTD(name="document", publicId="", systemId="")
       externalEntityDecl(name="myExternalEntity", publicId="", systemId="2.ent")
       internatlEntityDecl(name="myInternalEntity", value="vlahuuurg")
       externalEntityDecl(name="myNetworkEntity", publicId="", systemId="http://osada.com.pl/2net.ent")
    endDTD()
    startElement(namespaceURI="", localName="document", qName="document", atts=[])
       characters(ch="\n    ")
       characters(ch="vlahuuurg")
       startElement(namespaceURI="", localName="rike", qName="rike", atts=[])
          characters(ch="Hello World! :)")
       endElement(namespaceURI="", localName="rike", qName="rike")
       characters(ch="\n")
       startElement(namespaceURI="", localName="rike", qName="rike", atts=[])
          characters(ch="Hello Networked World! :)")
       endElement(namespaceURI="", localName="rike", qName="rike")
       characters(ch="\n")
       skippedEntity(name="myUndefinedEntity")
       characters(ch="\n")
    endElement(namespaceURI="", localName="document", qName="document")
 endDocument()

 QtXmlSimpleReader returned 1
 setDocumentLocator(locator={columnNumber=1, lineNumber=1})
 startDocument()
    processingInstruction(target="xml", data="version = '1.0' encoding = 'UTF-8'")
    startDTD(name="document", publicId="", systemId="")
       externalEntityDecl(name="myExternalEntity", publicId="", systemId="2.ent")
       internatlEntityDecl(name="myInternalEntity", value="vlahuuurg")
       externalEntityDecl(name="myNetworkEntity", publicId="", systemId="http://osada.com.pl/2net.ent")
    endDTD()
    startElement(namespaceURI="", localName="document", qName="document", atts=[])
       resolveEntity(publicId="", systemId="2.ent", ret={})
       skippedEntity(name="myExternalEntity")
       resolveEntity(publicId="", systemId="http://osada.com.pl/2net.ent", ret={})
       skippedEntity(name="myNetworkEntity")
       skippedEntity(name="myUndefinedEntity")
       characters(ch="\n    vlahuuurg\n")
    endElement(namespaceURI="", localName="document", qName="document")
 endDocument()

The xml file in this example contained:

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE document [
     <!ENTITY myExternalEntity SYSTEM "2.ent">
     <!ENTITY myInternalEntity "vlahuuurg">
     <!ENTITY myNetworkEntity SYSTEM "http://osada.com.pl/2net.ent">
 ]>
 <document>
     &myInternalEntity;&myExternalEntity;&myNetworkEntity;&myUndefinedEntity;
 </document>

testxml accepts the command line options -libxml and -qtxml: if one of these is specified testxml will only run the specified parser. This is useful if you want to be certain you didn't miss any changes, since you can use these to generate separate traces for QtLibxmlParser and QXmlSimpleParser and then diff the results.


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions