amassari 2004/12/28 09:31:19 Modified: c/src/xercesc/dom/impl DOMDocumentImpl.cpp DOMDocumentTypeImpl.cpp c/src/xercesc/util XMLUni.cpp XMLUni.hpp Log: Export the internal DOMDocumentTypeImpl interface in a safe way, so that DOMDocument::cloneNode can clone the element definitions (bug# 647) Revision Changes Path 1.59 +19 -7 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp Index: DOMDocumentImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- DOMDocumentImpl.cpp 8 Sep 2004 13:55:51 -0000 1.58 +++ DOMDocumentImpl.cpp 28 Dec 2004 17:31:19 -0000 1.59 @@ -1016,7 +1016,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); @@ -1111,11 +1111,23 @@ ((DOMDocumentTypeImpl *)newdoctype)->setInternalSubset(intSubset); } - // 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. ????? + // detect if the DTD being copied is our own implementation, and use the provided methods + try + { + DOMDocumentTypeImpl* docTypeImpl=(DOMDocumentTypeImpl*)(srcdoctype->getInterface(XMLUni::fgXercescInterfaceDOMDocumentTypeImpl)); + if(docTypeImpl) + { + smap = docTypeImpl->getElements(); + tmap = ((DOMDocumentTypeImpl *)newdoctype)->getElements(); + if (smap != 0) { + for(XMLSize_t i = 0; i < smap->getLength(); i++) { + tmap->setNamedItem(importNode(smap->item(i), true, true)); + } + } + } + } catch(DOMException&) { + } + newnode = newdoctype; } break; 1.27 +8 -2 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp Index: DOMDocumentTypeImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- DOMDocumentTypeImpl.cpp 8 Sep 2004 13:55:51 -0000 1.26 +++ DOMDocumentTypeImpl.cpp 28 Dec 2004 17:31:19 -0000 1.27 @@ -439,7 +439,6 @@ const XMLCh* DOMDocumentTypeImpl::lookupNamespacePrefix(const XMLCh* namespaceURI, bool useDefault) const {return fNode.lookupNamespacePrefix(namespaceURI, useDefault); } bool DOMDocumentTypeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const {return fNode.isDefaultNamespace(namespaceURI); } const XMLCh* DOMDocumentTypeImpl::lookupNamespaceURI(const XMLCh* prefix) const {return fNode.lookupNamespaceURI(prefix); } - DOMNode* DOMDocumentTypeImpl::getInterface(const XMLCh* feature) {return fNode.getInterface(feature); } bool DOMDocumentTypeImpl::isEqualNode(const DOMNode* arg) const @@ -532,6 +531,13 @@ } return fParent.isEqualNode(arg); +} + +DOMNode * DOMDocumentTypeImpl::getInterface(const XMLCh* feature) +{ + if(XMLString::equals(feature, XMLUni::fgXercescInterfaceDOMDocumentTypeImpl)) + return (DOMNode*)(DOMDocumentTypeImpl*)this; + return fNode.getInterface(feature); } XERCES_CPP_NAMESPACE_END 1.47 +8 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp Index: XMLUni.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- XMLUni.cpp 7 Dec 2004 19:45:43 -0000 1.46 +++ XMLUni.cpp 28 Dec 2004 17:31:19 -0000 1.47 @@ -1464,6 +1464,13 @@ chLatin_o, chNull }; +const XMLCh XMLUni::fgXercescInterfaceDOMDocumentTypeImpl[] = +{ + chLatin_D, chLatin_O, chLatin_M, chLatin_D, chLatin_o, chLatin_c, chLatin_u, + chLatin_m, chLatin_e, chLatin_n, chLatin_t, chLatin_T, chLatin_y, chLatin_p, + chLatin_e, chLatin_I, chLatin_m, chLatin_p, chLatin_l, chNull +}; + // en_US const char XMLUni::fgXercescDefaultLocale[] = "en_US"; 1.42 +2 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp Index: XMLUni.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- XMLUni.hpp 7 Dec 2004 19:45:43 -0000 1.41 +++ XMLUni.hpp 28 Dec 2004 17:31:19 -0000 1.42 @@ -262,6 +262,7 @@ // Private interface names static const XMLCh fgXercescInterfacePSVITypeInfo[]; + static const XMLCh fgXercescInterfaceDOMDocumentTypeImpl[]; // Locale static const char fgXercescDefaultLocale[];
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]