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]QXmlStreamWrite writing namespace !

[SOLVED]QXmlStreamWrite writing namespace !

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k 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 8 May 2013, 15:59 last edited by
    #1

    Hi,
    I have to write an XML file using QXmlStreamWrite like this :

    @
    <?xml version="1.0" encoding="UTF-8"?>
    <pnml >
    <net>
    .....................
    </net>
    </pnml>
    @

    But, QXmlStreamWriter assigns a prefix consisting of the letter 'n' followed by a number, by default :

    @
    <?xml version="1.0" encoding="UTF-8"?>
    <pnml xmlns:n1="http://www.pnml.org/version-2009/grammar/pnml">
    <net>
    .....................
    </net>
    </pnml>
    @

    Which is not allowed in my "XML scheam":http://www.pnml.org/version-2009/grammar/pnmlcoremodel.rng.
    So after writing the XML file I have always to open that file and eliminate by hand the " :n1 " string. Which is not
    practical !

    Is there any suggestion ?

    thanks in advance.

    http://www.iissam.com/

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on 9 May 2013, 10:38 last edited by
      #2

      Hi,

      using
      @void QXmlStreamWriter::writeNamespace(const QString & namespaceUri, const QString & prefix = QString())@

      you can specify your namespace prefix.

      One question: you want only erase "n1" or all the namespace declaration?

      Namespaces are used to avoid naming conflict, so you MUST provide prefix to identify them.

      P.S. In the case you don't have naming conflict problems you can use
      @
      void QXmlStreamWriter::writeDefaultNamespace(const QString & namespaceUri)
      @

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • I Offline
        I Offline
        issam
        wrote on 9 May 2013, 20:52 last edited by
        #3

        thank you mcosta :)

        the method :
        @
        void QXmlStreamWriter::writeDefaultNamespace(const QString & namespaceUri)
        @

        is exactly what i meant! ;)

        http://www.iissam.com/

        1 Reply Last reply
        0

        1/3

        8 May 2013, 15:59

        • Login

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