PDA

View Full Version : Accessing DTD in an XML file via QtXml module?



jorma
6th May 2006, 18:03
QT's XML parsers (DOM and SAX) can not validate that the XML file conforms to the possible DTD given in the file. I can live with that.

However, I would like to use the DTD information myself, and I have not found a way to do it with QT. I have used DOM parsing, and QDomImplementation has a function "createDocumentType" but no examples are given, and I have not been able to find the right way to use it myself.

It breaks my heart to hard-code the DTD into my program (to assume while writing the code that for example element "paragraph" is always a child of element "myDocument" etc.). I would like to do this in a generic way -

- read in the XML file including the DTD, no need to validate the XML file
- display the XML file elements as a tree (not the DTD info)
- edit the tree and verify at least some of the edit actions by using the DTD information (like copy-paste of the subtrees etc)
- save the tree

surely this cannot require a full-validating XML parser if I make my possible trees simple enough? But how should it be done? Has anyone got an example?

- Jorma

nupul
6th May 2006, 19:09
There is an example in the Qt package "Simple DOM model"

$QTDIR/itemviews/simpledommodel/

also a part of Qtdemo (ofcourse!) under the same hierarchy...try it, it may be of some help!