You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/01/05 02:16:11 UTC
cvs commit: xml-xerces/c/src/parsers DOMParser.cpp
andyh 00/01/04 17:16:11
Modified: c/src/dom DOM_Attr.hpp DOM_CDATASection.hpp DOM_Comment.hpp
DOM_DOMException.hpp DOM_DOMImplementation.cpp
DOM_DOMImplementation.hpp DOM_Document.cpp
DOM_Document.hpp DOM_DocumentType.hpp
DOM_Element.cpp DOM_Element.hpp DOM_Entity.hpp
DOM_EntityReference.hpp DOM_NamedNodeMap.cpp
DOM_NamedNodeMap.hpp DOM_Node.cpp DOM_Node.hpp
DOM_NodeList.hpp DOM_Notation.hpp
DOM_ProcessingInstruction.hpp DOM_Text.hpp
DocumentImpl.cpp DocumentImpl.hpp ElementImpl.cpp
ElementImpl.hpp NamedNodeMapImpl.cpp
NamedNodeMapImpl.hpp NodeImpl.cpp NodeImpl.hpp
c/src/parsers DOMParser.cpp
Log:
DOM Level 2 core, namespace support added.
Revision Changes Path
1.2 +4 -1 xml-xerces/c/src/dom/DOM_Attr.hpp
Index: DOM_Attr.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Attr.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Attr.hpp 1999/11/09 01:08:48 1.1
+++ DOM_Attr.hpp 2000/01/05 01:16:06 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Attr.hpp,v $
- * Revision 1.1 1999/11/09 01:08:48 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:06 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:48 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:13 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -209,7 +212,7 @@
DOM_Element getOwnerElement() const;
//@}
-private:
+protected:
DOM_Attr(AttrImpl *attr);
friend class DOM_Element;
1.2 +4 -1 xml-xerces/c/src/dom/DOM_CDATASection.hpp
Index: DOM_CDATASection.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_CDATASection.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_CDATASection.hpp 1999/11/09 01:08:49 1.1
+++ DOM_CDATASection.hpp 2000/01/05 01:16:06 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_CDATASection.hpp,v $
- * Revision 1.1 1999/11/09 01:08:49 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:06 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:49 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:13 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -141,7 +144,7 @@
//@}
-private:
+protected:
DOM_CDATASection(CDATASectionImpl *);
friend class DOM_Document;
1.2 +4 -1 xml-xerces/c/src/dom/DOM_Comment.hpp
Index: DOM_Comment.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Comment.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Comment.hpp 1999/11/09 01:08:50 1.1
+++ DOM_Comment.hpp 2000/01/05 01:16:06 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Comment.hpp,v $
- * Revision 1.1 1999/11/09 01:08:50 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:06 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:50 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:14 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -138,7 +141,7 @@
~DOM_Comment();
//@}
-private:
+protected:
DOM_Comment(CommentImpl *comment);
friend class DOM_Document;
1.2 +8 -1 xml-xerces/c/src/dom/DOM_DOMException.hpp
Index: DOM_DOMException.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_DOMException.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_DOMException.hpp 1999/11/09 01:08:53 1.1
+++ DOM_DOMException.hpp 2000/01/05 01:16:06 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_DOMException.hpp,v $
- * Revision 1.1 1999/11/09 01:08:53 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:06 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:53 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:14 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -101,7 +104,11 @@
NOT_FOUND_ERR = 8,
NOT_SUPPORTED_ERR = 9,
INUSE_ATTRIBUTE_ERR = 10,
- INVALID_STATE_ERR = 11
+ INVALID_STATE_ERR = 11,
+ SYNTAX_ERR = 12,
+ INVALID_MODIFICATION_ERR = 13,
+ NAMESPACE_ERR = 14,
+ INVALID_ACCESS_ERR = 15
};
public:
/** @name Constructors and assignment operator */
1.3 +5 -4 xml-xerces/c/src/dom/DOM_DOMImplementation.cpp
Index: DOM_DOMImplementation.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_DOMImplementation.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_DOMImplementation.cpp 1999/11/30 21:16:25 1.2
+++ DOM_DOMImplementation.cpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_DOMImplementation.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/11/30 21:16:25 roddey
* Changes to add the transcode() method to DOMString, which returns a transcoded
* version (to local code page) of the DOM string contents. And I changed all of the
@@ -159,10 +162,6 @@
const DOMString &publicID, const DOMString &systemID,
const DOMString &internalSubset)
{
- if (!DocumentImpl::isXMLName(qualifiedName))
- throw DOM_DOMException(
- DOM_DOMException::INVALID_CHARACTER_ERR, null);
-
return DOM_DocumentType(new DocumentTypeImpl(qualifiedName, publicID, systemID, internalSubset));
}
1.2 +9 -5 xml-xerces/c/src/dom/DOM_DOMImplementation.hpp
Index: DOM_DOMImplementation.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_DOMImplementation.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_DOMImplementation.hpp 1999/11/09 01:08:57 1.1
+++ DOM_DOMImplementation.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_DOMImplementation.hpp,v $
- * Revision 1.1 1999/11/09 01:08:57 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:57 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:15 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -118,8 +121,9 @@
/**
* Test if the DOM implementation implements a specific feature.
*
- * @param feature The package name of the feature to test. This
- * implemenation supports XML, but does not support HTML.
+ * @param feature The string of the feature to test (case-insensitive). The legal
+ * values are defined throughout this specification. The string must be
+ * an <EM>XML name</EM> (see also Compliance).
* @param version This is the version number of the package name to test.
* In Level 1, this is the string "1.0". If the version is not specified,
* supporting any version of the feature will cause the method to return
@@ -144,11 +148,11 @@
/** @name Functions introduced in DOM Level 2. */
//@{
/**
- * Creates an empty <code>DocumentType</code> node.
+ * Creates an empty <code>DOM_DocumentType</code> node.
* Entity declarations and notations are not made available.
* Entity reference expansions and default attribute additions
* do not occur. It is expected that a future version of the DOM
- * will provide a way for populating a <code>DocumentType</code>.
+ * will provide a way for populating a <code>DOM_DocumentType</code>.
* @param qualifiedName The <em>qualified name</em>
* of the document type to be created.
* @param publicID The external subset public identifier.
@@ -162,7 +166,7 @@
const DOMString &internalSubset);
/**
- * Creates an XML <code>Document</code> object of the specified type
+ * Creates an XML <code>DOM_Document</code> object of the specified type
* with its document element.
* @param namespaceURI The <em>namespace URI</em> of
* the document element to create, or <code>null</code>.
1.3 +5 -2 xml-xerces/c/src/dom/DOM_Document.cpp
Index: DOM_Document.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Document.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_Document.cpp 1999/11/23 01:48:14 1.2
+++ DOM_Document.cpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_Document.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/11/23 01:48:14 rahulj
* Changed 0L to 0. CC under HPUX is happy now.
*
@@ -229,9 +232,9 @@
//Introduced in DOM Level 2
-DOM_Node DOM_Document::importNode(const DOM_Node &source, bool deep)
+DOM_Node DOM_Document::importNode(const DOM_Node &importedNode, bool deep)
{
- return DOM_Node(((DocumentImpl *)fImpl)->importNode(source.fImpl, deep));
+ return DOM_Node(((DocumentImpl *)fImpl)->importNode(importedNode.fImpl, deep));
};
1.3 +77 -31 xml-xerces/c/src/dom/DOM_Document.hpp
Index: DOM_Document.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Document.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_Document.hpp 1999/12/21 07:47:06 1.2
+++ DOM_Document.hpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_Document.hpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/21 07:47:06 robweir
* Patches to support Xalan, where we need to create a
* "special" DOM with subclassed Nodes.
@@ -210,7 +213,7 @@
* @return A <code>DOM_Element</code> that reference the new element.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * invalid character.
+ * illegal character.
*/
DOM_Element createElement(const DOMString &tagName);
@@ -225,7 +228,11 @@
*
* @param tagName The name of the element type to instantiate, as
* a null-terminated unicode string.
- * @return A <code>DOM_Element</code> that reference the new element.
+ * @return A new <CODE>DOM_Element</CODE>
+ * object with the <CODE>nodeName</CODE> attribute set to
+ * <CODE>tagName</CODE>, and <CODE>localName</CODE>,
+ * <CODE>prefix</CODE>, and <CODE>namespaceURI</CODE> set to
+ * <CODE>null</CODE>.
*/
DOM_Element createElement(const XMLCh *tagName);
@@ -298,7 +305,7 @@
* @return A <code>DOM_ProcessingInstruction</code> that references the newly
* created PI node.
* @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if an invalid character is specified.
+ * INVALID_CHARACTER_ERR: Raised if an illegal character is specified.
*/
DOM_ProcessingInstruction createProcessingInstruction(const DOMString &target,
const DOMString &data);
@@ -311,11 +318,14 @@
* <code>Attr</code> instance can then be attached to an Element
* using the <code>DOMElement::setAttribute()</code> method.
* @param name The name of the attribute.
- * @return A <code>DOM_Attr</code> that references the newly
- * created Attr.
+ * @return A new <CODE>DOM_Attr</CODE>
+ * object with the <CODE>nodeName</CODE> attribute set to
+ * <CODE>name</CODE>, and <CODE>localName</CODE>, <CODE>prefix</CODE>,
+ * and <CODE>namespaceURI</CODE> set to
+ * <CODE>null</CODE>.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * invalid character.
+ * illegal character.
*/
DOM_Attr createAttribute(const DOMString &name);
@@ -328,7 +338,7 @@
* created EntityReference node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * invalid character.
+ * illegal character.
*/
DOM_EntityReference createEntityReference(const DOMString &name);
@@ -405,44 +415,72 @@
//@{
/**
- * Import a copy of a node from another document into this document.
- * The source node, which may belong to a different document, is
- * copied, with the copy belonging to this document. The copy
- * is not placed into the document (the parent node is null).
- *
- * @param deep If true, recursively import the subtree under the specified
- * node; if flase, import only the node itself (and its attributes, if
- * if is a DOM_Element.
- * @return The newly created copy of the source node, belonging to this document
- */
- DOM_Node importNode(const DOM_Node &source, bool deep);
+ * Imports a node from another document to this document.
+ * The returned node has no parent (<CODE>parentNode</CODE> is
+ * <CODE>null</CODE>). The source node is not altered or removed from the
+ * original document; this method creates a new copy of the source
+ * node.<BR>For all nodes, importing a node creates a node object owned by
+ * the importing document, with attribute values identical to the source
+ * node's <CODE>nodeName</CODE> and <CODE>nodeType</CODE>, plus the
+ * attributes related to namespaces (prefix and namespaces URI).
+ *
+ * @param importedNode The node to import.
+ * @param deep If <CODE>true</CODE>, recursively import the subtree under the
+ * specified node; if <CODE>false</CODE>, import only the node itself,
+ * as explained above. This does not apply to <CODE>Attr</CODE>,
+ * <CODE>EntityReference</CODE>, and <CODE>Notation</CODE> nodes.
+ * @return The imported node that belongs to this <CODE>Document</CODE>.
+ * @exception DOMException
+ * NOT_SUPPORTED_ERR: Raised if the type of node being imported is
+ * not supported.
+ */
+ DOM_Node importNode(const DOM_Node &importedNode, bool deep);
/**
- * Creates an element of the given qualified name and namespace URI.
+ * Creates an element of the given qualified name and
+ * namespace URI. If the given <CODE>namespaceURI</CODE> is <CODE>null</CODE>
+ * or an empty string and the <CODE>qualifiedName</CODE> has a prefix that is
+ * "xml", the created element is bound to the predefined namespace
+ * "http://www.w3.org/XML/1998/namespace".
* @param namespaceURI The <em>namespace URI</em> of
- * the element to create. When it is <code>null</code> or an empty
- * string, this method behaves like <code>createElement</code>.
+ * the element to create.
* @param qualifiedName The <em>qualified name</em>
* of the element type to instantiate.
* @return A new <code>DOM_Element</code> object.
* @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains
- * an invalid character.
+ * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
+ * an illegal character.
+ * <br>
+ * NAMESPACE_ERR: Raised if the <CODE>qualifiedName</CODE> is
+ * malformed, or if the <CODE>qualifiedName</CODE> has a prefix that is
+ * "xml" and the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE>
+ * nor an empty string nor "http://www.w3.org/XML/1998/namespace".
*/
DOM_Element createElementNS(const DOMString &namespaceURI,
const DOMString &qualifiedName);
/**
- * Creates an attribute of the given qualified name and namespace URI.
+ * Creates an attribute of the given qualified name and
+ * namespace URI. If the given <CODE>namespaceURI</CODE> is <CODE>null</CODE>
+ * or an empty string and the <CODE>qualifiedName</CODE> has a prefix that is
+ * "xml", the created attribute is bound to the predefined namespace
+ * "http://www.w3.org/XML/1998/namespace".
* @param namespaceURI The <em>namespace URI</em> of
- * the attribute to create. When it is <code>null</code> or an empty
- * string, this method behaves like <code>createAttribute</code>.
+ * the attribute to create.
* @param qualifiedName The <em>qualified name</em>
* of the attribute type to instantiate.
* @return A new <code>DOM_Attr</code> object.
* @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains
- * an invalid character.
+ * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
+ * an illegal character.
+ * <br>
+ * NAMESPACE_ERR: Raised if the <CODE>qualifiedName</CODE> is
+ * malformed, if the <CODE>qualifiedName</CODE> has a prefix that is
+ * "xml" and the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE>
+ * nor an empty string nor "http://www.w3.org/XML/1998/namespace", or
+ * if the <CODE>qualifiedName</CODE> has a prefix that is "xmlns" but
+ * the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE> nor an
+ * empty string.
*/
DOM_Attr createAttributeNS(const DOMString &namespaceURI,
const DOMString &qualifiedName);
@@ -454,8 +492,7 @@
* preorder traversal of the <code>Document</code> tree.
* @param namespaceURI The <em>namespace URI</em> of
* the elements to match on. The special value "*" matches all
- * namespaces. When it is <code>null</code> or an empty string, this
- * method behaves like <code>getElementsByTagName</code>.
+ * namespaces.
* @param localName The <em>local name</em> of the
* elements to match on. The special value "*" matches all local names.
* @return A new <code>DOM_NodeList</code> object containing all the matched
@@ -465,9 +502,14 @@
const DOMString &localName) const;
/**
- * Returns the <code>Element</code> whose ID is given by <code>elementId</code>.
+ * Returns the <code>DOM_Element</code> whose ID is given by <code>elementId</code>.
* If no such element exists, returns <code>null</code>.
* Behavior is not defined if more than one element has this <code>ID</code>.
+ * <P><B>Note:</B> The DOM implementation must have information that says
+ * which attributes are of type ID. Attributes with the name "ID" are not of
+ * type ID unless so defined. Implementations that do not know whether
+ * attributes are of type ID or not are expected to return
+ * <CODE>null</CODE>.</P>
* @param elementId The unique <code>id</code> value for an element.
* @return The matching element.
*/
1.2 +6 -2 xml-xerces/c/src/dom/DOM_DocumentType.hpp
Index: DOM_DocumentType.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_DocumentType.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_DocumentType.hpp 1999/11/09 01:08:52 1.1
+++ DOM_DocumentType.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_DocumentType.hpp,v $
- * Revision 1.1 1999/11/09 01:08:52 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:52 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:16 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -151,7 +154,8 @@
/**
* This function returns a <code>NamedNodeMap</code> containing the general entities, both
- * external and internal, declared in the DTD. Duplicates are discarded.
+ * external and internal, declared in the DTD. Parameter entities are not contained.
+ * Duplicates are discarded.
* <p>
* Note: this functionality is not implemented in the initial release
* of the parser, and the returned NamedNodeMap will be empty.
@@ -191,7 +195,7 @@
DOMString getInternalSubset() const;
//@}
-private:
+protected:
DOM_DocumentType(DocumentTypeImpl *);
friend class DOM_Document;
1.3 +7 -6 xml-xerces/c/src/dom/DOM_Element.cpp
Index: DOM_Element.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Element.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_Element.cpp 1999/12/03 00:11:23 1.2
+++ DOM_Element.cpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_Element.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/03 00:11:23 andyh
* Added DOMString.clone() to node parameters in and out of the DOM,
* where they had been missed.
@@ -163,12 +166,6 @@
{
return DOM_NodeList(((ElementImpl *)fImpl)->getElementsByTagName(name));
-};
-
-
-void DOM_Element::normalize()
-{
- ((ElementImpl *)fImpl)->normalize();
};
1.3 +54 -44 xml-xerces/c/src/dom/DOM_Element.hpp
Index: DOM_Element.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Element.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_Element.hpp 1999/12/21 07:47:06 1.2
+++ DOM_Element.hpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_Element.hpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/21 07:47:06 robweir
* Patches to support Xalan, where we need to create a
* "special" DOM with subclassed Nodes.
@@ -188,8 +191,8 @@
/**
* Retrieves an <code>DOM_Attr</code> node by name.
*
- * @param name The name of the attribute to retrieve.
- * @return The <code>DOM_Attr</code> node with the specified attribute name or
+ * @param name The name (<CODE>nodeName</CODE>) of the attribute to retrieve.
+ * @return The <code>DOM_Attr</code> node with the specified name (<CODE>nodeName</CODE>) or
* <code>null</code> if there is no such attribute.
*/
DOM_Attr getAttributeNode(const DOMString &name) const;
@@ -227,7 +230,7 @@
* @param value Value to set in string form.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * invalid character.
+ * illegal character.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
void setAttribute(const DOMString &name,
@@ -235,11 +238,11 @@
/**
* Adds a new attribute.
*
- * If an attribute with that name is already present
+ * If an attribute with that name (<CODE>nodeName</CODE>) is already present
* in the element, it is replaced by the new one.
* @param newAttr The <code>DOM_Attr</code> node to add to the attribute list.
* @return If the <code>newAttr</code> attribute replaces an existing
- * attribute with the same name, the previously existing
+ * attribute, the replaced
* <code>DOM_Attr</code> node is returned, otherwise <code>null</code> is
* returned.
* @exception DOMException
@@ -257,11 +260,14 @@
/** @name Functions which modify the Element. */
//@{
/**
- * Removes the specified attribute.
+ * Removes the specified attribute node.
+ * If the removed <CODE>DOM_Attr</CODE>
+ * has a default value it is immediately replaced. The replacing attribute
+ * has the same namespace URI and local name, as well as the original prefix,
+ * when applicable.
*
* @param oldAttr The <code>DOM_Attr</code> node to remove from the attribute
- * list. If the removed <code>DOM_Attr</code> has a default value it is
- * immediately replaced.
+ * list.
* @return The <code>DOM_Attr</code> node that was removed.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
@@ -271,24 +277,13 @@
DOM_Attr removeAttributeNode(DOM_Attr oldAttr);
/**
- * Puts all <code>Text</code> nodes in the full depth of the sub-tree
- * underneath this <code>DOM_Element</code> into a "normal" form.
-
- * In the "normal" form
- * markup (e.g., tags, comments, processing instructions, CDATA sections,
- * and entity references) separates <code>Text</code> nodes, i.e., there
- * are no adjacent <code>Text</code> nodes. This can be used to ensure
- * that the DOM view of a document is the same as if it were saved and
- * re-loaded, and is useful when operations (such as XPointer lookups) that
- * depend on a particular document tree structure are to be used.
- */
- void normalize();
-
- /**
* Removes an attribute by name.
*
- * If the removed attribute has a default
- * value it is immediately replaced.
+ * If the removed attribute
+ * is known to have a default value, an attribute immediately appears
+ * containing the default value as well as the corresponding namespace URI,
+ * local name, and prefix when applicable.<BR>To remove an attribute by local
+ * name and namespace URI, use the <CODE>removeAttributeNS</CODE> method.
* @param name The name of the attribute to remove.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
@@ -303,8 +298,7 @@
* Retrieves an attribute value by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
- * the attribute to retrieve. When it is <code>null</code> or an empty
- * string, this method behaves like <code>getAttribute</code>.
+ * the attribute to retrieve.
* @param localName The <em>local name</em> of the
* attribute to retrieve.
* @return The <code>DOM_Attr</code> value as a string, or an empty string if
@@ -314,10 +308,15 @@
const DOMString &localName) const;
/**
- * Adds a new attribute. If an attribute with the same local name and
- * namespace URI is already present in the element, its prefix is changed
- * to be that of the <code>qualifiedName</code> parameter,
- * and its value is changed to be that of the <code>value</code> parameter.
+ * Adds a new attribute. If the given
+ * <CODE>namespaceURI</CODE> is <CODE>null</CODE> or an empty string and the
+ * <CODE>qualifiedName</CODE> has a prefix that is "xml", the new attribute
+ * is bound to the predefined namespace
+ * "http://www.w3.org/XML/1998/namespace".
+ * If an attribute with the same local name and namespace URI is already
+ * present on the element, its prefix is changed to be the prefix part of the
+ * <CODE>qualifiedName</CODE>, and its value is changed to be the
+ * <CODE>value</CODE> parameter.
* This value is a simple string, it is
* not parsed as it is being set. So any markup (such as syntax to be
* recognized as an entity reference) is treated as literal text, and
@@ -329,15 +328,24 @@
* <code>setAttributeNode</code> to assign it as the value of an
* attribute.
* @param namespaceURI The <em>namespace URI</em> of
- * the attribute to create or alter. When it is <code>null</code> or an empty
- * string, this method behaves like <code>setAttribute</code>.
+ * the attribute to create or alter.
* @param localName The <em>local name</em> of the
* attribute to create or alter.
* @param value The value to set in string form.
* @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * invalid character.
+ * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an
+ * illegal character.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
+ * <br>
+ * NAMESPACE_ERR: Raised if the <CODE>qualifiedName</CODE> is
+ * malformed, if the <CODE>qualifiedName</CODE> has a prefix that is
+ * "xml" and the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE>
+ * nor an empty string nor "http://www.w3.org/XML/1998/namespace", or
+ * if the <CODE>qualifiedName</CODE> has a prefix that is "xmlns" but
+ * the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE> nor an
+ * empty string, or if if the <CODE>qualifiedName</CODE> has a prefix
+ * different from "xml" and "xmlns" and the <CODE>namespaceURI</CODE>
+ * is <CODE>null</CODE> or an empty string.
*/
void setAttributeNS(const DOMString &namespaceURI,
const DOMString &qualifiedName, const DOMString &value);
@@ -345,10 +353,12 @@
/**
* Removes an attribute by local name and namespace URI. If the
* removed attribute has a default value it is immediately replaced.
+ * The replacing attribute has the same namespace URI and local name, as well as
+ * the original prefix.<BR>HTML-only DOM implementations do not need to
+ * implement this method.
*
* @param namespaceURI The <em>namespace URI</em> of
- * the attribute to remove. When it is <code>null</code> or an empty
- * string, this method behaves like <code>removeAttribute</code>.
+ * the attribute to remove.
* @param localName The <em>local name</em> of the
* attribute to remove.
* @exception DOMException
@@ -361,8 +371,7 @@
* Retrieves an <code>DOM_Attr</code> node by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
- * the attribute to retrieve. When it is <code>null</code> or an empty
- * string, this method behaves like <code>getAttributeNode</code>.
+ * the attribute to retrieve.
* @param localName The <em>local name</em> of the
* attribute to retrieve.
* @return The <code>DOM_Attr</code> node with the specified attribute local
@@ -377,11 +386,9 @@
* If an attribute with that local name and namespace URI is already present
* in the element, it is replaced by the new one.
* @param newAttr The <code>DOM_Attr</code> node to add to the attribute list.
- * When the node has no <code>namespaceURI</code>, this method behaves like
- * <code>setAttributeNode</code>.
* @return If the <code>newAttr</code> attribute replaces an existing
* attribute with the same <em>local name</em> and <em>namespace URI</em>,
- * the previously existing <code>DOM_Attr</code> node is
+ * the replaced <code>DOM_Attr</code> node is
* returned, otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a
@@ -402,8 +409,7 @@
*
* @param namespaceURI The <em>namespace URI</em> of
* the elements to match on. The special value "*" matches all
- * namespaces. When it is <code>null</code> or an empty string, this
- * method behaves like <code>getElementsByTagName</code>.
+ * namespaces.
* @param localName The <em>local name</em> of the
* elements to match on. The special value "*" matches all local names.
* @return A new <code>DOM_NodeList</code> object containing all the matched
@@ -414,7 +420,7 @@
//@}
-protected:
+ protected:
DOM_Element(ElementImpl *impl);
friend class DOM_Document;
1.2 +4 -1 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Entity.hpp 1999/11/09 01:08:58 1.1
+++ DOM_Entity.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Entity.hpp,v $
- * Revision 1.1 1999/11/09 01:08:58 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:58 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:17 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -189,7 +192,7 @@
//@}
-private:
+protected:
DOM_Entity(EntityImpl *impl);
friend class DOM_Document;
1.2 +4 -1 xml-xerces/c/src/dom/DOM_EntityReference.hpp
Index: DOM_EntityReference.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_EntityReference.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_EntityReference.hpp 1999/11/09 01:08:58 1.1
+++ DOM_EntityReference.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_EntityReference.hpp,v $
- * Revision 1.1 1999/11/09 01:08:58 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:58 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:18 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -139,7 +142,7 @@
~DOM_EntityReference();
//@}
-private:
+protected:
DOM_EntityReference(EntityReferenceImpl *impl);
friend class DOM_Document;
1.2 +10 -2 xml-xerces/c/src/dom/DOM_NamedNodeMap.cpp
Index: DOM_NamedNodeMap.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_NamedNodeMap.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_NamedNodeMap.cpp 1999/11/09 01:08:59 1.1
+++ DOM_NamedNodeMap.cpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_NamedNodeMap.cpp,v $
- * Revision 1.1 1999/11/09 01:08:59 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:59 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:18 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -177,8 +180,13 @@
return DOM_Node(fImpl->getNamedItemNS(namespaceURI, localName));
}
+DOM_Node DOM_NamedNodeMap::setNamedItemNS(DOM_Node arg)
+{
+ return DOM_Node(fImpl->setNamedItemNS(arg.fImpl));
+}
+
DOM_Node DOM_NamedNodeMap::removeNamedItemNS(const DOMString &namespaceURI,
- const DOMString &name)
+ const DOMString &localName)
{
- return DOM_Node(fImpl->removeNamedItemNS(namespaceURI, name));
+ return DOM_Node(fImpl->removeNamedItemNS(namespaceURI, localName));
}
1.2 +44 -16 xml-xerces/c/src/dom/DOM_NamedNodeMap.hpp
Index: DOM_NamedNodeMap.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_NamedNodeMap.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_NamedNodeMap.hpp 1999/11/09 01:08:59 1.1
+++ DOM_NamedNodeMap.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_NamedNodeMap.hpp,v $
- * Revision 1.1 1999/11/09 01:08:59 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:59 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:18 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -160,7 +163,7 @@
//@{
/**
- * Adds a node using its <code>nodeName</code>.
+ * Adds a node using its <code>nodeName</code> attribute.
*
* <br>As the <code>nodeName</code> attribute is used to derive the name
* which the node must be stored under, multiple nodes of certain types
@@ -170,8 +173,8 @@
* accessible using the value of the <code>nodeName</code> attribute of
* the node. If a node with that name is already present in the map, it
* is replaced by the new one.
- * @return If the new <code>Node</code> replaces an existing node with the
- * same name the previously existing <code>Node</code> is returned,
+ * @return If the new <code>Node</code> replaces an existing node the
+ * replaced <code>Node</code> is returned,
* otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
@@ -206,9 +209,9 @@
/**
* Retrieves a node specified by name.
*
- * @param name Name of a node to retrieve.
- * @return A <code>Node</code> (of any type) with the specified name, or
- * null <code>DOM_Node</code> if the specified name did not identify any node in
+ * @param name The <code>nodeName</code> of a node to retrieve.
+ * @return A <code>DOM_Node</code> (of any type) with the specified <code>nodeName</code>, or
+ * <code>null</code> if it does not identify any node in
* the map.
*/
DOM_Node getNamedItem(const DOMString &name);
@@ -230,12 +233,15 @@
*
* If the removed node is an
* <code>Attr</code> with a default value it is immediately replaced.
- * @param name The name of a node to remove.
+ * @param name The <code>nodeName</code> of a node to remove.
* @return The node removed from the map or <code>null</code> if no node
* with such a name exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
* the map.
+ * <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>NamedNodeMap</code>
+ * is readonly.
*/
DOM_Node removeNamedItem(const DOMString &name);
@@ -247,28 +253,50 @@
* Retrieves a node specified by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
- * the node to retrieve. When it is <code>null</code> or an empty
- * string, this method behaves like <code>getNamedItem</code>.
+ * the node to retrieve.
* @param localName The <em>local name</em> of the node to retrieve.
* @return A <code>DOM_Node</code> (of any type) with the specified
- * name, or <code>null</code> if the specified name did not
+ * local name and namespace URI, or <code>null</code> if they do not
* identify any node in the map.
*/
DOM_Node getNamedItemNS(const DOMString &namespaceURI,
const DOMString &localName);
/**
+ * Adds a node using its <CODE>namespaceURI</CODE> and <CODE>localName</CODE>.
+ * @param arg A node to store in a named node map. The node will later be
+ * accessible using the value of the <CODE>namespaceURI</CODE> and
+ * <CODE>localName</CODE> attribute of the node. If a node with those
+ * namespace URI and local name is already present in the map, it is
+ * replaced by the new one.
+ * @return If the new <code>Node</code> replaces an existing node the
+ * replaced <code>Node</code> is returned,
+ * otherwise <code>null</code> is returned.
+ * @exception DOMException
+ * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
+ * different document than the one that created the
+ * <code>NamedNodeMap</code>.
+ * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
+ * <code>NamedNodeMap</code> is readonly.
+ * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
+ * <code>Attr</code> that is already an attribute of another
+ * <code>Element</code> object. The DOM user must explicitly clone
+ * <code>Attr</code> nodes to re-use them in other elements.
+ */
+ DOM_Node setNamedItemNS(DOM_Node arg);
+
+ /**
* Removes a node specified by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
- * the node to remove. When it is <code>null</code> or an empty
- * string, this method behaves like <code>removeNamedItem</code>.
- * @param name The <em>local name</em> of the
+ * the node to remove.
+ * @param localName The <em>local name</em> of the
* node to remove. When this <code>DOM_NamedNodeMap</code> contains the
* attributes attached to an element, as returned by the attributes
* attribute of the <code>DOM_Node</code> interface, if the removed
* attribute is known to have a default value, an attribute
- * immediately appears containing the default value.
+ * immediately appears containing the default value
+ * as well as the corresponding namespace URI, local name, and prefix.
* @return The node removed from the map if a node with such a local name
* and namespace URI exists.
* @exception DOMException
@@ -279,11 +307,11 @@
* is readonly.
*/
DOM_Node removeNamedItemNS(const DOMString &namespaceURI,
- const DOMString &name);
+ const DOMString &localName);
//@}
- private:
+ protected:
DOM_NamedNodeMap(NamedNodeMapImpl *impl);
1.3 +13 -0 xml-xerces/c/src/dom/DOM_Node.cpp
Index: DOM_Node.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Node.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM_Node.cpp 1999/12/03 00:11:23 1.2
+++ DOM_Node.cpp 2000/01/05 01:16:07 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DOM_Node.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/03 00:11:23 andyh
* Added DOMString.clone() to node parameters in and out of the DOM,
* where they had been missed.
@@ -278,6 +281,12 @@
//Introduced in DOM Level 2
+
+void DOM_Node::normalize()
+{
+ fImpl->normalize();
+};
+
bool DOM_Node::supports(const DOMString &feature,
const DOMString &version) const
1.2 +61 -32 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Node.hpp 1999/11/09 01:08:59 1.1
+++ DOM_Node.hpp 2000/01/05 01:16:07 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Node.hpp,v $
- * Revision 1.1 1999/11/09 01:08:59 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:07 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:08:59 twl
+ * Initial checkin
+ *
* Revision 1.4 1999/11/08 20:44:19 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -290,12 +293,12 @@
DOM_NamedNodeMap getAttributes() const;
/**
- * Gets the <code>Document</code> object associated with this node.
+ * Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
- * the <code>Document</code> object used to create new nodes. When this
- * node is a <code>Document</code> or a <code>DocumentType</code>,
- * which is not used with any <code>Document</code> yet, this is
+ * the <code>DOM_Document</code> object used to create new nodes. When this
+ * node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
+ * which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
DOM_Document getOwnerDocument() const;
@@ -359,7 +362,8 @@
* the node to insert is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
* from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
+ * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being
+ * inserted is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
* this node.
*/
@@ -371,6 +375,10 @@
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
+ * If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
+ * <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
+ * children, which are inserted in the same order.
+ *
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
@@ -381,7 +389,7 @@
* the node to put in is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
* from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
+ * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the new node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
* this node.
*/
@@ -416,7 +424,8 @@
* the node to append is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
* from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
+ * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being
+ * appended is readonly.
*/
DOM_Node appendChild(const DOM_Node &newChild);
@@ -492,6 +501,24 @@
//@{
/**
+ * Puts all <CODE>DOM_Text</CODE>
+ * nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
+ * including attribute nodes, into a "normal" form where only markup (e.g.,
+ * tags, comments, processing instructions, CDATA sections, and entity
+ * references) separates <CODE>DOM_Text</CODE>
+ * nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
+ * nodes. This can be used to ensure that the DOM view of a document is the
+ * same as if it were saved and re-loaded, and is useful when operations
+ * (such as XPointer lookups) that depend on a particular document tree
+ * structure are to be used.
+ * <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
+ * the normalize operation alone may not be sufficient, since XPointers do
+ * not differentiate between <CODE>DOM_Text</CODE>
+ * nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
+ */
+ void normalize();
+
+ /**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
@@ -509,31 +536,22 @@
/**
* Get the <em>namespace URI</em> of
- * this node, or <code>null</code> if it is unspecified. When this node is
- * of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code>, this is always <code>null</code> and
- * setting it has no effect.
+ * this node, or <code>null</code> if it is unspecified.
* <p>
* This is not a computed value that is the result of a namespace lookup
* based on an examination of the namespace declarations in scope. It is
* merely the namespace URI given at creation time.
* <p>
- * For nodes created with a DOM Level 1 method, such as
- * <code>createElement</code> from the <code>DOM_Document</code> interface,
- * this is <code>null</code>.
+ * For nodes of any type other than <CODE>ELEMENT_NODE</CODE> and
+ * <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
+ * such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
+ * interface, this is always <CODE>null</CODE>.
*/
DOMString getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
- * of this node, or <code>null</code> if it is unspecified. When this node
- * is of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> this is always <code>null</code> and
- * setting it has no effect.
- * <p>
- * For nodes created with a DOM Level 1 method, such as
- * <code>createElement</code> from the <code>DOM_Document</code> interface,
- * this is <code>null</code>.
+ * of this node, or <code>null</code> if it is unspecified.
*/
DOMString getPrefix() const;
@@ -542,27 +560,38 @@
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
- * and for nodes of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> this is the same as the
- * <code>nodeName</code> attribute.
+ * it is null.
*/
DOMString getLocalName() const;
/**
- * Get the <em>namespace prefix</em> of this node.
+ * Set the <em>namespace prefix</em> of this node.
+ * <p>
+ * Note that setting this attribute, when permitted, changes
+ * the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
+ * name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
+ * attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
+ * interfaces, when applicable.
* <p>
- * Note that setting this attribute changes the <code>nodeName</code>
- * attribute, which holds the <em>qualified name</em>,
- * as well as the <code>tagName</code> and
- * <code>name</code> attributes of the <code>Element</code> and
- * <code>Attr</code> interfaces, when applicable.
+ * Note also that changing the prefix of an
+ * attribute, that is known to have a default value, does not make a new
+ * attribute with the default value and the original prefix appear, since the
+ * <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
- * an invalid character.
+ * an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
+ * <br>
+ * NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
+ * malformed, if the specified prefix is "xml" and the
+ * <CODE>namespaceURI</CODE> of this node is different from
+ * "http://www.w3.org/XML/1998/namespace", if specified prefix is
+ * "xmlns" and the <CODE>namespaceURI</CODE> is neither
+ * <CODE>null</CODE> nor an empty string, or if the
+ * <CODE>localName</CODE> is <CODE>null</CODE>.
*/
void setPrefix(const DOMString &prefix);
1.2 +4 -1 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_NodeList.hpp 1999/11/09 01:09:02 1.1
+++ DOM_NodeList.hpp 2000/01/05 01:16:08 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_NodeList.hpp,v $
- * Revision 1.1 1999/11/09 01:09:02 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:09:02 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:20 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -190,7 +193,7 @@
int getLength() const;
//@}
-private:
+protected:
DOM_NodeList(NodeListImpl *impl);
friend class DOM_Document;
1.2 +4 -1 xml-xerces/c/src/dom/DOM_Notation.hpp
Index: DOM_Notation.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Notation.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Notation.hpp 1999/11/09 01:09:03 1.1
+++ DOM_Notation.hpp 2000/01/05 01:16:08 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Notation.hpp,v $
- * Revision 1.1 1999/11/09 01:09:03 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:09:03 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:21 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -188,7 +191,7 @@
//@}
-private:
+protected:
DOM_Notation(NotationImpl *impl);
friend class DOM_Document;
1.2 +4 -1 xml-xerces/c/src/dom/DOM_ProcessingInstruction.hpp
Index: DOM_ProcessingInstruction.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_ProcessingInstruction.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_ProcessingInstruction.hpp 1999/11/09 01:09:03 1.1
+++ DOM_ProcessingInstruction.hpp 2000/01/05 01:16:08 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_ProcessingInstruction.hpp,v $
- * Revision 1.1 1999/11/09 01:09:03 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:09:03 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:21 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -171,7 +174,7 @@
void setData(const DOMString &data);
//@}
-private:
+protected:
DOM_ProcessingInstruction(ProcessingInstructionImpl *impl);
friend class DOM_Document;
1.2 +7 -3 xml-xerces/c/src/dom/DOM_Text.hpp
Index: DOM_Text.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOM_Text.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOM_Text.hpp 1999/11/09 01:09:04 1.1
+++ DOM_Text.hpp 2000/01/05 01:16:08 1.2
@@ -56,9 +56,12 @@
/**
* $Log: DOM_Text.hpp,v $
- * Revision 1.1 1999/11/09 01:09:04 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:09:04 twl
+ * Initial checkin
+ *
* Revision 1.2 1999/11/08 20:44:22 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -154,14 +157,15 @@
//@{
/**
- * Breaks this <code>Text</code> node into two Text nodes at the specified
+ * Breaks this node into two nodes at the specified
* offset, keeping both in the tree as siblings.
*
* This node then only
* contains all the content up to the <code>offset</code> point. And a new
- * <code>Text</code> node, which is inserted as the next sibling of this
+ * node of the same nodeType, which is inserted as the next sibling of this
* node, contains all the content at and after the <code>offset</code>
- * point.
+ * point. When the <code>offset</code> is equal to the lenght of this node,
+ * the new node has no data.
* @param offset The offset at which to split, starting from 0.
* @return The new <code>Text</code> node.
* @exception DOMException
1.3 +105 -115 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DocumentImpl.cpp 1999/11/30 21:16:25 1.2
+++ DocumentImpl.cpp 2000/01/05 01:16:08 1.3
@@ -56,6 +56,9 @@
/**
* $Log: DocumentImpl.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/11/30 21:16:25 roddey
* Changes to add the transcode() method to DOMString, which returns a transcoded
* version (to local code page) of the DOM string contents. And I changed all of the
@@ -119,13 +122,15 @@
: NodeImpl(null, namespaceURI, qualifiedName, DOM_Node::DOCUMENT_NODE, false, null)
{
if (doctype != null && doctype->getOwnerDocument() != null)
- throw DOM_DOMException(
+ throw DOM_DOMException( //one doctype can belong to only one DocumentImpl
DOM_DOMException::WRONG_DOCUMENT_ERR, null);
docType=doctype;
if (doctype != null)
doctype -> setOwnerDocument(this);
docElement=null;
namePool = new DStringPool(257);
+ iterators = 0L;
+ treeWalkers = 0L;
}
@@ -341,114 +346,6 @@
-
-NodeImpl *DocumentImpl::importNode(NodeImpl *source, bool deep)
-{
- NodeImpl *newnode=null;
-
- switch (source->getNodeType())
- {
- case DOM_Node::ELEMENT_NODE :
- {
- ElementImpl *newelement = createElement(source->getNodeName());
- NamedNodeMapImpl *srcattr=source->getAttributes();
- if(srcattr!=null)
- for(int i=0;i<srcattr->getLength();++i)
- newelement->setAttributeNode(
- (AttrImpl *)importNode(srcattr->item(i),true));
- newnode=newelement;
- }
- break;
- case DOM_Node::ATTRIBUTE_NODE :
- newnode = createAttribute(source->getNodeName());
- // Kids carry value
- break;
- case DOM_Node::TEXT_NODE :
- newnode = createTextNode(source->getNodeValue());
- break;
- case DOM_Node::CDATA_SECTION_NODE :
- newnode = createCDATASection(source->getNodeValue());
- break;
- case DOM_Node::ENTITY_REFERENCE_NODE :
- newnode = createEntityReference(source->getNodeName());
- deep=false; // ????? Right Thing?
- // Value implied by doctype, so we should not copy it
- // -- instead, refer to local doctype, if any.
- break;
- case DOM_Node::ENTITY_NODE :
- {
- EntityImpl *srcentity=(EntityImpl *)source;
- EntityImpl *newentity = createEntity(source->getNodeName());
- newentity->setPublicId(srcentity->getPublicId());
- newentity->setSystemId(srcentity->getSystemId());
- newentity->setNotationName(srcentity->getNotationName());
- // Kids carry additional value
- newnode=newentity;
- }
- break;
- case DOM_Node::PROCESSING_INSTRUCTION_NODE :
- newnode = createProcessingInstruction(source->getNodeName(), source->getNodeValue());
- break;
- case DOM_Node::COMMENT_NODE :
- newnode = createComment(source->getNodeValue());
- break;
- case DOM_Node::DOCUMENT_TYPE_NODE :
- {
- DocumentTypeImpl *srcdoctype = (DocumentTypeImpl *)source;
- DocumentTypeImpl *newdoctype = createDocumentType(source->getNodeName());
- // Values are on NamedNodeMaps
- NamedNodeMapImpl *smap=srcdoctype->getEntities();
- NamedNodeMapImpl *tmap=newdoctype->getEntities();
- if(smap!=null)
- for(int i=0;i<smap->getLength();++i)
- tmap->setNamedItem(importNode(smap->item(i),true));
- smap=srcdoctype->getNotations();
- tmap=newdoctype->getNotations();
- if(smap!=null)
- for(int i=0;i<smap->getLength();++i)
- tmap->setNamedItem(
- importNode(smap->item(i),true));
- // 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. ?????
- newnode=newdoctype;
- }
- break;
- case DOM_Node::DOCUMENT_FRAGMENT_NODE :
- newnode = createDocumentFragment();
- // No name, kids carry value
- break;
- case DOM_Node::NOTATION_NODE :
- {
- NotationImpl *srcnotation=(NotationImpl *)source;
- NotationImpl *newnotation = createNotation(source->getNodeName());
- newnotation->setPublicId(srcnotation->getPublicId());
- newnotation->setSystemId(srcnotation->getSystemId());
- // Kids carry additional value
- newnode=newnotation;
- // No name, no value
- break;
- }
-
- case DOM_Node::DOCUMENT_NODE : // Document can't be child of Document
- default: // Unknown node type
- throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR,null);
- }
-
- // If deep, replicate and attach the kids.
- if (deep)
- for (NodeImpl *srckid = source->getFirstChild(); srckid != null; srckid = srckid->getNextSibling())
- {
- newnode->appendChild(importNode(srckid, true));
- }
-
- return newnode;
-};
-
-
-
NodeImpl *DocumentImpl::insertBefore(NodeImpl *newChild, NodeImpl *refChild)
{
// Only one such child permitted
@@ -546,11 +443,106 @@
//Introduced in DOM Level 2
+NodeImpl *DocumentImpl::importNode(NodeImpl *source, bool deep)
+{
+ NodeImpl *newnode=null;
+
+ switch (source->getNodeType())
+ {
+ case DOM_Node::ELEMENT_NODE :
+ {
+ ElementImpl *newelement;
+ if (source->getLocalName() == null)
+ newelement = createElement(source->getNodeName());
+ else
+ newelement = createElementNS(source->getNamespaceURI(), source->getNodeName());
+ NamedNodeMapImpl *srcattr=source->getAttributes();
+ if(srcattr!=null)
+ for(int i=0;i<srcattr->getLength();++i)
+ {
+ AttrImpl *attr = (AttrImpl *) srcattr->item(i);
+ if (attr -> getSpecified()) //not a default attribute
+ if (attr -> getLocalName() == null)
+ newelement->setAttributeNode((AttrImpl *)importNode(attr, true));
+ else
+ newelement->setAttributeNodeNS((AttrImpl *)importNode(attr, true));
+ }
+ newnode=newelement;
+ }
+ break;
+ case DOM_Node::ATTRIBUTE_NODE :
+ if (source->getLocalName() == null)
+ newnode = createAttribute(source->getNodeName());
+ else
+ newnode = createAttributeNS(source->getNamespaceURI(), source->getNodeName());
+ deep = true;
+ // Kids carry value
+ break;
+ case DOM_Node::TEXT_NODE :
+ newnode = createTextNode(source->getNodeValue());
+ break;
+ case DOM_Node::CDATA_SECTION_NODE :
+ newnode = createCDATASection(source->getNodeValue());
+ break;
+ case DOM_Node::COMMENT_NODE :
+ newnode = createComment(source->getNodeValue());
+ break;
+ case DOM_Node::ENTITY_REFERENCE_NODE :
+ newnode = createEntityReference(source->getNodeName());
+ deep=false; // ????? Right Thing?
+ // Value implied by doctype, so we should not copy it
+ // -- instead, refer to local doctype, if any.
+ break;
+ case DOM_Node::ENTITY_NODE :
+ {
+ EntityImpl *srcentity=(EntityImpl *)source;
+ EntityImpl *newentity = createEntity(source->getNodeName());
+ newentity->setPublicId(srcentity->getPublicId());
+ newentity->setSystemId(srcentity->getSystemId());
+ newentity->setNotationName(srcentity->getNotationName());
+ // Kids carry additional value
+ newnode=newentity;
+ }
+ break;
+ case DOM_Node::PROCESSING_INSTRUCTION_NODE :
+ newnode = createProcessingInstruction(source->getNodeName(), source->getNodeValue());
+ break;
+ case DOM_Node::DOCUMENT_FRAGMENT_NODE :
+ newnode = createDocumentFragment();
+ // No name, kids carry value
+ break;
+ case DOM_Node::NOTATION_NODE :
+ {
+ NotationImpl *srcnotation=(NotationImpl *)source;
+ NotationImpl *newnotation = createNotation(source->getNodeName());
+ newnotation->setPublicId(srcnotation->getPublicId());
+ newnotation->setSystemId(srcnotation->getSystemId());
+ // Kids carry additional value
+ newnode=newnotation;
+ // No name, no value
+ break;
+ }
+
+ case DOM_Node::DOCUMENT_NODE : // Document can't be child of Document
+ case DOM_Node::DOCUMENT_TYPE_NODE :
+ default: // Unknown node type
+ throw DOM_DOMException(DOM_DOMException::NOT_SUPPORTED_ERR, null);
+ }
+
+ // If deep, replicate and attach the kids.
+ if (deep)
+ for (NodeImpl *srckid = source->getFirstChild(); srckid != null; srckid = srckid->getNextSibling())
+ {
+ newnode->appendChild(importNode(srckid, true));
+ }
+
+ return newnode;
+};
+
+
ElementImpl *DocumentImpl::createElementNS(const DOMString &namespaceURI,
const DOMString &qualifiedName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return createElement(qualifiedName);
if(!isXMLName(qualifiedName))
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
//DOMString pooledTagName = this->namePool->getPooledString(qualifiedName);
@@ -561,8 +553,6 @@
AttrImpl *DocumentImpl::createAttributeNS(const DOMString &namespaceURI,
const DOMString &qualifiedName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return createAttribute(qualifiedName);
if(!isXMLName(qualifiedName))
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
return new AttrImpl(this, namespaceURI, qualifiedName);
@@ -572,8 +562,6 @@
DeepNodeListImpl *DocumentImpl::getElementsByTagNameNS(const DOMString &namespaceURI,
const DOMString &localName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return getElementsByTagName(localName);
return new DeepNodeListImpl(this, namespaceURI, localName);
}
1.3 +8 -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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DocumentImpl.hpp 1999/12/21 07:47:06 1.2
+++ DocumentImpl.hpp 2000/01/05 01:16:08 1.3
@@ -59,6 +59,9 @@
/**
* $Log: DocumentImpl.hpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/21 07:47:06 robweir
* Patches to support Xalan, where we need to create a
* "special" DOM with subclassed Nodes.
@@ -148,7 +151,6 @@
virtual DocumentTypeImpl *getDoctype();
virtual ElementImpl *getDocumentElement();
virtual DeepNodeListImpl *getElementsByTagName(const DOMString & tagname);
- virtual NodeImpl *importNode(NodeImpl *source, bool deep);
virtual NodeImpl *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
static bool isXMLName(const DOMString & s);
virtual void referenced();
@@ -159,6 +161,7 @@
static TreeWalkerImpl* createTreeWalker(DOM_Node root, short whatToShow, DOM_NodeFilter filter, NodeFilterImpl* fi);
//Introduced in DOM Level 2
+ virtual NodeImpl *importNode(NodeImpl *source, bool deep);
virtual ElementImpl *createElementNS(const DOMString &namespaceURI,
const DOMString &qualifiedName);
virtual AttrImpl *createAttributeNS(const DOMString &namespaceURI,
1.3 +5 -46 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElementImpl.cpp 1999/11/30 21:16:25 1.2
+++ ElementImpl.cpp 2000/01/05 01:16:08 1.3
@@ -56,6 +56,9 @@
/**
* $Log: ElementImpl.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/11/30 21:16:25 roddey
* Changes to add the transcode() method to DOMString, which returns a transcoded
* version (to local code page) of the DOM string contents. And I changed all of the
@@ -78,7 +81,6 @@
#include "ElementDefinitionImpl.hpp"
#include "NamedNodeMapImpl.hpp"
#include "NodeVector.hpp"
-#include "TextImpl.hpp"
ElementImpl::ElementImpl(DocumentImpl *ownerDoc, const DOMString &nam) :
@@ -183,37 +185,6 @@
};
-void ElementImpl::normalize()
-{
- NodeImpl *kid, *next;
- for (kid = getFirstChild(); kid != null; kid = next)
- {
- next = kid->getNextSibling();
-
- // If kid and next are both Text nodes (but _not_ CDATASection,
- // which is a subclass of Text), they can be merged.
- if (next != null &&
- kid->isTextImpl() && !(kid->isCDATASectionImpl()) &&
- next->isTextImpl() && !(next->isCDATASectionImpl()) )
- {
- ((TextImpl *) kid)->appendData(((TextImpl *) next)->getData());
- removeChild(next);
- if (next->nodeRefCount == 0)
- deleteIf(next);
- next = kid; // Don't advance; there might be another.
- }
-
- // Otherwise it might be an Element, which is handled recursively
- else
- if (kid->isElementImpl())
- ((ElementImpl *) kid)->normalize();
- };
-
- // changed() will have occurred when the removeChild() was done,
- // so does not have to be reissued.
-};
-
-
void ElementImpl::removeAttribute(const DOMString &nam)
{
if (readOnly)
@@ -323,8 +294,6 @@
DOMString ElementImpl::getAttributeNS(const DOMString &namespaceURI,
const DOMString &localName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return getAttribute(localName);
static DOMString *emptyString = 0;
AttrImpl * attr=(AttrImpl *)(attributes->getNamedItemNS(namespaceURI, localName));
return (attr==null) ? DStringPool::getStaticString("", &emptyString) : attr->getValue();
@@ -334,10 +303,6 @@
void ElementImpl::setAttributeNS(const DOMString &namespaceURI,
const DOMString &qualifiedName, const DOMString &value)
{
- if (namespaceURI == null || namespaceURI.length() == 0) {
- setAttribute(qualifiedName, value);
- return;
- }
if (readOnly)
throw DOM_DOMException(
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
@@ -358,10 +323,6 @@
void ElementImpl::removeAttributeNS(const DOMString &namespaceURI,
const DOMString &localName)
{
- if (namespaceURI == null || namespaceURI.length() == 0) {
- removeAttribute(localName);
- return;
- }
if (readOnly)
throw DOM_DOMException(
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
@@ -380,16 +341,12 @@
AttrImpl *ElementImpl::getAttributeNodeNS(const DOMString &namespaceURI,
const DOMString &localName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return getAttributeNode(localName);
return (AttrImpl *)(attributes->getNamedItemNS(namespaceURI, localName));
}
AttrImpl *ElementImpl::setAttributeNodeNS(AttrImpl *newAttr)
{
- if (newAttr && newAttr ->getNamespaceURI() == null)
- return setAttributeNode(newAttr);
if (readOnly)
throw DOM_DOMException(
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
1.3 +7 -1 xml-xerces/c/src/dom/ElementImpl.hpp
Index: ElementImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/ElementImpl.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElementImpl.hpp 1999/12/21 07:47:07 1.2
+++ ElementImpl.hpp 2000/01/05 01:16:08 1.3
@@ -59,6 +59,9 @@
/**
* $Log: ElementImpl.hpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/21 07:47:07 robweir
* Patches to support Xalan, where we need to create a
* "special" DOM with subclassed Nodes.
@@ -108,7 +111,6 @@
virtual NamedNodeMapImpl * getAttributes();
virtual DeepNodeListImpl * getElementsByTagName(const DOMString &tagname);
virtual DOMString getTagName();
- virtual void normalize();
virtual void removeAttribute(const DOMString &name);
virtual AttrImpl * removeAttributeNode(AttrImpl * oldAttr);
virtual void setAttribute(const DOMString &name, const DOMString &value);
1.3 +55 -7 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NamedNodeMapImpl.cpp 1999/11/30 21:16:25 1.2
+++ NamedNodeMapImpl.cpp 2000/01/05 01:16:08 1.3
@@ -56,6 +56,9 @@
/**
* $Log: NamedNodeMapImpl.cpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/11/30 21:16:25 roddey
* Changes to add the transcode() method to DOMString, which returns a transcoded
* version (to local code page) of the DOM string contents. And I changed all of the
@@ -316,6 +319,9 @@
//
NodeImpl * NamedNodeMapImpl::removeNamedItem(const DOMString &name)
{
+ if (readOnly)
+ throw DOM_DOMException(
+ DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
int i=findNamePoint(name);
if(i<0)
throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
@@ -328,6 +334,9 @@
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->namespaceURI = n->namespaceURI == null ? null : n->namespaceURI.clone();
+ d->prefix = n->prefix == null ? null : n->prefix.clone();
+ d->localName = n->localName == null ? null : n->localName.clone();
}
nodes->setElementAt(d, i);
} else
@@ -483,37 +492,74 @@
NodeImpl *NamedNodeMapImpl::getNamedItemNS(const DOMString &namespaceURI,
const DOMString &localName)
{
- if (namespaceURI == null || namespaceURI.length() == 0)
- return getNamedItem(localName);
int i = findNamePoint(namespaceURI, localName);
return i < 0 ? null : nodes -> elementAt(i);
}
+//
+// setNamedItemNS() Put the item into the NamedNodeList by name.
+// If an item with the same name already was
+// in the list, replace it. Return the old
+// item, if there was one.
+// Caller is responsible for arranging for
+// deletion of the old item if its ref count is
+// zero.
+//
+NodeImpl * NamedNodeMapImpl::setNamedItemNS(NodeImpl *arg)
+{
+ if(arg->getOwnerDocument()!=ownerDoc)
+ throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR,null);
+ if (readOnly)
+ throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
+ if (arg->owned)
+ throw DOM_DOMException(DOM_DOMException::INUSE_ATTRIBUTE_ERR,null);
+
+ arg->owned = true;
+ int i=findNamePoint(arg->getNamespaceURI(), arg->getLocalName());
+ NodeImpl *previous=null;
+ if(i>=0) {
+ previous = nodes->elementAt(i);
+ nodes->setElementAt(arg,i);
+ } else {
+ i=-1-i; // Insert point (may be end of list)
+ if(null==nodes)
+ nodes=new NodeVector();
+ nodes->insertElementAt(arg,i);
+ }
+ ++changes;
+ if (previous != null)
+ previous->owned = false;
+
+ return previous;
+};
+
+
// removeNamedItemNS() - Remove the named item, and return it.
// The caller must arrange for deletion of the
// returned item if its refcount has gone to zero -
// we can't do it here because the caller would
// never see the returned node.
NodeImpl *NamedNodeMapImpl::removeNamedItemNS(const DOMString &namespaceURI,
- const DOMString &name)
+ const DOMString &localName)
{
if (readOnly)
throw DOM_DOMException(
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
- if (namespaceURI == null || namespaceURI.length() == 0)
- return removeNamedItem(name);
- int i = findNamePoint(namespaceURI, name);
+ 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, name)) != null) {
+ 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->namespaceURI = n->namespaceURI == null ? null : n->namespaceURI.clone();
+ d->prefix = n->prefix == null ? null : n->prefix.clone();
+ d->localName = n->localName == null ? null : n->localName.clone();
}
nodes -> setElementAt(d, i); //replace n in nodes by d
} else
1.2 +6 -2 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamedNodeMapImpl.hpp 1999/11/09 01:09:12 1.1
+++ NamedNodeMapImpl.hpp 2000/01/05 01:16:08 1.2
@@ -59,9 +59,12 @@
/**
* $Log: NamedNodeMapImpl.hpp,v $
- * Revision 1.1 1999/11/09 01:09:12 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:09:12 twl
+ * Initial checkin
+ *
* Revision 1.3 1999/11/08 20:44:29 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -83,7 +86,7 @@
class DocumentImpl;
class NodeImpl;
-class NamedNodeMapImpl {
+class CDOM_EXPORT NamedNodeMapImpl {
private:
NodeVector *nodes;
DocumentImpl *ownerDoc;
@@ -123,8 +126,9 @@
const DOMString &localName);
virtual NodeImpl *getNamedItemNS(const DOMString &namespaceURI,
const DOMString &localName);
+ virtual NodeImpl *setNamedItemNS(NodeImpl *arg);
virtual NodeImpl *removeNamedItemNS(const DOMString &namespaceURI,
- const DOMString &name);
+ const DOMString &localName);
};
#endif
1.4 +145 -58 xml-xerces/c/src/dom/NodeImpl.cpp
Index: NodeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/NodeImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeImpl.cpp 1999/12/03 00:11:23 1.3
+++ NodeImpl.cpp 2000/01/05 01:16:08 1.4
@@ -56,6 +56,9 @@
/**
* $Log: NodeImpl.cpp,v $
+* Revision 1.4 2000/01/05 01:16:08 andyh
+* DOM Level 2 core, namespace support added.
+*
* Revision 1.3 1999/12/03 00:11:23 andyh
* Added DOMString.clone() to node parameters in and out of the DOM,
* where they had been missed.
@@ -85,6 +88,7 @@
#include "stdio.h"
#include <util/XMLString.hpp>
#include <util/XMLUni.hpp>
+#include "TextImpl.hpp"
NodeImpl::NodeImpl(DocumentImpl *ownerDoc,
const DOMString &nam, short nTyp,
@@ -123,33 +127,30 @@
{
// Do we want to add isLeafNode to this? How about initial value?
this->ownerDocument=ownerDoc;
- this->name=qualifiedName.clone();
-
- this->namespaceURI=namespaceURI.clone();
- // Look in the qualified name parameter for a colon.
- // If found, break out the prefix and local name parts.
- // (bug: check for well formed names.)
- XMLCh *qNameP = this->name.rawBuffer();
- int qNameLen = this->name.length();
- int index;
- for (index=0; index<qNameLen; index++)
- {
- if (qNameP[index] == chColon)
- {
- this->prefix = this->name.substringData(0, index);
- int len = this->name.length() - index - 1;
- this->localName = this->name.substringData(index+1, len);
- break;
- }
+ //Check if qualifiedName = prefix:localName, name or malformed
+ this->name = qualifiedName.clone();
+ XMLCh *qNameP = this->name.rawBuffer();
+ int qNameLen = this->name.length(); //note: qNameP[qNameLen] may not be 0
+ int index = -1, count = 0;
+ for (int i = 0; i < qNameLen; ++i)
+ if (*qNameP++ == chColon) {
+ index = i;
+ ++count; //number of ':' found
+ }
+ if (qNameLen == 0 || count > 1 || index == 0 || index == qNameLen-1)
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+
+ if (count == 0) { //count == 0 && index == -1
+ this -> prefix = null;
+ this -> localName = this -> name;
+ } else { //count == 1 && 0 < index < qNameLen-1
+ this -> prefix = this->name.substringData(0, index);
+ this -> localName = this->name.substringData(index+1, qNameLen-index-1);
}
- if (this->prefix == null)
- {
- // The search for a colon, above, in the qualified name failed.
- // the localname is the whole name, and there is no prefix part.
- this->localName = this->name;
- }
+ const DOMString& URI = mapPrefix(prefix, namespaceURI, nTyp);
+ this -> namespaceURI = URI == null ? null : URI.clone();
this->nType=nTyp;
this->isLeafNode=isLeafNod;
@@ -374,7 +375,7 @@
NodeImpl *NodeImpl::insertBefore(NodeImpl *newChild, NodeImpl *refChild) {
- if (readOnly)
+ if (readOnly || newChild -> readOnly)
throw DOM_DOMException(
DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
@@ -645,38 +646,120 @@
return DOMString("[")+getNodeName()+": "+getNodeValue()+"]";
// return getNodeName();
};
-
- //Introduced in DOM Level 2
-
- bool NodeImpl::supports(const DOMString &feature, const DOMString &version)
- {
- return false; //must be overriden by each subclass
- }
-
- DOMString NodeImpl::getNamespaceURI()
- {
- return namespaceURI;
- }
- DOMString NodeImpl::getPrefix()
- {
- return prefix;
- }
-
- DOMString NodeImpl::getLocalName()
- {
- return localName;
- }
+//Introduced in DOM Level 2
- void NodeImpl::setPrefix(const DOMString &prefix)
- {
- if (readOnly)
- throw DOM_DOMException(
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
- if (isAttrImpl() || isElementImpl()) {
- name = this -> prefix = prefix;
- name = name + chColon + localName; //nodeName is changed too
- //what to do if namespaceURI is null?
- }
-
- }
+void NodeImpl::normalize()
+{
+ NodeImpl *kid, *next;
+ for (kid = getFirstChild(); kid != null; kid = next)
+ {
+ next = kid->getNextSibling();
+
+ // If kid and next are both Text nodes (but _not_ CDATASection,
+ // which is a subclass of Text), they can be merged.
+ if (next != null &&
+ kid->isTextImpl() && !(kid->isCDATASectionImpl()) &&
+ next->isTextImpl() && !(next->isCDATASectionImpl()) )
+ {
+ ((TextImpl *) kid)->appendData(((TextImpl *) next)->getData());
+ removeChild(next);
+ if (next->nodeRefCount == 0)
+ deleteIf(next);
+ next = kid; // Don't advance; there might be another.
+ }
+
+ // Otherwise it might be an Element, which is handled recursively
+ else
+ if (kid->isElementImpl())
+ kid->normalize();
+ };
+
+ // changed() will have occurred when the removeChild() was done,
+ // so does not have to be reissued.
+};
+
+
+bool NodeImpl::supports(const DOMString &feature, const DOMString &version)
+{
+ return false; //must be overriden by each subclass
+}
+
+DOMString NodeImpl::getNamespaceURI()
+{
+ return namespaceURI;
+}
+
+DOMString NodeImpl::getPrefix()
+{
+ return prefix;
+}
+
+DOMString NodeImpl::getLocalName()
+{
+ return localName;
+}
+
+
+void NodeImpl::setPrefix(const DOMString &prefix)
+{
+ static const DOMString xml("xml");
+ static const DOMString xmlURI("http://www.w3.org/XML/1998/namespace");
+ static const DOMString xmlns("xmlns");
+
+ if (readOnly)
+ throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
+ if(prefix != null && !DocumentImpl::isXMLName(prefix))
+ throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
+ if (localName == null) //if not Element or Attr node
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+
+ if (prefix == null || prefix.length() == 0) {
+ this -> prefix = null;
+ name = localName;
+ return;
+ }
+
+ XMLCh *p = prefix.rawBuffer();
+ for (int i = prefix.length(); --i >= 0;)
+ if (*p++ == chColon) //prefix is malformed
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+ if (prefix.equals(xml) && !namespaceURI.equals(xmlURI) ||
+ prefix.equals(xmlns) && namespaceURI != null && namespaceURI.length() != 0)
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+
+ name = this -> prefix = prefix;
+ name = name + chColon + localName; //nodeName is changed too
+}
+
+//Return a URI mapped from the given prefix and namespaceURI as below
+// prefix namespaceURI output
+//---------------------------------------------------
+// "xml" null, "" or xmlURI xmlURI
+// "xml" otherwise NAMESPACE_ERR
+// "xmlns" null or "" namespaceURI (nType = ATTRIBUTE_NODE only)
+// "xmlns" otherwise NAMESPACE_ERR (nType = ATTRIBUTE_NODE only)
+// else any namesapceURI
+const DOMString& NodeImpl::mapPrefix(const DOMString &prefix,
+ const DOMString &namespaceURI, short nType)
+{
+ //The constants below are duplicates of those in setPrefix().
+ //However, there is a static initializer problem if they are
+ //defined outside of each function. Need to work on this later.
+ static const DOMString xml("xml");
+ static const DOMString xmlURI("http://www.w3.org/XML/1998/namespace");
+ static const DOMString xmlns("xmlns");
+
+ if (prefix == null)
+ return namespaceURI;
+ if (prefix.equals(xml)) {
+ if (namespaceURI == null || namespaceURI.length() == 0 || namespaceURI.equals(xmlURI))
+ return xmlURI;
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+ } else if (nType == DOM_Node::ATTRIBUTE_NODE && prefix.equals(xmlns)) {
+ if (namespaceURI == null || namespaceURI.length() == 0)
+ return namespaceURI;
+ throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
+ } else
+ return namespaceURI;
+}
1.3 +16 -5 xml-xerces/c/src/dom/NodeImpl.hpp
Index: NodeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/NodeImpl.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NodeImpl.hpp 1999/12/21 07:47:07 1.2
+++ NodeImpl.hpp 2000/01/05 01:16:08 1.3
@@ -59,6 +59,9 @@
/**
* $Log: NodeImpl.hpp,v $
+ * Revision 1.3 2000/01/05 01:16:08 andyh
+ * DOM Level 2 core, namespace support added.
+ *
* Revision 1.2 1999/12/21 07:47:07 robweir
* Patches to support Xalan, where we need to create a
* "special" DOM with subclassed Nodes.
@@ -183,11 +186,15 @@
virtual void unreferenced();
//Introduced in DOM Level 2
- virtual bool supports(const DOMString &feature, const DOMString &version);
- virtual DOMString getNamespaceURI();
- virtual DOMString getPrefix();
- virtual DOMString getLocalName();
- virtual void setPrefix(const DOMString &prefix);
+ virtual void normalize();
+ virtual bool supports(const DOMString &feature, const DOMString &version);
+ virtual DOMString getNamespaceURI();
+ virtual DOMString getPrefix();
+ virtual DOMString getLocalName();
+ virtual void setPrefix(const DOMString &prefix);
+ //Utility, not part of DOM Level 2 API
+ static const DOMString& mapPrefix(const DOMString &prefix,
+ const DOMString &namespaceURI, short nType);
};
1.2 +7 -2 xml-xerces/c/src/parsers/DOMParser.cpp
Index: DOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/DOMParser.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOMParser.cpp 1999/11/09 01:07:49 1.1
+++ DOMParser.cpp 2000/01/05 01:16:11 1.2
@@ -61,9 +61,12 @@
* are created and added to the DOM tree.
*
* $Log: DOMParser.cpp,v $
- * Revision 1.1 1999/11/09 01:07:49 twl
- * Initial revision
+ * Revision 1.2 2000/01/05 01:16:11 andyh
+ * DOM Level 2 core, namespace support added.
*
+ * Revision 1.1.1.1 1999/11/09 01:07:49 twl
+ * Initial checkin
+ *
* Revision 1.7 1999/11/08 20:44:52 rahul
* Swat for adding in Product name and CVS comment log variable.
*
@@ -470,9 +473,10 @@
DOM_Element elem;
if (fScanner -> getDoNamespaces()) { //DOM Level 2, doNamespaces on
unsigned int globalNSid = fValidator -> getGlobalNamespaceId();
+ unsigned int xmlnsNSid = fValidator -> getXMLNSNamespaceId();
XMLBuffer buf;
DOMString namespaceURI = 0;
- if (urlId != globalNSid) { //TagName has prefix
+ if (urlId != globalNSid) { //TagName has a prefix
fValidator -> getURIText(urlId, buf); //get namespaceURI
namespaceURI = DOMString(buf.getRawBuffer());
}
@@ -481,7 +485,8 @@
const XMLAttr* oneAttrib = attrList.elementAt(index);
unsigned int attrURIId = oneAttrib -> getURIId();
namespaceURI = 0;
- if (attrURIId != globalNSid) { //Attribute Name has prefix
+ if (attrURIId != globalNSid && attrURIId != xmlnsNSid) {
+ //Attribute Name has a prefix != "xmlns"
fValidator -> getURIText(attrURIId, buf); //get namespaceURI
namespaceURI = DOMString(buf.getRawBuffer());
}