Hello folks,

I've a problem to create a xml struct like XMPP. XMPP has a lot of
namspaces and prefixes, so xercesc ist a good choice for creating and
parsing XMPP snippets.

I'll create a XML like this:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<stream:stream xmlns:stream="http://etherx.jabber.org/streams";>
        <stream:error>
                <error xmlns="urn:ietf:params:xml:ns:xmpp-streams"/>
        </stream:error>
</stream:stream>

The stream:stream tag and namespace is no problem, this will do the
Document constructor.

But the stream:error and the namspace at the error element is tricky.
Here some code witch fail:

### snip ###
DOMElement* stream_error_elem = doc->createElement(X("error"));
stream_error_elem->setPrefix("X("stream"));
### snap ###

These construct will fail with an error: attempt is made to create or
change an object in a way which is incorrect with respect to
namespaces

I don't understood this...

Now i create my element with:

### snip ###
DOMElement* stream_error_elem = doc->createElement(X("strem:error"));
### snap ###

This works fine.

Can someone tell me why setPrefix is the wrong way?

Thanks a lot

so long
jd

Reply via email to