Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Validate an XML document

[SOLVED]Validate an XML document

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    issam
    wrote on last edited by
    #1

    Hi,
    I am developing a Petri Net Editor. A Petri net is a set of Places(ellipce items), transitons (rect items), Arc (path items) and Labels (text items) drawn in a graphicsScene.
    I want to add the file save functionality to the application and XML is the best way. "PNML core model":http://www.pnml.org/version-2009/grammar/pnmlcoremodel.rng is the standard specification.

    What is the better way : using QDomDocument or QXmlStreamWriter/Reader ?
    How can i validate the xml document before open it ?
    I mean is there a Qt tool to validate such doc ori have to implement the validator ?

    thanks in advance.

    http://www.iissam.com/

    1 Reply Last reply
    0
    • A Offline
      A Offline
      akonradwesolutions
      wrote on last edited by
      #2

      Qt does AFAIK not support validation of Relax NG schema definitions, so if you want to validate input against that schema you should find some 3rd-party component that offers validation. Implementing the validation yourself is most likely not trivial and not worth the effort. If you can get a hold of a W3C XML Schema for the desired format you can use QXmlSchemaValidator contained in the QtXmlPatterns module for validation.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bodzio131
        wrote on last edited by
        #3

        Hi,
        You could try to use QXmlSchema/QXmlDTDHandler for validation.
        I would prefer QXmlStreamWriter/Reader as it seems to be faster and less memory consuming than QDomDocument. From the other side if you need to have whole xml document structure loaded then QDomDocument could be good container for you. Unfortunately the answer strongly depends on your internal requirements, so probably nobody can give you clear clue which class would be best for you.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          issam
          wrote on last edited by
          #4

          OOps, i didn't see the QtXmlPatterns module. It is the key !

          So i will use :

          • QXmlSchema : to validate the data definition schema.
          • QXmlSchemaValidator : to validate the xml doc
          • QXmlStreamWriter/Reader : to read write the xml doc

          Thanks all. :)

          http://www.iissam.com/

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved