In the following code:
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <iostream>
main ()
{
//using namespace XERCES_CPP_NAMESPACE;
XMLPlatformUtils::Initialize ();
XMLCh ls[100];
XMLString::transcode ("LS",ls,99);
DOMImplementation * impl = DOMImplementationRegistry::getDOMImplementation (ls);
XMLCh namespace_uri[400];
XMLString::transcode ("urn:colina.demon.co.uk:test-one",namespace_uri,199);
XMLCh element_name[100];
XMLString::transcode ("test:fred",element_name,199);
DOMDocument * document = impl->createDocument(namespace_uri, element_name, 0);
// only if the following code is executed will the output contain xmlns attributes:
/*
XMLCh xmlns_namespace_uri[400];
XMLString::transcode ("http://www.w3.org/2000/xmlns/",xmlns_namespace_uri,199);
XMLCh attribute_name[100];
XMLString::transcode ("xmlns:test",attribute_name,99);
DOMElement * document_element = document->getDocumentElement ();
document_element->setAttributeNS (xmlns_namespace_uri, attribute_name,
namespace_uri);
*/
// now serialise
DOMWriter * writer = static_cast<DOMImplementation*>(impl)->createDOMWriter ();
XMLFormatTarget * my_target = new StdOutFormatTarget ();
writer->writeNode (my_target, *document);
}
the DOMWriter does NOT write out any xmlns attributes, unless the
commented-out section is un-commented. Is this a bug in
createDocument/createElementNS, or am I missing something?
Same problem in both 2.1.0 and the nightly build ofNovember 28th.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]