Hi,
        namespace attributes are a parse time thing. If you want them in 
the output then you have to "namespace normalize". Check out the specs for 
more information (normalizeDocument on document and DOMConfigeration). We 
have not implemented this as yet. There is psydocode on how to do this on 
in the specs. If you do implement it we would gladly accept the code :)

Gareth



On 25 Dec 2002, Colin Paul Adams wrote:

> 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.
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to