gareth      2002/11/21 06:13:01

  Modified:    c/src/xercesc/dom DOMElement.hpp
               c/src/xercesc/dom/impl DOMElementImpl.hpp DOMElementImpl.cpp
  Log:
  Implemented setIdAttribute, setIdAttributeNS and setIdAttributeNode from DOM level 3 
core. Patch by myself and Jennifer "Georgina" Schachter.
  
  Revision  Changes    Path
  1.6       +65 -1     xml-xerces/c/src/xercesc/dom/DOMElement.hpp
  
  Index: DOMElement.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/DOMElement.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DOMElement.hpp    4 Nov 2002 15:09:24 -0000       1.5
  +++ DOMElement.hpp    21 Nov 2002 14:13:01 -0000      1.6
  @@ -415,6 +415,70 @@
                                           const XMLCh *localName) const = 0;
       //@}
   
  +
  +    /** @name Functions introduced in DOM Level 3 */
  +    //@{
  +
  +    /**
  +     * Declares the <code>DOMAttr</code> specified by name to be of type ID. If the
  +     * value of the specified <code>DOMAttr</code> is unique then this element node
  +     * can later be retrieved using getElementById on Document. Note, however,
  +     * that this simply affects this node and does not change any grammar that 
  +     * may be in use.
  +     * To specify an <code>DOMAttr</code> by local name and namespace URI, use the 
  +     * setIdAttributeNS method.
  +     * @param name The name of the <code>DOMAttr</code>.
  +     * @exception DOMException
  +     *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  +     *    <br />NOT_FOUND_ERR: Raised if the specified node is not an 
<code>DOMAttr</code> 
  +     * of this element.
  +     *
  +     * <p><b>"Experimental - subject to change"</b></p>
  +     *
  +     * @since DOM Level 3
  +     */
  +    virtual void setIdAttribute(const XMLCh* name) = 0;
  +
  +
  +    /**
  +     * Declares the <code>DOMAttr</code> specified by local name and namespace 
  +     * URI to be of type ID. If the value of the specified <code>DOMAttr</code>
  +     * is unique then this <code>DOMElement</code> node can later be retrieved
  +     * using getElementById on <code>DOMDocument</code>. Note, however, that 
  +     * this simply affects this node and does not change any grammar that may 
  +     * be in use.
  +     * @param namespaceURI The namespace URI of the <code>DOMAttr</code>.
  +     * @param localName The local name of the <code>DOMAttr</code>.
  +     * @exception  DOMException
  +     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  +     *   <br />NOT_FOUND_ERR: Raised if the specified node is not an 
<code>DOMAttr</code> of this element.
  +     *
  +     * <p><b>"Experimental - subject to change"</b></p>
  +     *
  +     * @since DOM Level 3
  +     */
  +    virtual void setIdAttributeNS(const XMLCh* namespaceURI, const XMLCh* 
localName) = 0;
  +
  +
  +
  +    /**
  +     * Declares the <code>DOMAttr</code> specified by node to be of type ID.
  +     * If the value of the specified <code>DOMAttr</code> is unique then this
  +     * <code>DOMElement</code> node can later be retrieved using getElementById 
  +     * on <code>DOMDocument</code>. Note, however, that this simply affects this
  +     * node and does not change any grammar that may be in use.
  +     * @param idAttr The <code>DOMAttr</code> node.
  +     * @exception  DOMException
  +     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  +     *   <br />NOT_FOUND_ERR: Raised if the specified node is not an 
<code>DOMAttr</code> of this element.
  +     *
  +     * <p><b>"Experimental - subject to change"</b></p>
  +     *
  +     * @since DOM Level 3     
  +     */
  +    virtual void setIdAttributeNode(const DOMAttr *idAttr) = 0;
  +    //@}
  +
   };
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.5       +6 -1      xml-xerces/c/src/xercesc/dom/impl/DOMElementImpl.hpp
  
  Index: DOMElementImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMElementImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMElementImpl.hpp        4 Nov 2002 15:07:34 -0000       1.4
  +++ DOMElementImpl.hpp        21 Nov 2002 14:13:01 -0000      1.5
  @@ -138,6 +138,11 @@
       virtual bool              hasAttributeNS(const XMLCh *namespaceURI,
                                                const XMLCh *localName) const;
   
  +    //Introduced in DOM level 3
  +    virtual void setIdAttribute(const XMLCh* name);
  +    virtual void setIdAttributeNS(const XMLCh* namespaceURI, const XMLCh* 
localName);
  +    virtual void setIdAttributeNode(const DOMAttr *idAttr);
  +
       // for handling of default attribute
       virtual DOMAttr*          setDefaultAttributeNode(DOMAttr *newAttr);
       virtual DOMAttr*          setDefaultAttributeNodeNS(DOMAttr *newAttr);
  
  
  
  1.18      +54 -3     xml-xerces/c/src/xercesc/dom/impl/DOMElementImpl.cpp
  
  Index: DOMElementImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMElementImpl.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DOMElementImpl.cpp        4 Nov 2002 15:07:34 -0000       1.17
  +++ DOMElementImpl.cpp        21 Nov 2002 14:13:01 -0000      1.18
  @@ -67,6 +67,7 @@
   #include <xercesc/util/XMLUri.hpp>
   
   #include "DOMAttrMapImpl.hpp"
  +#include "DOMAttrImpl.hpp"
   #include "DOMDocumentImpl.hpp"
   #include "DOMParentNode.hpp"
   #include "DOMStringPool.hpp"
  @@ -183,7 +184,6 @@
       return  (DOMAttr *)fAttributes->getNamedItem(nam);
   };
   
  -#include "stdio.h"
   
   DOMNamedNodeMap *DOMElementImpl::getAttributes() const
   {
  @@ -216,6 +216,7 @@
       if (i >= 0)
       {
           DOMNode *att = fAttributes->removeNamedItemAt(i);
  +        ((DOMAttrImpl *)att)->removeAttrFromIDNodeMap();
           att->release();
       }
   };
  @@ -241,8 +242,10 @@
       if (i >= 0) {
           // If it is in fact the right object, remove it.
           found = fAttributes->item(i);
  -        if (found == oldAttr)
  +        if (found == oldAttr) {
               fAttributes->removeNamedItemAt(i);
  +            ((DOMAttrImpl *)oldAttr)->removeAttrFromIDNodeMap();
  +        }
           else
               throw DOMException(DOMException::NOT_FOUND_ERR, 0);
   
  @@ -271,6 +274,54 @@
       newAttr->setNodeValue(val);
   };
   
  +void DOMElementImpl::setIdAttribute(const XMLCh* name)
  +{
  +    if (fNode.isReadOnly())
  +        throw DOMException(
  +        DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  +
  +    DOMAttr *attr = getAttributeNode(name);
  +
  +    if (!attr) 
  +        throw DOMException(DOMException::NOT_FOUND_ERR, 0);
  +
  +    ((DOMAttrImpl *)attr)->addAttrToIDNodeMap();
  +};
  +
  +void DOMElementImpl::setIdAttributeNS(const XMLCh* namespaceURI, const XMLCh* 
localName) {
  +
  +    if (fNode.isReadOnly())
  +        throw DOMException(
  +        DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  +
  +    DOMAttr *attr = getAttributeNodeNS(namespaceURI, localName);
  +
  +    if (!attr) 
  +        throw DOMException(DOMException::NOT_FOUND_ERR, 0);
  +
  +    ((DOMAttrImpl *)attr)->addAttrToIDNodeMap();
  +
  +};
  +
  +
  +void DOMElementImpl::setIdAttributeNode(const DOMAttr *idAttr) {
  +
  +    if (fNode.isReadOnly())
  +        throw DOMException(
  +        DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);
  +
  +    DOMAttr *attr;
  +    const XMLCh* localName = idAttr->getLocalName();
  +    if (localName)
  +        attr = getAttributeNodeNS(idAttr->getNamespaceURI(), 
idAttr->getLocalName());
  +    else 
  +        attr = getAttributeNode(idAttr->getName());
  +    
  +    if(!attr) 
  +        throw DOMException(DOMException::NOT_FOUND_ERR, 0);
  +
  +    ((DOMAttrImpl *)attr)->addAttrToIDNodeMap();
  +};
   
   
   DOMAttr * DOMElementImpl::setAttributeNode(DOMAttr *newAttr)
  
  
  

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

Reply via email to