Named node map extensions

The NamedNodeMap interface retains the original methods:

					Node  item(int index);
					int   getLength( );
					Node  getNamedItem(String nodeName);
					Node  setNamedItem(Node theNode) throws DOMException;
					Node  removeNamedItem(String nodeName)
					throws DOMException;
				

Three new methods have been added to handle elements and attributes by reference to the namespace URL rather than the prefix:

Node  getNamedItemNS(String namespaceURI,
                     String localName);
Node  removeNamedItemNS(String namespaceURI,
                        String localName)
                                  throws DOMException;
Node  setNamedItemNS(Node arg) throws DOMException;

These methods are variants of existing methods to get and remove nodes in the list, and to add nodes to the list. In the first two cases, the variant is simply the addition of an extra parameter that gives the URL of the required attribute. The application does not need to know the prefix it was mapped to when using the getNamedItemNS method and removeNamedItemNS method.

At first sight, the setNamedItemNS method appears to be identical to the original setNamedItem method. In both cases, a node is added to the list by passing a reference to that node to the NamedNodeMap object. The subtle difference is that the added node will replace an existing node if they share the same local name and namespace URL, even if they have different prefixes. This contrasts with the original behaviour, where the prefix, colon and local name would be compared as a single name string.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.36.203