[ http://nagoya.apache.org/jira/browse/XERCESC-647?page=history ]
Alberto Massari updated XERCESC-647: ------------------------------------ Priority: Major > problem cloning DOMDocument > --------------------------- > > Key: XERCESC-647 > URL: http://nagoya.apache.org/jira/browse/XERCESC-647 > Project: Xerces-C++ > Type: Bug > Components: DOM > Versions: 2.1.0 > Environment: Operating System: All > Platform: Other > Reporter: gareth reakes > Assignee: Xerces-C Developers Mailing List > > 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; -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://nagoya.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]