|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ElementImpl.java | 72.2% | 80.6% | 63.6% | 76.2% |
|
||||||||||||||
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | * | |
| 17 | * $Id: ElementImpl.java 571948 2007-09-02 10:51:37Z vgritsenko $ | |
| 18 | */ | |
| 19 | ||
| 20 | package org.apache.xindice.xml.dom; | |
| 21 | ||
| 22 | import org.apache.commons.logging.Log; | |
| 23 | import org.apache.commons.logging.LogFactory; | |
| 24 | import org.apache.xindice.core.data.Key; | |
| 25 | import org.apache.xindice.util.ByteArrayInput; | |
| 26 | import org.apache.xindice.xml.NodeSource; | |
| 27 | import org.apache.xindice.xml.SymbolTable; | |
| 28 | import org.apache.xindice.xml.XMLCompressedInput; | |
| 29 | ||
| 30 | import org.w3c.dom.Attr; | |
| 31 | import org.w3c.dom.DOMException; | |
| 32 | import org.w3c.dom.Element; | |
| 33 | import org.w3c.dom.NamedNodeMap; | |
| 34 | import org.w3c.dom.Node; | |
| 35 | import org.w3c.dom.TypeInfo; | |
| 36 | import org.w3c.dom.UserDataHandler; | |
| 37 | ||
| 38 | import java.io.IOException; | |
| 39 | import java.util.HashSet; | |
| 40 | ||
| 41 | /** | |
| 42 | * ElementImpl | |
| 43 | * | |
| 44 | * @version $Revision: 571948 $, $Date: 2007-09-02 03:51:37 -0700 (Sun, 02 Sep 2007) $ | |
| 45 | */ | |
| 46 | public final class ElementImpl extends ContainerNodeImpl | |
| 47 | implements Element { | |
| 48 | ||
| 49 | private static final Log log = LogFactory.getLog(ElementImpl.class); | |
| 50 | ||
| 51 | // private static final String SRC_NS = XMLNS_PREFIX + ":src"; | |
| 52 | // private static final String SRC_COL = "src:" + NodeSource.SOURCE_COL; | |
| 53 | // private static final String SRC_KEY = "src:" + NodeSource.SOURCE_KEY; | |
| 54 | ||
| 55 | private NamedNodeMapImpl attributes = new NamedNodeMapImpl(this); | |
| 56 | private short symbolID = -1; | |
| 57 | ||
| 58 | ||
| 59 | 0 | public ElementImpl() { |
| 60 | } | |
| 61 | ||
| 62 | 69792 | public ElementImpl(NodeImpl parent, byte[] data, int pos, int len) { |
| 63 | 69792 | super(parent, data, pos, len); |
| 64 | 69792 | DocumentImpl doc = (DocumentImpl) getOwnerDocument(); |
| 65 | 69792 | try { |
| 66 | 69792 | loadAttributes(doc.getSymbols()); |
| 67 | } catch (Exception e) { | |
| 68 | 0 | if (log.isWarnEnabled()) { |
| 69 | 0 | log.warn("ignored exception", e); |
| 70 | } | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | 0 | public ElementImpl(NodeImpl parent, boolean dirty) { |
| 75 | 0 | super(parent, dirty); |
| 76 | } | |
| 77 | ||
| 78 | 124885 | public ElementImpl(NodeImpl parent, String nodeName) { |
| 79 | 124885 | super(parent, true); |
| 80 | 124885 | this.nodeName = nodeName; |
| 81 | } | |
| 82 | ||
| 83 | 211445 | protected boolean isNodeTypeValid(short type) { |
| 84 | 211445 | return type == Node.ELEMENT_NODE |
| 85 | || type == Node.COMMENT_NODE | |
| 86 | || type == Node.TEXT_NODE | |
| 87 | || type == Node.CDATA_SECTION_NODE | |
| 88 | || type == Node.ENTITY_REFERENCE_NODE; | |
| 89 | } | |
| 90 | ||
| 91 | 1795579 | protected void checkLoaded() { |
| 92 | 1795578 | if (loaded) { |
| 93 | 1606475 | return; |
| 94 | } | |
| 95 | ||
| 96 | 189092 | loaded = true; |
| 97 | 189092 | try { |
| 98 | 189092 | if (data != null) { |
| 99 | 69720 | DocumentImpl doc = (DocumentImpl) getOwnerDocument(); |
| 100 | 69720 | SymbolTable st = doc.getSymbols(); |
| 101 | ||
| 102 | 69720 | ByteArrayInput bis = new ByteArrayInput(data, pos, len); |
| 103 | 69720 | XMLCompressedInput in = new XMLCompressedInput(bis, st); |
| 104 | ||
| 105 | 69720 | in.readSignature(); // Skip The Signature |
| 106 | 69720 | in.readContentSize(); // Skip The Content Size |
| 107 | ||
| 108 | 69720 | symbolID = in.readShort(); |
| 109 | 69720 | SymbolTable.SymbolInfo si = st.getSymbolInfo(symbolID); |
| 110 | 69720 | nodeName = si.getQName(); |
| 111 | 69720 | nsURI = si.getNamespaceURI(); |
| 112 | ||
| 113 | 69720 | loadChildren(st); |
| 114 | } | |
| 115 | } catch (IOException e) { | |
| 116 | 0 | if (log.isWarnEnabled()) { |
| 117 | 0 | log.warn("ignored exception", e); |
| 118 | } | |
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | 0 | public short getSymbolID() { |
| 123 | 0 | return symbolID; |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * Add "src" and "col" attributes in {@link NodeSource#SOURCE_NS} namespace. | |
| 128 | */ | |
| 129 | 358 | public void expandSource() { |
| 130 | 358 | NodeSource src = getSource(); |
| 131 | 358 | if (src != null) { |
| 132 | 346 | final String prefix = sourcePrefix("src", NodeSource.SOURCE_NS); |
| 133 | ||
| 134 | 346 | setAttribute(XMLNS_PREFIX + ":" + prefix, NodeSource.SOURCE_NS); |
| 135 | 346 | setAttribute(prefix + ":" + NodeSource.SOURCE_COL, src.getCollection().getCanonicalName()); |
| 136 | 346 | Key k = src.getKey(); |
| 137 | 346 | if (k != null) { |
| 138 | 346 | setAttribute(prefix + ":" + NodeSource.SOURCE_KEY, k.toString()); |
| 139 | } | |
| 140 | } | |
| 141 | } | |
| 142 | ||
| 143 | /** | |
| 144 | * Choose unique prefix for a namespace. | |
| 145 | * Reuse existing prefix if namespace is already defined. | |
| 146 | */ | |
| 147 | 346 | private String sourcePrefix(final String candidatePrefix, final String nsuri) { |
| 148 | 346 | Element element = this; |
| 149 | 346 | HashSet prefixes = new HashSet(); |
| 150 | 346 | while (element != null) { |
| 151 | 626 | NamedNodeMap nm = element.getAttributes(); |
| 152 | 626 | for (int i = 0; i < nm.getLength(); i++) { |
| 153 | 564 | final Attr a = (Attr) nm.item(i); |
| 154 | 564 | final String name = a.getNodeName(); |
| 155 | 564 | if (name.startsWith("xmlns:")) { |
| 156 | 48 | final String prefix = name.substring(6); |
| 157 | 48 | if (nsuri.equals(a.getValue())) { |
| 158 | 42 | return prefix; |
| 159 | } | |
| 160 | 6 | prefixes.add(prefix); |
| 161 | } | |
| 162 | } | |
| 163 | 584 | element = element.getParentNode().getNodeType() == ELEMENT_NODE ? (Element) element.getParentNode() : null; |
| 164 | } | |
| 165 | ||
| 166 | 304 | String result = candidatePrefix; |
| 167 | 304 | while (prefixes.contains(result)) { |
| 168 | 2 | result = candidatePrefix + System.currentTimeMillis(); |
| 169 | } | |
| 170 | ||
| 171 | 304 | return result; |
| 172 | } | |
| 173 | ||
| 174 | 69792 | protected void loadAttributes(SymbolTable st) throws IOException { |
| 175 | 69792 | ByteArrayInput bis = new ByteArrayInput(data, pos, len); |
| 176 | 69792 | XMLCompressedInput in = new XMLCompressedInput(bis, st); |
| 177 | ||
| 178 | 69792 | in.readSignature(); |
| 179 | 69792 | in.readContentSize(); |
| 180 | 69792 | in.readShort(); // Some "elemSymbol" - symbol ID? |
| 181 | 69792 | int attrCount = in.readAttributeCount(); |
| 182 | ||
| 183 | 69792 | for (int i = 0; i < attrCount; i++) { |
| 184 | 47420 | short symbol = in.readShort(); |
| 185 | 47420 | short strLen = in.readShort(); |
| 186 | 47420 | byte[] b = new byte[strLen]; |
| 187 | 47420 | in.read(b); |
| 188 | 47420 | SymbolTable.SymbolInfo si = st.getSymbolInfo(symbol); |
| 189 | 47420 | String name = si.getQName(); |
| 190 | 47420 | String nsURI = si.getNamespaceURI(); |
| 191 | 47420 | AttrImpl attr = new AttrImpl(this, name, nsURI, symbol, new String(b, "UTF-8")); |
| 192 | 47420 | attributes.setNamedItem(attr); |
| 193 | } | |
| 194 | } | |
| 195 | ||
| 196 | 6539432 | public short getNodeType() { |
| 197 | 6539427 | return Node.ELEMENT_NODE; |
| 198 | } | |
| 199 | ||
| 200 | /** | |
| 201 | * A <code>NamedNodeMap</code> containing the attributes of this node (if it | |
| 202 | * is an <code>Element</code>) or <code>null</code> otherwise. | |
| 203 | */ | |
| 204 | 264084 | public NamedNodeMap getAttributes() { |
| 205 | 264084 | return attributes; |
| 206 | } | |
| 207 | ||
| 208 | 42 | public boolean hasAttributes() { |
| 209 | 42 | return attributes.size() > 0; |
| 210 | } | |
| 211 | ||
| 212 | 0 | public boolean hasAttribute(String name) { |
| 213 | 0 | return attributes.getNamedItem(name) != null; |
| 214 | } | |
| 215 | ||
| 216 | /** | |
| 217 | * Removes an attribute by name. If the removed attribute has a | |
| 218 | * default value it is immediately replaced. If the named | |
| 219 | * attribute does not exist, this method has no effect. | |
| 220 | * | |
| 221 | * @param name The name of the attribute to remove. | |
| 222 | * @exception DOMException | |
| 223 | * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 224 | **/ | |
| 225 | 0 | public void removeAttribute(String name) throws DOMException { |
| 226 | 0 | checkReadOnly(); |
| 227 | 0 | AttrImpl attr = (AttrImpl) attributes.removeNamedItem(name); |
| 228 | 0 | if (attr != null) { |
| 229 | 0 | attr.setParentNode((NodeImpl) this.getOwnerDocument()); |
| 230 | } | |
| 231 | 0 | setDirty(); |
| 232 | } | |
| 233 | ||
| 234 | /** | |
| 235 | * The name of the element. For example, in: <elementExample | |
| 236 | * id="demo"> ... </elementExample> , <code>tagName</code> has | |
| 237 | * the value <code>"elementExample"</code>. Note that this is | |
| 238 | * case-preserving in XML, as are all of the operations of the DOM. The | |
| 239 | * HTML DOM returns the <code>tagName</code> of an HTML element in the | |
| 240 | * canonical uppercase form, regardless of the case in the source HTML | |
| 241 | * document. | |
| 242 | */ | |
| 243 | 15104 | public String getTagName() { |
| 244 | 15104 | return getNodeName(); |
| 245 | } | |
| 246 | ||
| 247 | /** | |
| 248 | * Retrieves an attribute value by name. | |
| 249 | * @param name The name of the attribute to retrieve. | |
| 250 | * @return The <code>Attr</code> value as a string, or the empty string if | |
| 251 | * that attribute does not have a specified or default value. | |
| 252 | */ | |
| 253 | 477069 | public String getAttribute(String name) { |
| 254 | 477069 | Attr attr = (Attr) attributes.getNamedItem(name); |
| 255 | 477069 | return attr != null ? attr.getValue() : ""; |
| 256 | } | |
| 257 | ||
| 258 | /** | |
| 259 | * Adds a new attribute. If an attribute with that name is already present | |
| 260 | * in the element, it is replaced by the new one. | |
| 261 | * @param newAttr The <code>Attr</code> node to add to the attribute list. | |
| 262 | * @return If the <code>newAttr</code> attribute replaces an existing | |
| 263 | * attribute with the same name, the previously existing | |
| 264 | * <code>Attr</code> node is returned, otherwise <code>null</code> is | |
| 265 | * returned. | |
| 266 | * @exception DOMException | |
| 267 | * WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a | |
| 268 | * different document than the one that created the element. | |
| 269 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 270 | * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an | |
| 271 | * attribute of another <code>Element</code> object. The DOM user must | |
| 272 | * explicitly clone <code>Attr</code> nodes to re-use them in other | |
| 273 | * elements. | |
| 274 | */ | |
| 275 | 111507 | public Attr setAttributeNode(Attr newAttr) throws DOMException { |
| 276 | 111507 | checkReadOnly(); |
| 277 | 111507 | Attr oldAttr = (Attr) attributes.getNamedItem(newAttr.getName()); |
| 278 | 111507 | DocumentImpl doc = (DocumentImpl) getOwnerDocument(); |
| 279 | 111507 | if (newAttr.getParentNode().getNodeType() == Node.ELEMENT_NODE) { |
| 280 | 0 | throw EX_INUSE_ATTRIBUTE; |
| 281 | } | |
| 282 | 111507 | if (doc != newAttr.getOwnerDocument()) { |
| 283 | 0 | throw EX_WRONG_DOCUMENT; |
| 284 | } | |
| 285 | 111507 | ((AttrImpl) newAttr).setParentNode(this); |
| 286 | 111507 | attributes.setNamedItem(newAttr); |
| 287 | 111507 | setDirty(); |
| 288 | 111507 | return oldAttr; |
| 289 | } | |
| 290 | ||
| 291 | /** | |
| 292 | * Adds a new attribute. If an attribute with that name is already present | |
| 293 | * in the element, its value is changed to be that of the value parameter. | |
| 294 | * This value is a simple string, it is not parsed as it is being set. So | |
| 295 | * any markup (such as syntax to be recognized as an entity reference) is | |
| 296 | * treated as literal text, and needs to be appropriately escaped by the | |
| 297 | * implementation when it is written out. In order to assign an attribute | |
| 298 | * value that contains entity references, the user must create an | |
| 299 | * <code>Attr</code> node plus any <code>Text</code> and | |
| 300 | * <code>EntityReference</code> nodes, build the appropriate subtree, and | |
| 301 | * use <code>setAttributeNode</code> to assign it as the value of an | |
| 302 | * attribute. | |
| 303 | * @param name The name of the attribute to create or alter. | |
| 304 | * @param value Value to set in string form. | |
| 305 | * @exception DOMException | |
| 306 | * INVALID_CHARACTER_ERR: Raised if the specified name contains an | |
| 307 | * invalid character. | |
| 308 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 309 | */ | |
| 310 | 106899 | public void setAttribute(String name, String value) throws DOMException { |
| 311 | 106899 | Attr attr = getOwnerDocument().createAttribute(name); |
| 312 | 106899 | attr.setValue(value); |
| 313 | 106898 | setAttributeNode(attr); |
| 314 | } | |
| 315 | ||
| 316 | /** | |
| 317 | * Retrieves an <code>Attr</code> node by name. | |
| 318 | * @param name The name of the attribute to retrieve. | |
| 319 | * @return The <code>Attr</code> node with the specified attribute name or | |
| 320 | * <code>null</code> if there is no such attribute. | |
| 321 | */ | |
| 322 | 4 | public Attr getAttributeNode(String name) { |
| 323 | 4 | return (Attr) attributes.getNamedItem(name); |
| 324 | } | |
| 325 | ||
| 326 | /** | |
| 327 | * Removes the specified attribute. | |
| 328 | * @param oldAttr The <code>Attr</code> node to remove from the attribute | |
| 329 | * list. If the removed <code>Attr</code> has a default value it is | |
| 330 | * immediately replaced. | |
| 331 | * @return The <code>Attr</code> node that was removed. | |
| 332 | * @exception DOMException | |
| 333 | * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 334 | * <br>NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an attribute | |
| 335 | * of the element. | |
| 336 | **/ | |
| 337 | 0 | public Attr removeAttributeNode(Attr oldAttr) throws DOMException { |
| 338 | 0 | checkReadOnly(); |
| 339 | 0 | if (oldAttr.getParentNode() != this) { |
| 340 | 0 | throw EX_NOT_FOUND; |
| 341 | } | |
| 342 | 0 | attributes.remove(oldAttr.getName()); |
| 343 | 0 | ((AttrImpl) oldAttr).setParentNode((NodeImpl) this.getOwnerDocument()); |
| 344 | 0 | setDirty(); |
| 345 | 0 | return oldAttr; |
| 346 | } | |
| 347 | ||
| 348 | /** | |
| 349 | * Retrieves an attribute value by local name and namespace URI. | |
| 350 | * HTML-only DOM implementations do not need to implement this method. | |
| 351 | * @param namespaceURI The namespace URI of the attribute to retrieve. | |
| 352 | * @param localName The local name of the attribute to retrieve. | |
| 353 | * @return The <code>Attr</code> value as a string, or the empty | |
| 354 | * string if that attribute does not have a specified or default | |
| 355 | * value. | |
| 356 | * @since DOM Level 2 | |
| 357 | */ | |
| 358 | 176 | public String getAttributeNS(String namespaceURI, String localName) { |
| 359 | 176 | Attr attr = (Attr) attributes.getNamedItemNS(namespaceURI, localName); |
| 360 | 176 | return attr != null ? attr.getValue() : ""; |
| 361 | } | |
| 362 | ||
| 363 | /** | |
| 364 | * Adds a new attribute. If an attribute with the same local name and | |
| 365 | * namespace URI is already present on the element, its prefix is changed | |
| 366 | * to be the prefix part of the <code>qualifiedName</code> , and its | |
| 367 | * value is changed to be the <code>value</code> parameter. This value is | |
| 368 | * a simple string; it is not parsed as it is being set. So any markup | |
| 369 | * (such as syntax to be recognized as an entity reference) is treated as | |
| 370 | * literal text, and needs to be appropriately escaped by the | |
| 371 | * implementation when it is written out. In order to assign an attribute | |
| 372 | * value that contains entity references, the user must create an | |
| 373 | * <code>Attr</code> node plus any <code>Text</code> and | |
| 374 | * <code>EntityReference</code> nodes, build the appropriate subtree, and | |
| 375 | * use <code>setAttributeNodeNS</code> or <code>setAttributeNode</code> to | |
| 376 | * assign it as the value of an attribute. | |
| 377 | * <br> HTML-only DOM implementations do not need to implement this method. | |
| 378 | * @param namespaceURI The namespace URI of the attribute to create or | |
| 379 | * alter. | |
| 380 | * @param qualifiedName The qualified name of the attribute to create or | |
| 381 | * alter. | |
| 382 | * @param value The value to set in string form. | |
| 383 | * @exception DOMException | |
| 384 | * INVALID_CHARACTER_ERR: Raised if the specified qualified name | |
| 385 | * contains an illegal character. | |
| 386 | * <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 387 | * <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is | |
| 388 | * malformed, if the <code>qualifiedName</code> has a prefix and the | |
| 389 | * <code>namespaceURI</code> is <code>null</code> or an empty string, | |
| 390 | * if the <code>qualifiedName</code> has a prefix that is "xml" and the | |
| 391 | * <code>namespaceURI</code> is different from | |
| 392 | * "http://www.w3.org/XML/1998/namespace", if the | |
| 393 | * <code>qualifiedName</code> has a prefix that is "xmlns" and the | |
| 394 | * <code>namespaceURI</code> is different from | |
| 395 | * "http://www.w3.org/2000/xmlns/", or if the <code>qualifiedName</code> | |
| 396 | * is "xmlns" and the <code>namespaceURI</code> is different from | |
| 397 | * "http://www.w3.org/2000/xmlns/". | |
| 398 | * @since DOM Level 2 | |
| 399 | */ | |
| 400 | 727 | public void setAttributeNS(String namespaceURI, String qualifiedName, String value) { |
| 401 | 727 | Attr attr = getOwnerDocument().createAttributeNS(namespaceURI, qualifiedName); |
| 402 | 727 | attr.setValue(value); |
| 403 | 727 | setAttributeNodeNS(attr); |
| 404 | } | |
| 405 | ||
| 406 | /** | |
| 407 | * Removes an attribute by local name and namespace URI. If the | |
| 408 | * removed attribute has a default value it is immediately | |
| 409 | * replaced. The replacing attribute has the same namespace URI | |
| 410 | * and local name, as well as the original prefix. | |
| 411 | * | |
| 412 | * <br> HTML-only DOM implementations do not need to implement this | |
| 413 | * method. | |
| 414 | * | |
| 415 | * @param namespaceURI The namespace URI of the attribute to remove. | |
| 416 | * @param localName The local name of the attribute to remove. | |
| 417 | * @exception DOMException | |
| 418 | * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 419 | * @since DOM Level 2 | |
| 420 | **/ | |
| 421 | 2 | public void removeAttributeNS(String namespaceURI, String localName) { |
| 422 | 2 | checkReadOnly(); |
| 423 | 2 | AttrImpl attr = (AttrImpl) attributes.removeNamedItemNS(namespaceURI, localName); |
| 424 | 2 | if (attr != null) { |
| 425 | 0 | attr.setParentNode((NodeImpl) this.getOwnerDocument()); |
| 426 | } | |
| 427 | 2 | setDirty(); |
| 428 | } | |
| 429 | ||
| 430 | /** | |
| 431 | * Retrieves an <code>Attr</code> node by local name and namespace URI. | |
| 432 | * HTML-only DOM implementations do not need to implement this method. | |
| 433 | * @param namespaceURI The namespace URI of the attribute to retrieve. | |
| 434 | * @param localName The local name of the attribute to retrieve. | |
| 435 | * @return The <code>Attr</code> node with the specified attribute local | |
| 436 | * name and namespace URI or <code>null</code> if there is no such | |
| 437 | * attribute. | |
| 438 | * @since DOM Level 2 | |
| 439 | */ | |
| 440 | 0 | public Attr getAttributeNodeNS(String namespaceURI, String localName) { |
| 441 | 0 | return (Attr) attributes.getNamedItemNS(namespaceURI, localName); |
| 442 | } | |
| 443 | ||
| 444 | /** | |
| 445 | * Adds a new attribute. If an attribute with that local name and that | |
| 446 | * namespace URI is already present in the element, it is replaced by the | |
| 447 | * new one. | |
| 448 | * <br> HTML-only DOM implementations do not need to implement this method. | |
| 449 | * @param newAttr The <code>Attr</code> node to add to the attribute list. | |
| 450 | * @return If the <code>newAttr</code> attribute replaces an existing | |
| 451 | * attribute with the same local name and namespace URI , the | |
| 452 | * replaced <code>Attr</code> node is returned, otherwise | |
| 453 | * <code>null</code> is returned. | |
| 454 | * @exception DOMException | |
| 455 | * WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from | |
| 456 | * a different document than the one that created the element. | |
| 457 | * <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
| 458 | * <br> INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already | |
| 459 | * an attribute of another <code>Element</code> object. The DOM user | |
| 460 | * must explicitly clone <code>Attr</code> nodes to re-use them in | |
| 461 | * other elements. | |
| 462 |