Hi, xerces-developers,

(didn't find an entry point for xerces-c bug reports on 
http://issues.apache.org/bugzilla/enter_bug.cgi, so I report it here)

Creating a new DOMDocument, supplying any namespace-argument different 
than zero, results in DOM-tree/serialization inconsistencies (see 
examples below).

With xml-parsed DOMDocuments, the document's root element contains the 
xmlns-attribute, if given in the xml-file. In contrary, newly created 
DOMDocuments' root elements never contain the xmlns-attribute, 
although a namespace-argument was given to createDocument, but the 
DOMWriter-serialized output shows the xmlns-attribute, as expected. 
This is inconsistent.

Even worse: adding the xmlns-attribute manually to the root element 
after creation, the serialized output shows the xmlns-attribute 
twice, which is illegal with respect to the XML specification.

The only workaround would be to always set the namespace-argument of 
DOMImplementationLS::createDocument to zero and to add the 
xmlns-attribute manually.

Here's some examples that show the spot:

implementation: valid DOMImplementationLS-object-pointer
writer:         valid DOMWriter-object-pointer
namespace:      XMLCh-representation of a namespace name
root_name:      XMLCh-representation of the root element name
xmlns:          XMLCh-representation of "xmlns"

CASE 1:

DOMDocument *doc = 
        implementation->createDocument(namespace, root_name, 0);
DOMElement *elem = doc->getDocumentElement();
XMLCh *serialized = writer->serialize(elem);

o elem contains no attributes (e.g. elem->hasAttributes() returns 
false resp. elem->getAttributes() is empty)
o serialized shows the provided xmlns-attribute

CASE 2:

DOMDocument *doc = 
        implementation->createDocument(namespace, root_name, 0);
DOMElement *elem = doc->getDocumentElement();
elem->setAttribute(xmlns, namespace);
XMLCh *serialized = writer->serialize(elem);

o elem contains the xmlns-attributes
o serialized shows the xmlns-attribute TWICE, which is invalid!

WORKAROUND:

DOMDocument *doc = 
        implementation->createDocument(0, root_name, 0);
DOMElement *elem = doc->getDocumentElement();
elem->setAttribute(xmlns, namespace);
XMLCh *serialized = writer->serialize(elem);

Regards,
                        Axel

-- 
Humboldt-University of Berlin
Institut for Computer Science
Signal-Processing and Pattern-Recognition
Dipl.-Inf. Axel Weiss
Rudower Chaussee 25
D 12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

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

Reply via email to