Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-647

problem cloning DOMDocument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.2.0
    • DOM
    • None
    • Operating System: All
      Platform: Other
    • 13199

    Description

      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;

      • if (attr -> getSpecified())
        Unknown macro: { // 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)
        Unknown macro: {+ 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;

      Attachments

        Activity

          People

            Unassigned Unassigned
            gareth@decisionsoft.com gareth reakes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: