You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ar...@locus.apache.org on 2000/04/19 04:26:19 UTC
cvs commit: xml-xerces/c/src/dom DocumentImpl.cpp DocumentImpl.hpp DocumentTypeImpl.cpp DocumentTypeImpl.hpp DOM_Entity.cpp DOM_Entity.hpp DOM_Node.hpp DOM_NodeList.hpp ElementImpl.cpp EntityImpl.cpp EntityImpl.hpp EntityReferenceImpl.cpp EntityReferenceImpl.hpp NamedNodeMapImpl.cpp NamedNodeMapImpl.hpp
aruna1 00/04/18 19:26:19
Modified: c/src/dom DocumentImpl.cpp DocumentImpl.hpp
DocumentTypeImpl.cpp DocumentTypeImpl.hpp
DOM_Entity.cpp DOM_Entity.hpp DOM_Node.hpp
DOM_NodeList.hpp ElementImpl.cpp EntityImpl.cpp
EntityImpl.hpp EntityReferenceImpl.cpp
EntityReferenceImpl.hpp NamedNodeMapImpl.cpp
NamedNodeMapImpl.hpp
Log:
Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
Revision Changes Path
1.20 +28 -15 xml-xerces/c/src/dom/DocumentImpl.cpp
Index: DocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentImpl.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DocumentImpl.cpp 2000/04/17 21:55:04 1.19
+++ DocumentImpl.cpp 2000/04/19 02:26:16 1.20
@@ -55,7 +55,7 @@
*/
/*
- * $Id: DocumentImpl.cpp,v 1.19 2000/04/17 21:55:04 aruna1 Exp $
+ * $Id: DocumentImpl.cpp,v 1.20 2000/04/19 02:26:16 aruna1 Exp $
*/
//
@@ -130,28 +130,41 @@
DocumentTypeImpl *doctype)
: NodeContainer(null)
{
- if (doctype != null && doctype->getOwnerDocument() != null)
- // a doctype can belong to only one DocumentImpl
- throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR, null);
docType=null;
- if (doctype != null) {
- doctype -> setOwnerDocument(this);
- appendChild(doctype);
- doctype -> referenced(); // Warning, tricky! An external (DOM_Node) reference
- // to a node normally bumps the reference count to its
- // document also. But this could not happen when the
- // user created the DOM_DocumentType because there was
- // no document yet. Now we have the document, and
- // the docs ref count must be got back in sync.
- }
+
+ setDocumentType(doctype);
+
docElement=null;
appendChild(createElementNS(fNamespaceURI, qualifiedName)); //root element
namePool = new DStringPool(257);
- identifiers = new RefHashTableOf<PoolElem>(109);
+ identifiers = new RefHashTableOf<PoolElem>(109);
iterators = 0L;
treeWalkers = 0L;
}
+void DocumentImpl::setDocumentType(DocumentTypeImpl *doctype)
+{
+ if (!doctype)
+ return;
+
+ if (doctype->getOwnerDocument() != null)
+ throw DOM_DOMException( //one doctype can belong to only one DocumentImpl
+ DOM_DOMException::WRONG_DOCUMENT_ERR, null);
+
+ doctype -> setOwnerDocument(this);
+ doctype->getEntities()->ownerNode->ownerDocument = this;
+ doctype->getNotations()->ownerNode->ownerDocument = this;
+ doctype -> referenced(); // Warning, tricky! An external (DOM_Node) reference
+ // to a node normally bumps the reference count to its
+ // document also. But this could not happen when the
+ // user created the DOM_DocumentType because there was
+ // no document yet. Now we have the document, and
+ // the docs ref count must be got back in sync.
+
+
+ appendChild(doctype);
+
+}
DocumentImpl::~DocumentImpl()
{
1.13 +4 -1 xml-xerces/c/src/dom/DocumentImpl.hpp
Index: DocumentImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentImpl.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DocumentImpl.hpp 2000/04/06 23:59:23 1.12
+++ DocumentImpl.hpp 2000/04/19 02:26:16 1.13
@@ -58,7 +58,7 @@
*/
/*
- * $Id: DocumentImpl.hpp,v 1.12 2000/04/06 23:59:23 lehors Exp $
+ * $Id: DocumentImpl.hpp,v 1.13 2000/04/19 02:26:16 aruna1 Exp $
*/
//
@@ -120,6 +120,8 @@
DOMString fString;
};
+ void setDocumentType(DocumentTypeImpl *doctype);
+
DocumentTypeImpl *docType;
ElementImpl *docElement;
DStringPool *namePool;
@@ -129,6 +131,7 @@
TreeWalkers *treeWalkers;
friend class NodeIteratorImpl;
friend class TreeWalkerImpl;
+ friend class DOMParser;
public:
DocumentImpl();
1.16 +45 -38 xml-xerces/c/src/dom/DocumentTypeImpl.cpp
Index: DocumentTypeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentTypeImpl.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DocumentTypeImpl.cpp 2000/04/07 20:58:36 1.15
+++ DocumentTypeImpl.cpp 2000/04/19 02:26:16 1.16
@@ -55,7 +55,7 @@
*/
/*
- * $Id: DocumentTypeImpl.cpp,v 1.15 2000/04/07 20:58:36 lehors Exp $
+ * $Id: DocumentTypeImpl.cpp,v 1.16 2000/04/19 02:26:16 aruna1 Exp $
*/
#include "DocumentTypeImpl.hpp"
@@ -68,32 +68,30 @@
DocumentTypeImpl::DocumentTypeImpl(DocumentImpl *ownerDoc,
const DOMString &dtName)
: NodeContainer(ownerDoc),
- publicId(null), systemId(null) //DOM Level 2
+ publicId(null), systemId(null), internalSubset(null) //DOM Level 2
+ , isIntSubsetReading(false)
{
name = dtName.clone();
- entities = new NamedNodeMapImpl(this, null);
- notations= new NamedNodeMapImpl(this, null);
+ entities = new NamedNodeMapImpl(this);
+ notations= new NamedNodeMapImpl(this);
- // NON-DOM
- elements = new NamedNodeMapImpl(this, null);
};
//Introduced in DOM Level 2
DocumentTypeImpl::DocumentTypeImpl(const DOMString &qualifiedName,
const DOMString &fPublicId, const DOMString &fSystemId)
- : NodeContainer(null),
- publicId(fPublicId), systemId(fSystemId)
+ : NodeContainer(null),
+ publicId(fPublicId), systemId(fSystemId), internalSubset(null)
+ , isIntSubsetReading(false)
{
name = qualifiedName.clone();
if (DocumentImpl::indexofQualifiedName(qualifiedName) < 0)
throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
- entities = new NamedNodeMapImpl(this, null);
- notations= new NamedNodeMapImpl(this, null);
+ entities = new NamedNodeMapImpl(this);
+ notations= new NamedNodeMapImpl(this);
- // NON-DOM
- elements = new NamedNodeMapImpl(this, null);
};
@@ -106,12 +104,11 @@
entities = other.entities->cloneMap(this);
notations= other.notations->cloneMap(this);
- // NON-DOM
- elements = other.elements->cloneMap(this);
-
//DOM Level 2
- publicId = other.publicId.clone();
- systemId = other.systemId.clone();
+ publicId = other.publicId.clone();
+ systemId = other.systemId.clone();
+ internalSubset = other.internalSubset.clone();
+ isIntSubsetReading = other.isIntSubsetReading;
};
@@ -128,13 +125,6 @@
notations->removeAll();
NamedNodeMapImpl::removeRef(notations);
}
-
- if (elements != null)
- {
- elements->removeAll();
- NamedNodeMapImpl::removeRef(elements);
- }
-
};
@@ -155,12 +145,6 @@
};
-NamedNodeMapImpl *DocumentTypeImpl::getElements()
-{
- return elements;
-};
-
-
NamedNodeMapImpl *DocumentTypeImpl::getEntities()
{
return entities;
@@ -216,14 +200,36 @@
DOMString DocumentTypeImpl::getInternalSubset()
{
- return null; //not implemented yet
+ return internalSubset;
}
+//set functions
+
+void DocumentTypeImpl::setPublicId(const DOMString& value)
+{
+ if (value == 0)
+ return;
+ publicId = value.clone();
+}
+
+void DocumentTypeImpl::setSystemId(const DOMString& value)
+{
+ if (value == 0)
+ return;
+ systemId = value.clone();
+}
+
+void DocumentTypeImpl::setInternalSubset(const DOMString &value)
+{
+ if (value == 0)
+ return;
+ internalSubset = value.clone();
+}
void DocumentTypeImpl::setOwnerDocument(DocumentImpl *docImpl)
{
ownerDocument = docImpl;
- //Note: ownerDoc of entities, notations and elements remain unchanged
+ //Note: ownerDoc of entities, notations remain unchanged
//The DOM APIs does not require a NamedNodeMap to have an owner document
}
@@ -234,15 +240,16 @@
{
DocumentTypeImpl *doctype;
doctype = new DocumentTypeImpl(name, publicId, systemId);
+ doctype -> internalSubset = internalSubset;
+ doctype -> isIntSubsetReading = false;
doctype -> setOwnerDocument(docImpl);
if (deep) {
- delete doctype -> entities;
- delete doctype -> notations;
- delete doctype -> elements;
- doctype -> entities = entities -> exportNode(doctype);
- doctype -> notations = notations -> exportNode(doctype);
- doctype -> elements = elements -> exportNode(doctype);
+ delete doctype -> entities;
+ delete doctype -> notations;
+ doctype -> entities = entities -> exportNode(doctype);
+ doctype -> notations = notations -> exportNode(doctype);
}
+
return doctype;
}
1.12 +18 -10 xml-xerces/c/src/dom/DocumentTypeImpl.hpp
Index: DocumentTypeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentTypeImpl.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DocumentTypeImpl.hpp 2000/04/06 23:59:23 1.11
+++ DocumentTypeImpl.hpp 2000/04/19 02:26:16 1.12
@@ -58,7 +58,7 @@
*/
/*
- * $Id: DocumentTypeImpl.hpp,v 1.11 2000/04/06 23:59:23 lehors Exp $
+ * $Id: DocumentTypeImpl.hpp,v 1.12 2000/04/19 02:26:16 aruna1 Exp $
*/
//
@@ -79,15 +79,25 @@
class CDOM_EXPORT DocumentTypeImpl: public NodeContainer {
private:
- DOMString name;
- NamedNodeMapImpl *entities;
- NamedNodeMapImpl *notations;
- NamedNodeMapImpl *elements;
+ DOMString name;
+ NamedNodeMapImpl *entities;
+ NamedNodeMapImpl *notations;
+ DOMString publicId;
+ DOMString systemId;
+ DOMString internalSubset;
+
+ bool isIntSubsetReading;
+
+ virtual void setPublicId(const DOMString& value);
+ virtual void setSystemId(const DOMString& value);
+ virtual void setInternalSubset(const DOMString &value);
+
+ friend class DOMParser;
public:
DocumentTypeImpl(DocumentImpl *, const DOMString &);
DocumentTypeImpl(const DOMString &qualifiedName, //DOM Level 2
- const DOMString &publicId, const DOMString &systemId);
+ const DOMString &publicId, const DOMString &systemId);
DocumentTypeImpl(const DocumentTypeImpl &other, bool deep=false);
virtual ~DocumentTypeImpl();
virtual bool isDocumentTypeImpl();
@@ -95,16 +105,14 @@
virtual NodeImpl * cloneNode(bool deep);
virtual DOMString getNodeName();
virtual short getNodeType();
- virtual NamedNodeMapImpl * getElements();
virtual NamedNodeMapImpl * getEntities();
virtual DOMString getName();
virtual NamedNodeMapImpl * getNotations();
virtual void setNodeValue(const DOMString &arg);
virtual void setReadOnly(bool readOnly, bool deep);
-
+
//Introduced in DOM Level 2
- DOMString publicId;
- DOMString systemId;
+
virtual DOMString getPublicId();
virtual DOMString getSystemId();
virtual DOMString getInternalSubset();
1.6 +35 -1 xml-xerces/c/src/dom/DOM_Entity.cpp
Index: DOM_Entity.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Entity.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOM_Entity.cpp 2000/03/11 02:58:38 1.5
+++ DOM_Entity.cpp 2000/04/19 02:26:16 1.6
@@ -56,6 +56,9 @@
/*
* $Log: DOM_Entity.cpp,v $
+ * Revision 1.6 2000/04/19 02:26:16 aruna1
+ * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
+ *
* Revision 1.5 2000/03/11 02:58:38 chchou
* Fix bug # 18, remove set method of readonly attributes
*
@@ -84,7 +87,7 @@
#include "DOM_Entity.hpp"
#include "EntityImpl.hpp"
-
+#include "DOM_NodeList.hpp"
@@ -137,4 +140,35 @@
DOMString DOM_Entity::getNotationName() const
{
return ((EntityImpl *)fImpl)->getNotationName().clone();
+};
+
+DOM_Node DOM_Entity::getFirstChild() const
+{
+ return DOM_Node( ((EntityImpl*)fImpl)->getFirstChild());
+};
+
+DOM_Node DOM_Entity::getLastChild() const
+{
+ return DOM_Node(((EntityImpl*)fImpl)->getLastChild());
+};
+
+DOM_NodeList DOM_Entity::getChildNodes() const
+{
+ return DOM_NodeList((EntityImpl*)fImpl);
+};
+
+bool DOM_Entity::hasChildNodes() const
+{
+ return ((EntityImpl*)fImpl)->hasChildNodes();
+};
+
+DOM_Node DOM_Entity::getPreviousSibling() const
+{
+ return DOM_Node(((EntityImpl*)fImpl)->getPreviousSibling());
+};
+
+
+DOM_Node DOM_Entity::getNextSibling() const
+{
+ return DOM_Node(((EntityImpl*)fImpl)->getNextSibling());
};
1.7 +10 -0 xml-xerces/c/src/dom/DOM_Entity.hpp
Index: DOM_Entity.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Entity.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DOM_Entity.hpp 2000/03/11 02:58:38 1.6
+++ DOM_Entity.hpp 2000/04/19 02:26:16 1.7
@@ -56,6 +56,9 @@
/*
* $Log: DOM_Entity.hpp,v $
+ * Revision 1.7 2000/04/19 02:26:16 aruna1
+ * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
+ *
* Revision 1.6 2000/03/11 02:58:38 chchou
* Fix bug # 18, remove set method of readonly attributes
*
@@ -177,6 +180,13 @@
* For parsed entities, this is <code>null</code>.
*/
DOMString getNotationName() const;
+
+ virtual DOM_Node getFirstChild() const;
+ virtual DOM_Node getLastChild() const;
+ virtual DOM_NodeList getChildNodes() const;
+ virtual bool hasChildNodes() const;
+ virtual DOM_Node getPreviousSibling() const;
+ virtual DOM_Node getNextSibling() const;
//@}
protected:
1.8 +5 -0 xml-xerces/c/src/dom/DOM_Node.hpp
Index: DOM_Node.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Node.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOM_Node.hpp 2000/03/11 02:17:19 1.7
+++ DOM_Node.hpp 2000/04/19 02:26:16 1.8
@@ -56,6 +56,9 @@
/*
* $Log: DOM_Node.hpp,v $
+ * Revision 1.8 2000/04/19 02:26:16 aruna1
+ * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
+ *
* Revision 1.7 2000/03/11 02:17:19 chchou
* Fix bug # 29 to have the spefified flag set correctly for AttrImpl.
*
@@ -652,6 +655,8 @@
friend class DOM_NamedNodeMap;
friend class DOM_NodeList;
friend class DOMParser;
+ friend class DOM_Entity;
+
};
1.9 +7 -0 xml-xerces/c/src/dom/DOM_NodeList.hpp
Index: DOM_NodeList.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_NodeList.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DOM_NodeList.hpp 2000/03/02 19:53:56 1.8
+++ DOM_NodeList.hpp 2000/04/19 02:26:16 1.9
@@ -56,6 +56,9 @@
/*
* $Log: DOM_NodeList.hpp,v $
+ * Revision 1.9 2000/04/19 02:26:16 aruna1
+ * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
+ *
* Revision 1.8 2000/03/02 19:53:56 roddey
* This checkin includes many changes done while waiting for the
* 1.1.0 code to be finished. I can't list them all here, but a list is
@@ -242,6 +245,8 @@
friend class DOM_Document;
friend class DOM_Element;
friend class DOM_Node;
+ friend class DOM_Entity;
+
};
#endif
1.20 +5 -18 xml-xerces/c/src/dom/ElementImpl.cpp
Index: ElementImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/ElementImpl.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ElementImpl.cpp 2000/04/07 20:58:36 1.19
+++ ElementImpl.cpp 2000/04/19 02:26:16 1.20
@@ -55,7 +55,7 @@
*/
/*
- * $Id: ElementImpl.cpp,v 1.19 2000/04/07 20:58:36 lehors Exp $
+ * $Id: ElementImpl.cpp,v 1.20 2000/04/19 02:26:16 aruna1 Exp $
*/
#include "DeepNodeListImpl.hpp"
@@ -73,19 +73,7 @@
: NodeContainer(ownerDoc)
{
name = eName.clone();
-
- // If there is an ElementDefinition, set its Attributes up as
- // shadows behind our own.
- NamedNodeMapImpl *defaultAttrs = null;
- DocumentTypeImpl *doctype = (DocumentTypeImpl*)ownerDocument->getDoctype();
- if (doctype != null)
- {
- ElementDefinitionImpl *eldef=(ElementDefinitionImpl *)
- doctype->getElements()->getNamedItem(this->name);
- if(eldef!=null)
- defaultAttrs=(NamedNodeMapImpl *)eldef->getAttributes();
- }
- attributes = new NamedNodeMapImpl(this, defaultAttrs);
+ attributes = new NamedNodeMapImpl(this);
};
@@ -172,7 +160,7 @@
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
AttrImpl *att = (AttrImpl *) attributes->getNamedItem(nam);
- // Remove it (and let the NamedNodeMap recreate the default, if any)
+ // Remove it
if (att != null)
{
attributes->removeNamedItem(nam);
@@ -191,8 +179,7 @@
AttrImpl *found = (AttrImpl *) attributes->getNamedItem(oldAttr->getName());
- // If it is in fact the right object, remove it (and let the
- // NamedNodeMap recreate the default, if any)
+ // If it is in fact the right object, remove it.
if (found == oldAttr)
{
@@ -307,7 +294,7 @@
AttrImpl *att =
(AttrImpl *) attributes->getNamedItemNS(fNamespaceURI, fLocalName);
- // Remove it (and let the NamedNodeMap recreate the default, if any)
+ // Remove it
if (att != null) {
attributes->removeNamedItemNS(fNamespaceURI, fLocalName);
if (att->nodeRefCount == 0)
1.11 +79 -7 xml-xerces/c/src/dom/EntityImpl.cpp
Index: EntityImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/EntityImpl.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- EntityImpl.cpp 2000/04/07 00:51:45 1.10
+++ EntityImpl.cpp 2000/04/19 02:26:16 1.11
@@ -55,7 +55,7 @@
*/
/*
- * $Id: EntityImpl.cpp,v 1.10 2000/04/07 00:51:45 lehors Exp $
+ * $Id: EntityImpl.cpp,v 1.11 2000/04/19 02:26:16 aruna1 Exp $
*/
#include "DOM_DOMException.hpp"
@@ -64,21 +64,26 @@
EntityImpl::EntityImpl(DocumentImpl *ownerDoc, const DOMString &eName)
- : NodeContainer(ownerDoc)
+ : NodeContainer(ownerDoc),
+ refEntity(0)
+
{
- name = eName.clone();
+ name = eName.clone();
+ readOnly = true;
};
EntityImpl::EntityImpl(const EntityImpl &other, bool deep)
: NodeContainer(other)
{
- name = other.name.clone();
+ name = other.name.clone();
if (deep)
cloneChildren(other);
- publicId = other.publicId.clone();
- systemId = other.systemId.clone();
- notationName = other.notationName.clone();
+ publicId = other.publicId.clone();
+ systemId = other.systemId.clone();
+ notationName = other.notationName.clone();
+ refEntity = other.refEntity;
+ readOnly = true;
};
@@ -149,3 +154,70 @@
systemId = arg;
};
+void EntityImpl::setEntityRef(EntityReferenceImpl* other)
+{
+ refEntity = other;
+}
+
+EntityReferenceImpl* EntityImpl::getEntityRef() const
+{
+ return refEntity;
+}
+
+void EntityImpl::cloneEntityRefTree()
+{
+ //lazily clone the entityRef tree to this entity
+ if (firstChild != 0)
+ return;
+
+ if (!refEntity)
+ return;
+
+ this->cloneChildren(*refEntity);
+}
+
+NodeImpl * EntityImpl::getFirstChild()
+{
+ cloneEntityRefTree();
+ return firstChild;
+};
+
+NodeImpl* EntityImpl::getLastChild()
+{
+ cloneEntityRefTree();
+ return lastChild;
+}
+
+NodeListImpl* EntityImpl::getChildNodes()
+{
+ cloneEntityRefTree();
+ return this;
+
+}
+
+bool EntityImpl::hasChildNodes()
+{
+ cloneEntityRefTree();
+ return firstChild!=null;
+}
+
+NodeImpl* EntityImpl::item(unsigned int index)
+{
+ cloneEntityRefTree();
+ NodeImpl *node = firstChild;
+ for(unsigned int i=0; i<index && node!=null; ++i)
+ node = node->nextSibling;
+ return node;
+}
+
+NodeImpl * EntityImpl::getNextSibling()
+{
+ cloneEntityRefTree();
+ return nextSibling;
+}
+
+NodeImpl* EntityImpl::getPreviousSibling()
+{
+ cloneEntityRefTree();
+ return previousSibling;
+}
1.10 +23 -4 xml-xerces/c/src/dom/EntityImpl.hpp
Index: EntityImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/EntityImpl.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- EntityImpl.hpp 2000/04/06 23:59:23 1.9
+++ EntityImpl.hpp 2000/04/19 02:26:16 1.10
@@ -58,7 +58,7 @@
*/
/*
- * $Id: EntityImpl.hpp,v 1.9 2000/04/06 23:59:23 lehors Exp $
+ * $Id: EntityImpl.hpp,v 1.10 2000/04/19 02:26:16 aruna1 Exp $
*/
//
@@ -72,7 +72,9 @@
#include <util/XercesDefs.hpp>
#include "NodeContainer.hpp"
+#include "EntityReferenceImpl.hpp"
+
class CDOM_EXPORT EntityImpl: public NodeContainer {
private:
DOMString name;
@@ -80,15 +82,20 @@
DOMString systemId;
DOMString notationName;
+ EntityReferenceImpl* refEntity;
+ void cloneEntityRefTree();
+
+ friend class DOMParser;
+
public:
- EntityImpl(DocumentImpl *, const DOMString &eName);
+ EntityImpl(DocumentImpl*, const DOMString &eName);
EntityImpl(const EntityImpl &other, bool deep=false);
virtual ~EntityImpl();
- virtual NodeImpl *cloneNode(bool deep);
+ virtual NodeImpl* cloneNode(bool deep);
virtual DOMString getNodeName();
virtual short getNodeType();
- virtual NodeImpl * getParentNode();
+ virtual NodeImpl* getParentNode();
virtual DOMString getPublicId();
virtual DOMString getSystemId();
virtual DOMString getNotationName();
@@ -96,6 +103,18 @@
virtual void setNotationName(const DOMString &arg);
virtual void setPublicId(const DOMString &arg);
virtual void setSystemId(const DOMString &arg);
+
+ virtual NodeImpl* getFirstChild();
+ virtual NodeImpl* getLastChild();
+ virtual NodeListImpl* getChildNodes();
+ virtual bool hasChildNodes();
+ virtual NodeImpl* item(unsigned int index);
+ virtual NodeImpl* getNextSibling();
+ virtual NodeImpl* getPreviousSibling();
+
+ //DOM Level 2 additions. Non standard functions
+ virtual void setEntityRef(EntityReferenceImpl*);
+ virtual EntityReferenceImpl* getEntityRef() const;
};
#endif
1.12 +1 -94 xml-xerces/c/src/dom/EntityReferenceImpl.cpp
Index: EntityReferenceImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/EntityReferenceImpl.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- EntityReferenceImpl.cpp 2000/04/07 00:51:45 1.11
+++ EntityReferenceImpl.cpp 2000/04/19 02:26:16 1.12
@@ -55,7 +55,7 @@
*/
/*
- * $Id: EntityReferenceImpl.cpp,v 1.11 2000/04/07 00:51:45 lehors Exp $
+ * $Id: EntityReferenceImpl.cpp,v 1.12 2000/04/19 02:26:16 aruna1 Exp $
*/
/**
@@ -153,8 +153,6 @@
NodeImpl *EntityReferenceImpl::cloneNode(bool deep)
{
- // Note #971. Unclear what a shallow clone should mean/do.
- synchronize();
return new EntityReferenceImpl(*this, deep);
}
@@ -171,37 +169,31 @@
/**
-* Perform synchronize() before accessing children.
*
* @return org.w3c.dom.NodeList
*/
NodeListImpl *EntityReferenceImpl::getChildNodes()
{
- synchronize();
return NodeContainer::getChildNodes();
}
/**
-* Perform synchronize() before accessing children.
*
* @return org.w3c.dom.NodeList
*/
NodeImpl *EntityReferenceImpl::getFirstChild()
{
- synchronize();
return NodeContainer::getFirstChild();
}
/**
-* Perform synchronize() before accessing children.
*
* @return org.w3c.dom.NodeList
*/
NodeImpl *EntityReferenceImpl::getLastChild()
{
- synchronize();
return NodeContainer::getLastChild();
}
@@ -265,14 +257,10 @@
/**
-* Perform synchronize() before accessing children.
-* ????? Should just ask the Entity instead!
-* (Though if we discover 0, we can flush)
*
* @return org.w3c.dom.NodeList
*/
NodeImpl *EntityReferenceImpl::item(unsigned int index) {
- synchronize();
return NodeContainer::item(index);
}
@@ -303,84 +291,3 @@
}
-/**
-* EntityReference's children are a reflection of those defined in the
-* named Entity. This method updates them if the Entity is changed.
-* <P>
-* It is unclear what the least-cost resynch mechanism is.
-* If we expect the kids to be shallow, and/or expect changes
-* to the Entity contents to be rare, wiping them all out
-* and recloning is simplest.
-* <P>
-* If we expect them to be deep,
-* it might be better to first decide which kids (if any)
-* persist, and keep the ones (if any) that are unchanged
-* rather than doing all the work of cloning them again.
-* But that latter gets into having to convolve the two child lists,
-* insert new information in the right order (and possibly reorder
-* the existing kids), and a few other complexities that I really
-* don't want to deal with in this implementation.
-* <P>
-* Note that if we decide that we need to update the EntityReference's
-* contents, we have to turn off the readOnly flag temporarily to do so.
-* When we get around to adding multitasking support, this whole method
-* should probably be an atomic operation.
-*
-* @see DocumentTypeImpl
-* @see EntityImpl
-*/
-void EntityReferenceImpl::synchronize()
-{
- DocumentTypeImpl *doctype;
- NamedNodeMapImpl *entities;
- EntityImpl *entDef;
- if (null != (doctype = ownerDocument->getDoctype()) &&
- null != (entities = doctype->getEntities())
- )
- {
- entDef = (EntityImpl *)entities->getNamedItem(name);
-
- // No Entity by this name. If we had a change count, reset it.
- if(null==entDef)
- entityChanges=-1;
-
- // If no kids availalble, wipe any pre-existing children.
- // (See discussion above.)
- // Note that we have to use the superclass to avoid recursion
- // through Synchronize.
- bool oldReadOnly = readOnly;
- readOnly=false;
- if(null==entDef || !entDef->hasChildNodes() || entDef->changes!=entityChanges)
- {
- NodeImpl *kid;
- while ((kid=NodeContainer::getFirstChild()) != null)
- {
- removeChild(kid);
- // Adding and removing a reference will cause the node to
- // be deleted if the reference count is zero, meaning
- // that there are no outside (from the application code) refs
- // to the node. When NodeImpl::removeChild is called from
- // DOM_Node::removeChild, this reference count wiggle happens
- // as a result of returning the removed node, but that doesn't
- // work here, so we do it by hand.
- addRef(kid);
- removeRef(kid);
- }
- }
-
- // If entity's definition changed, clone its kids
- // (See discussion above.)
- if(null!=entDef && entDef->changes!=entityChanges)
- {
- for(NodeImpl *defkid=entDef->getFirstChild();
- defkid!=null; defkid=defkid->getNextSibling())
- {
- NodeImpl *newkid=(NodeImpl *) defkid->cloneNode(true);
- insertBefore(newkid,null);
- newkid->setReadOnly(true,true);
- }
- entityChanges=entDef->changes;
- }
- readOnly=oldReadOnly;
- }
-}
1.11 +1 -2 xml-xerces/c/src/dom/EntityReferenceImpl.hpp
Index: EntityReferenceImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/EntityReferenceImpl.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- EntityReferenceImpl.hpp 2000/04/06 23:59:24 1.10
+++ EntityReferenceImpl.hpp 2000/04/19 02:26:17 1.11
@@ -58,7 +58,7 @@
*/
/*
- * $Id: EntityReferenceImpl.hpp,v 1.10 2000/04/06 23:59:24 lehors Exp $
+ * $Id: EntityReferenceImpl.hpp,v 1.11 2000/04/19 02:26:17 aruna1 Exp $
*/
//
@@ -95,7 +95,6 @@
virtual NodeImpl *item(unsigned int index);
virtual void setNodeValue(const DOMString &);
virtual void setReadOnly(bool readOnly,bool deep);
- virtual void synchronize();
};
#endif
1.13 +20 -195 xml-xerces/c/src/dom/NamedNodeMapImpl.cpp
Index: NamedNodeMapImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/NamedNodeMapImpl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- NamedNodeMapImpl.cpp 2000/04/07 20:58:36 1.12
+++ NamedNodeMapImpl.cpp 2000/04/19 02:26:17 1.13
@@ -55,7 +55,7 @@
*/
/*
- * $Id: NamedNodeMapImpl.cpp,v 1.12 2000/04/07 20:58:36 lehors Exp $
+ * $Id: NamedNodeMapImpl.cpp,v 1.13 2000/04/19 02:26:17 aruna1 Exp $
*/
#include "NamedNodeMapImpl.hpp"
@@ -68,14 +68,10 @@
int NamedNodeMapImpl::gLiveNamedNodeMaps = 0;
int NamedNodeMapImpl::gTotalNamedNodeMaps = 0;
-NamedNodeMapImpl::NamedNodeMapImpl(NodeImpl *ownerNode,NamedNodeMapImpl *defs)
+NamedNodeMapImpl::NamedNodeMapImpl(NodeImpl *ownerNode)
{
this->ownerNode=ownerNode;
- this->defaults=defs;
- addRef(defaults);
this->nodes = null;
- this->changes = 0;
- lastDefaultsChanges = -1;
this->readOnly = false;
this->refCount = 1;
gLiveNamedNodeMaps++;
@@ -95,7 +91,6 @@
nodes = 0;
}
gLiveNamedNodeMaps--;
- removeRef(defaults);
};
@@ -108,7 +103,7 @@
NamedNodeMapImpl *NamedNodeMapImpl::cloneMap(NodeImpl *ownerNode)
{
- NamedNodeMapImpl *newmap = new NamedNodeMapImpl(ownerNode, defaults);
+ NamedNodeMapImpl *newmap = new NamedNodeMapImpl(ownerNode);
if (nodes != null)
{
newmap->nodes = new NodeVector(nodes->size());
@@ -119,9 +114,7 @@
newmap->nodes->addElement(n);
}
}
- newmap->defaults = defaults;
- NamedNodeMapImpl::addRef(defaults);
-
+
return newmap;
};
@@ -159,8 +152,7 @@
int NamedNodeMapImpl::findNamePoint(const DOMString &name)
{
- reconcileDefaults();
-
+
// Binary search
int i=0;
if(nodes!=null)
@@ -204,7 +196,6 @@
unsigned int NamedNodeMapImpl::getLength()
{
- reconcileDefaults();
return (nodes != null) ? nodes->size() : 0;
};
@@ -214,89 +205,17 @@
{
int i=findNamePoint(name);
return (i<0) ? null : (NodeImpl *)(nodes->elementAt(i));
-
- /************
- reconcileDefaults();
-
- // DO BINARY SEARCH?????
- if (nodes != null)
- for (int i = 0; i < nodes.size(); ++i)
- {
- int test = name.compareTo(((Node) (nodes.elementAt(i))).getNodeName());
- if (test == 0)
- return (Node) (nodes.elementAt(i));
- if (test < 0)
- break; // Past the sort point.
- }
- return null;
- **************/
};
NodeImpl * NamedNodeMapImpl::item(unsigned int index)
{
- reconcileDefaults();
return (nodes != null && index < nodes->size()) ?
(NodeImpl *) (nodes->elementAt(index)) : null;
};
-
-void NamedNodeMapImpl::reconcileDefaults()
-{
- if (defaults != null && lastDefaultsChanges != defaults->changes)
- {
- int n = 0, d = 0, nsize = nodes->size(), dsize = defaults->nodes->size();
- AttrImpl * nnode = (nsize == 0) ? null : (AttrImpl *) nodes->elementAt(0);
- AttrImpl * dnode = (dsize == 0) ? null : (AttrImpl *) defaults->nodes->elementAt(0);
- while (n < nsize && d < dsize)
- {
- nnode = (AttrImpl *) nodes->elementAt(n);
- dnode = (AttrImpl *) defaults->nodes->elementAt(d);
- int test = nnode->getNodeName().compareString( dnode->getNodeName());
- // nnode->getNodeName()->compareTo(dnode->getNodeName());
-
- // Same name and a default -- make sure same value
- if (test == 0 && !nnode->getSpecified())
- {
- nodes->setElementAt(dnode, n);
- // Advance over both, since names in sync
- ++n;
- ++d;
- }
-
- // Different name, new default in table; add it
- else if (test > 0)
- {
- nodes->insertElementAt(dnode, n);
- // Now in sync, so advance over both
- ++n;
- ++d;
- }
-
- // Different name, old default here; remove it.
- else if (!nnode->getSpecified())
- {
- nodes->removeElementAt(n);
- // n didn't advance but represents a different element
- }
-
- // Different name, specified; accept it
- else
- ++n;
- }
-
- // If we ran out of local before default, pick up defaults
- while (d < dsize)
- {
- nodes->addElement(defaults->nodes->elementAt(d));
- }
- lastDefaultsChanges = defaults->changes;
- }
-};
-
-
//
// removeNamedItem() - Remove the named item, and return it.
// The caller must arrange for deletion of the
@@ -307,60 +226,22 @@
NodeImpl * NamedNodeMapImpl::removeNamedItem(const DOMString &name)
{
if (readOnly)
- throw DOM_DOMException(
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
+ throw DOM_DOMException(
+ DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
int i=findNamePoint(name);
+ NodeImpl *n = null;
+
if(i<0)
throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
else
{
- NodeImpl * n = (NodeImpl *) (nodes->elementAt(i));
- // If there's a default, add it instead
- NodeImpl * d;
- if (defaults != null && (d = defaults->getNamedItem(name)) != null) {
- if (n->isAttrImpl() && d->isAttrImpl()) { //DOM Level 2
- d = d->cloneNode(true); //copy d and ownerElement of n
- ((AttrImpl*)d)->setOwnerElement(((AttrImpl*)n)->getOwnerElement());
- d->getNamespaceURI() = n->getNamespaceURI() == null ?
- DOMString(null) : n->getNamespaceURI().clone();
- d->getPrefix() = n->getPrefix() == null ?
- DOMString(null) : n->getPrefix().clone();
- d->getLocalName() = n->getLocalName() == null ?
- DOMString(null) : n->getLocalName().clone();
- }
- nodes->setElementAt(d, i);
- } else
- nodes->removeElementAt(i);
+ n = (NodeImpl *) (nodes->elementAt(i));
+ nodes->removeElementAt(i);
- ++changes;
n->ownerNode = null;
- return n;
}
- /************
- // DO BINARY SEARCH?????
- // At least take advantage of sort-order for early stop.
- if (nodes != null)
- {
- for (int i = 0; i < nodes.size(); ++i)
- if (name.equals(((Node) (nodes.elementAt(i))).getNodeName()))
- {
- Node n = (Node) (nodes.elementAt(i));
- // If there's a default, add it instead
- Node d;
- if (defaults != null &&
- (d = defaults.getNamedItem(name)) != null)
- nodes.setElementAt(d, i);
- else
- nodes.removeElementAt(i);
-
- ++changes;
- return n;
- }
- }
- throw DOMExceptionImpl(DOMException.NOT_FOUND_ERR, null);
- **************/
- return null; // just to keep the compiler happy
+ return n;
};
@@ -385,9 +266,6 @@
if(arg->getOwnerDocument()!= ownerNode->ownerDocument)
throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR,null);
- if (arg->ownerNode)
- throw DOM_DOMException(DOM_DOMException::INUSE_ATTRIBUTE_ERR,null);
-
arg->ownerNode = ownerNode;
int i=findNamePoint(arg->getNodeName());
NodeImpl * previous=null;
@@ -403,42 +281,10 @@
nodes=new NodeVector();
nodes->insertElementAt(arg,i);
}
- ++changes;
if (previous != null)
previous->ownerNode = null;
return previous;
-
- /*************************
- // DO BINARY SEARCH?????
- // Insertion-sort is used to maintain list in lexical order. That
- // doesn't matter a great deal in normal operation (minor
- // performance boost in getNamedItem), but improves comparison
- // for reconcileDefault() (and equals(), if we add that.)
- if(nodes==null)
- nodes=new Vector();
- for(int i=0; i<nodes.size();++i)
- {
- int test=arg.getNodeName()
- .compareTo( ((Node)(nodes.elementAt(i))) .getNodeName());
- if(test==0)
- { // Names match
- Node previous=(Node)nodes.elementAt(i);
- nodes.setElementAt(arg,i);
- ++changes;
- return previous;
- }
- else if(test<0)
- { // Mismatch but new goes before old
- nodes.insertElementAt(arg,i);
- ++changes;
- return null;
- }
- }
- nodes.addElement(arg); // Bigger than all, append to end
- ++changes;
- return null;
- ************/
};
@@ -464,9 +310,7 @@
*/
NamedNodeMapImpl *NamedNodeMapImpl::exportNode(NodeImpl *node)
{
- NamedNodeMapImpl *newdefs =
- defaults == null ? null : defaults->exportNode(node);
- NamedNodeMapImpl *newmap = new NamedNodeMapImpl(node, newdefs);
+ NamedNodeMapImpl *newmap = new NamedNodeMapImpl(node);
if (nodes != null)
{
newmap->nodes = new NodeVector(nodes->size());
@@ -484,7 +328,6 @@
int NamedNodeMapImpl::findNamePoint(const DOMString &namespaceURI,
const DOMString &localName)
{
- reconcileDefaults();
if (nodes == null)
return -1;
// Linear search
@@ -519,7 +362,7 @@
//
NodeImpl * NamedNodeMapImpl::setNamedItemNS(NodeImpl *arg)
{
- if(arg->getOwnerDocument() != ownerNode->ownerDocument)
+ if(arg->getOwnerDocument() != ownerNode->ownerDocument)
throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR,null);
if (readOnly)
throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
@@ -538,7 +381,6 @@
nodes=new NodeVector();
nodes->insertElementAt(arg,i);
}
- ++changes;
if (previous != null)
previous->ownerNode = null;
@@ -555,31 +397,14 @@
const DOMString &localName)
{
if (readOnly)
- throw DOM_DOMException(
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
+ throw DOM_DOMException(
+ DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
int i = findNamePoint(namespaceURI, localName);
if (i < 0)
- throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
- NodeImpl * n = nodes -> elementAt(i); //node to be removed or replaced
- //find if n has a default value defined in DTD, if so replace n in nodes
- //by its corresponding default value node, otherwise remove n from nodes
- NodeImpl * d;
- if (defaults != null
- && (d = defaults->getNamedItemNS(namespaceURI, localName)) != null) {
- if (n->isAttrImpl() && d->isAttrImpl()) {
- d = d->cloneNode(true); //copy d and ownerElement of n
- ((AttrImpl*)d)->setOwnerElement(((AttrImpl*)n)->getOwnerElement());
- d->getNamespaceURI() = n->getNamespaceURI() == null ?
- DOMString(null) : n->getNamespaceURI().clone();
- d->getPrefix() = n->getPrefix() == null ?
- DOMString(null) : n->getPrefix().clone();
- d->getLocalName() = n->getLocalName() == null ?
- DOMString(null) : n->getLocalName().clone();
- }
- nodes -> setElementAt(d, i); //replace n in nodes by d
- } else
- nodes -> removeElementAt(i); //remove n from nodes
- ++changes;
+ throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
+ NodeImpl * n = nodes -> elementAt(i);
+
+ nodes -> removeElementAt(i); //remove n from nodes
n -> ownerNode = null;
return n;
}
1.11 +6 -6 xml-xerces/c/src/dom/NamedNodeMapImpl.hpp
Index: NamedNodeMapImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/NamedNodeMapImpl.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NamedNodeMapImpl.hpp 2000/04/07 20:58:36 1.10
+++ NamedNodeMapImpl.hpp 2000/04/19 02:26:17 1.11
@@ -59,6 +59,9 @@
/*
* $Log: NamedNodeMapImpl.hpp,v $
+ * Revision 1.11 2000/04/19 02:26:17 aruna1
+ * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
+ *
* Revision 1.10 2000/04/07 20:58:36 lehors
* fixed all cloneMap so that the ownerNode is correct
*
@@ -121,10 +124,7 @@
class CDOM_EXPORT NamedNodeMapImpl {
private:
NodeVector *nodes;
- NodeImpl *ownerNode; // the node this map belongs to
- NamedNodeMapImpl *defaults;
- int changes;
- int lastDefaultsChanges;
+ NodeImpl *ownerNode; // the node this map belongs to
bool readOnly;
int refCount;
static int gLiveNamedNodeMaps;
@@ -134,11 +134,11 @@
friend class DOM_NamedNodeMap;
friend class DomMemDebug;
friend class ElementImpl;
+ friend class DocumentImpl;
public:
- NamedNodeMapImpl(NodeImpl *ownerNode, NamedNodeMapImpl *defaults);
+ NamedNodeMapImpl(NodeImpl *ownerNode);
- virtual void reconcileDefaults();
virtual ~NamedNodeMapImpl();
virtual NamedNodeMapImpl *cloneMap(NodeImpl *ownerNode);
static void addRef(NamedNodeMapImpl *);