Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, March 2008
QXmlStreamWriter : possibility define declare a namespace into the the next element.


Message 1 in thread

Hi !

According to the doc of Qt4.4 the function

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

process the following way:

"If writeStartElement() or writeEmptyElement() was called, the declaration
applies to the current element; otherwise it applies to the next child
element."

~~~~~~

It is NOT possible to define a namespace with a specific prefix for the
current Element if the document is already started.

~~~~~~

In the exemple below, it would be better to have the namespace "kaolin"
declared into the Element "Response" like that : "<kaolin:Response
xmlns:kaolin="urn.kaolin">".

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope";
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding";>
  <soap:Body xmlns:kaolin="urn:kaolin">
    <kaolin:Response>
      <kaolin:Message>Test method worked</kaolin:Message>
    </kaolin:Response>
  </soap:Body>
</soap:Envelope>

~~~~~~

What about having a function :

void
QXmlStreamWriter::writeElementNamespace ( const QString & name, const
QString & namespaceUri, const QString & prefix = QString() );

XML stream system would know the namespace at the time it writes the
Element.
And it is NOT needed anymore to have it declared previously.

( If the namespace URI is alreay declared, prefix is ignored )

~~~~~~

Or another :

void
QXmlStreamWriter::writeNamespace ( const QString & namespaceUri, const
QString & prefix = QString(), bool intoNext = false );