DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13199>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13199 problem cloning DOMDocument Summary: problem cloning DOMDocument Product: Xerces-C++ Version: 2.1.0 Platform: Other OS/Version: All Status: NEW Severity: Normal Priority: Other Component: DOM AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] When cloning a DOMDocument we do not clone the elements that provide default attribute information. This causes 2 problems. First is that any elements that are then cloned do not get the default attributes because these are created in the constructors by asking the DOMDocument. Second is that deafult attributes do not get placed back on the elemtents when they are deleted. This was raised on the list and the feedback was positive for the change. Patch is for cvs Index: dom/impl/DOMDocumentImpl.cpp =================================================================== RCS file: /home/cvspublic/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp,v retrieving revision 1.26 diff -u -r1.26 DOMDocumentImpl.cpp --- dom/impl/DOMDocumentImpl.cpp 27 Sep 2002 19:18:40 -0000 1.26 +++ dom/impl/DOMDocumentImpl.cpp 2 Oct 2002 12:03:22 -0000 @@ -971,7 +971,7 @@ for(XMLSize_t i=0;i<srcattr->getLength();++i) { DOMAttr *attr = (DOMAttr *) srcattr->item(i); - if (attr -> getSpecified()) { // not a default attribute + if (attr -> getSpecified() || cloningDoc) { // not a default attribute or we are in the process of cloning the elements from inside a DOMDocumentType DOMAttr *nattr = (DOMAttr *) importNode(attr, true, false); if (attr -> getLocalName() == 0) newelement->setAttributeNode(nattr); @@ -1061,11 +1061,17 @@ tmap->setNamedItem(importNode(smap->item(i), true, false)); } } - // NOTE: At this time, the DOM definition of DocumentType - // doesn't cover Elements and their Attributes. domimpl's - // extentions in that area will not be preserved, even if - // copying from domimpl to domimpl. We could special-case - // that here. Arguably we should. Consider. ????? + + smap = ((DOMDocumentTypeImpl *)srcdoctype)->getElements(); + tmap = ((DOMDocumentTypeImpl *)newdoctype)->getElements(); + if (smap != 0) { + for(XMLSize_t i = 0; i < smap->getLength(); i++) { + + //note the true setting for clone doc, this is so default attrs get copied accross in the next call to this method + tmap->setNamedItem(importNode(smap->item(i), true, true)); + } + } + newnode = newdoctype; } break; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
