diff --git a/src/dom/DOM_Node.cpp b/src/dom/DOM_Node.cpp
index 95eab62438f475cd0ee177566ae3dc68f7f8f4e7..efe3232f0450d9e95242e50cf630a55a064b3e7b 100644
--- a/src/dom/DOM_Node.cpp
+++ b/src/dom/DOM_Node.cpp
@@ -56,6 +56,10 @@
 
 /*
  * $Log$
+ * Revision 1.7  2000/06/14 21:08:07  andyh
+ * DOM attribute/named nodemaps: Fix a couple of null ptr problems.
+ * Joe Polastre.
+ *
  * Revision 1.6  2000/06/07 22:49:40  andyh
  * Memory usage reduction:  DOM NamedNodeMaps for attributes are allocated
  * only for elements that actually have attributes.  By Joe Polastre.
@@ -243,7 +247,10 @@ void          *DOM_Node::getUserData() const
   
 DOM_NamedNodeMap DOM_Node::getAttributes() const
 {
-    return (fImpl->getAttributes() == null) ? DOM_NamedNodeMap(fImpl) : DOM_NamedNodeMap(fImpl->getAttributes());
+	if (getNodeType() == ELEMENT_NODE)
+		return (fImpl->getAttributes() == null) ? DOM_NamedNodeMap(fImpl) : DOM_NamedNodeMap(fImpl->getAttributes());
+	else
+		return DOM_NamedNodeMap();
 };
 
   
diff --git a/src/dom/ElementImpl.cpp b/src/dom/ElementImpl.cpp
index de3ff2eb1651fa1fa9ab63b4ddd019f235e0296e..e8dfdd6e64cb9c434beed5138a47d6a3a18632a6 100644
--- a/src/dom/ElementImpl.cpp
+++ b/src/dom/ElementImpl.cpp
@@ -129,7 +129,11 @@ short ElementImpl::getNodeType() {
 DOMString ElementImpl::getAttribute(const DOMString &nam)
 {
     static DOMString *emptyString = 0;
-    AttrImpl * attr=(AttrImpl *)(attributes->getNamedItem(nam));
+    AttrImpl * attr=null;
+
+    if (attributes != null)
+	attr=(AttrImpl *)(attributes->getNamedItem(nam));
+
     return (attr==null) ? DStringPool::getStaticString("", &emptyString) : attr->getValue();
 };
 
@@ -171,14 +175,17 @@ void ElementImpl::removeAttribute(const DOMString &nam)
     if (readOnly())
         throw DOM_DOMException(
         DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
-    
-    AttrImpl *att = (AttrImpl *) attributes->getNamedItem(nam);
-    // Remove it
-    if (att != null)
-    {
-        attributes->removeNamedItem(nam);
-        if (att->nodeRefCount == 0)
-            NodeImpl::deleteIf(att);
+
+    if (attributes != null)
+    {    
+    	AttrImpl *att = (AttrImpl *) attributes->getNamedItem(nam);
+    	// Remove it
+    	if (att != null)
+    	{
+    	    attributes->removeNamedItem(nam);
+    	    if (att->nodeRefCount == 0)
+    	        NodeImpl::deleteIf(att);
+    	}
     }
 };
 
@@ -190,17 +197,20 @@ AttrImpl *ElementImpl::removeAttributeNode(AttrImpl *oldAttr)
         throw DOM_DOMException(
         DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
     
-    AttrImpl *found = (AttrImpl *) attributes->getNamedItem(oldAttr->getName());
+    if (attributes != null)
+    {
+	    AttrImpl *found = (AttrImpl *) attributes->getNamedItem(oldAttr->getName());
     
-    // If it is in fact the right object, remove it.
+	    // If it is in fact the right object, remove it.
     
-    if (found == oldAttr)
-    {
-        attributes->removeNamedItem(oldAttr->getName());
-        return found;
-    }
-    else
-        throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
+	    if (found == oldAttr)
+	    {
+	        attributes->removeNamedItem(oldAttr->getName());
+	        return found;
+	    }
+	    else
+	        throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
+	}
 	return null;	// just to keep the compiler happy
 };
 
@@ -310,15 +320,18 @@ void ElementImpl::removeAttributeNS(const DOMString &fNamespaceURI,
     if (readOnly())
         throw DOM_DOMException(
 	    DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
-    
-    AttrImpl *att =
-      (AttrImpl *) attributes->getNamedItemNS(fNamespaceURI, fLocalName);
-    // Remove it 
-    if (att != null) {
-        attributes->removeNamedItemNS(fNamespaceURI, fLocalName);
-        if (att->nodeRefCount == 0)
-            NodeImpl::deleteIf(att);
-    }
+ 
+    if (attributes != null)
+    {   
+		AttrImpl *att =
+		  (AttrImpl *) attributes->getNamedItemNS(fNamespaceURI, fLocalName);
+		// Remove it 
+		if (att != null) {
+			attributes->removeNamedItemNS(fNamespaceURI, fLocalName);
+			if (att->nodeRefCount == 0)
+				NodeImpl::deleteIf(att);
+		}
+	}
 }