[SOLVED]QXmlStreamWrite writing namespace !
-
wrote on 8 May 2013, 15:59 last edited by
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.
-
wrote on 9 May 2013, 10:38 last edited by
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)
@ -
wrote on 9 May 2013, 20:52 last edited by
thank you mcosta :)
the method :
@
void QXmlStreamWriter::writeDefaultNamespace(const QString & namespaceUri)
@is exactly what i meant! ;)
1/3