1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: DOM2DTMdefaultNamespaceDeclarationNode.java,v
  18. */
  19. package com.sun.org.apache.xml.internal.dtm.ref.dom2dtm;
  20. import com.sun.org.apache.xml.internal.dtm.DTMException;
  21. import org.w3c.dom.Attr;
  22. import org.w3c.dom.Document;
  23. import org.w3c.dom.Element;
  24. import org.w3c.dom.NamedNodeMap;
  25. import org.w3c.dom.Node;
  26. import org.w3c.dom.NodeList;
  27. import org.w3c.dom.TypeInfo;
  28. import org.w3c.dom.UserDataHandler;
  29. import org.w3c.dom.DOMException;
  30. /** This is a kluge to let us shove a declaration for xml: into the
  31. * DOM2DTM model. Basically, it creates a proxy node in DOM space to
  32. * carry the additional information. This is _NOT_ a full DOM
  33. * implementation, and shouldn't be one since it sits alongside the
  34. * DOM rather than becoming part of the DOM model.
  35. *
  36. * (This used to be an internal class within DOM2DTM. Moved out because
  37. * I need to perform an instanceof operation on it to support a temporary
  38. * workaround in DTMManagerDefault.)
  39. *
  40. * %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
  41. * there isn't a single root element? I think this fails that case...
  42. *
  43. * %REVIEW% An alternative solution would be to create the node _only_
  44. * in DTM space, but given how DOM2DTM is currently written I think
  45. * this is simplest.
  46. * */
  47. public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo
  48. {
  49. final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
  50. Element pseudoparent;
  51. String prefix,uri,nodename;
  52. int handle;
  53. DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
  54. {
  55. this.pseudoparent=pseudoparent;
  56. this.prefix=prefix;
  57. this.uri=uri;
  58. this.handle=handle;
  59. this.nodename="xmlns:"+prefix;
  60. }
  61. public String getNodeName() {return nodename;}
  62. public String getName() {return nodename;}
  63. public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
  64. public String getPrefix() {return prefix;}
  65. public String getLocalName() {return prefix;}
  66. public String getNodeValue() {return uri;}
  67. public String getValue() {return uri;}
  68. public Element getOwnerElement() {return pseudoparent;}
  69. public boolean isSupported(String feature, String version) {return false;}
  70. public boolean hasChildNodes() {return false;}
  71. public boolean hasAttributes() {return false;}
  72. public Node getParentNode() {return null;}
  73. public Node getFirstChild() {return null;}
  74. public Node getLastChild() {return null;}
  75. public Node getPreviousSibling() {return null;}
  76. public Node getNextSibling() {return null;}
  77. public boolean getSpecified() {return false;}
  78. public void normalize() {return;}
  79. public NodeList getChildNodes() {return null;}
  80. public NamedNodeMap getAttributes() {return null;}
  81. public short getNodeType() {return Node.ATTRIBUTE_NODE;}
  82. public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  83. public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  84. public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  85. public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
  86. public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
  87. public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
  88. public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
  89. public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
  90. public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
  91. /** Non-DOM method, part of the temporary kluge
  92. * %REVIEW% This would be a pruning problem, but since it will always be
  93. * added to the root element and we prune on elements, we shouldn't have
  94. * to worry.
  95. */
  96. public int getHandleOfNode()
  97. {
  98. return handle;
  99. }
  100. //RAMESH: PENDING=> Add proper implementation for the below DOM L3 additions
  101. /**
  102. * @see org.w3c.dom.TypeInfo#getTypeName()
  103. */
  104. public String getTypeName() {return null; }
  105. /**
  106. * @see org.w3c.dom.TypeInfo#getTypeNamespace()
  107. */
  108. public String getTypeNamespace() { return null;}
  109. /**
  110. * @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)
  111. */
  112. public boolean isDerivedFrom( String ns, String localName, int derivationMethod ) {
  113. return false;
  114. }
  115. public TypeInfo getSchemaTypeInfo() { return this; }
  116. public boolean isId( ) { return false; }
  117. /**
  118. * Associate an object to a key on this node. The object can later be
  119. * retrieved from this node by calling <code>getUserData</code> with the
  120. * same key.
  121. * @param key The key to associate the object to.
  122. * @param data The object to associate to the given key, or
  123. * <code>null</code> to remove any existing association to that key.
  124. * @param handler The handler to associate to that key, or
  125. * <code>null</code>.
  126. * @return Returns the <code>DOMObject</code> previously associated to
  127. * the given key on this node, or <code>null</code> if there was none.
  128. * @since DOM Level 3
  129. */
  130. public Object setUserData(String key,
  131. Object data,
  132. UserDataHandler handler) {
  133. return getOwnerDocument().setUserData( key, data, handler);
  134. }
  135. /**
  136. * Retrieves the object associated to a key on a this node. The object
  137. * must first have been set to this node by calling
  138. * <code>setUserData</code> with the same key.
  139. * @param key The key the object is associated to.
  140. * @return Returns the <code>DOMObject</code> associated to the given key
  141. * on this node, or <code>null</code> if there was none.
  142. * @since DOM Level 3
  143. */
  144. public Object getUserData(String key) {
  145. return getOwnerDocument().getUserData( key);
  146. }
  147. /**
  148. * This method returns a specialized object which implements the
  149. * specialized APIs of the specified feature and version. The
  150. * specialized object may also be obtained by using binding-specific
  151. * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
  152. * @param feature The name of the feature requested (case-insensitive).
  153. * @param version This is the version number of the feature to test. If
  154. * the version is <code>null</code> or the empty string, supporting
  155. * any version of the feature will cause the method to return an
  156. * object that supports at least one version of the feature.
  157. * @return Returns an object which implements the specialized APIs of
  158. * the specified feature and version, if any, or <code>null</code> if
  159. * there is no object which implements interfaces associated with that
  160. * feature. If the <code>DOMObject</code> returned by this method
  161. * implements the <code>Node</code> interface, it must delegate to the
  162. * primary core <code>Node</code> and not return results inconsistent
  163. * with the primary core <code>Node</code> such as attributes,
  164. * childNodes, etc.
  165. * @since DOM Level 3
  166. */
  167. public Object getFeature(String feature, String version) {
  168. // we don't have any alternate node, either this node does the job
  169. // or we don't have anything that does
  170. return isSupported(feature, version) ? this : null;
  171. }
  172. /**
  173. * Tests whether two nodes are equal.
  174. * <br>This method tests for equality of nodes, not sameness (i.e.,
  175. * whether the two nodes are references to the same object) which can be
  176. * tested with <code>Node.isSameNode</code>. All nodes that are the same
  177. * will also be equal, though the reverse may not be true.
  178. * <br>Two nodes are equal if and only if the following conditions are
  179. * satisfied: The two nodes are of the same type.The following string
  180. * attributes are equal: <code>nodeName</code>, <code>localName</code>,
  181. * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
  182. * , <code>baseURI</code>. This is: they are both <code>null</code>, or
  183. * they have the same length and are character for character identical.
  184. * The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
  185. * This is: they are both <code>null</code>, or they have the same
  186. * length and for each node that exists in one map there is a node that
  187. * exists in the other map and is equal, although not necessarily at the
  188. * same index.The <code>childNodes</code> <code>NodeLists</code> are
  189. * equal. This is: they are both <code>null</code>, or they have the
  190. * same length and contain equal nodes at the same index. This is true
  191. * for <code>Attr</code> nodes as for any other type of node. Note that
  192. * normalization can affect equality; to avoid this, nodes should be
  193. * normalized before being compared.
  194. * <br>For two <code>DocumentType</code> nodes to be equal, the following
  195. * conditions must also be satisfied: The following string attributes
  196. * are equal: <code>publicId</code>, <code>systemId</code>,
  197. * <code>internalSubset</code>.The <code>entities</code>
  198. * <code>NamedNodeMaps</code> are equal.The <code>notations</code>
  199. * <code>NamedNodeMaps</code> are equal.
  200. * <br>On the other hand, the following do not affect equality: the
  201. * <code>ownerDocument</code> attribute, the <code>specified</code>
  202. * attribute for <code>Attr</code> nodes, the
  203. * <code>isWhitespaceInElementContent</code> attribute for
  204. * <code>Text</code> nodes, as well as any user data or event listeners
  205. * registered on the nodes.
  206. * @param arg The node to compare equality with.
  207. * @param deep If <code>true</code>, recursively compare the subtrees; if
  208. * <code>false</code>, compare only the nodes themselves (and its
  209. * attributes, if it is an <code>Element</code>).
  210. * @return If the nodes, and possibly subtrees are equal,
  211. * <code>true</code> otherwise <code>false</code>.
  212. * @since DOM Level 3
  213. */
  214. public boolean isEqualNode(Node arg) {
  215. if (arg == this) {
  216. return true;
  217. }
  218. if (arg.getNodeType() != getNodeType()) {
  219. return false;
  220. }
  221. // in theory nodeName can't be null but better be careful
  222. // who knows what other implementations may be doing?...
  223. if (getNodeName() == null) {
  224. if (arg.getNodeName() != null) {
  225. return false;
  226. }
  227. }
  228. else if (!getNodeName().equals(arg.getNodeName())) {
  229. return false;
  230. }
  231. if (getLocalName() == null) {
  232. if (arg.getLocalName() != null) {
  233. return false;
  234. }
  235. }
  236. else if (!getLocalName().equals(arg.getLocalName())) {
  237. return false;
  238. }
  239. if (getNamespaceURI() == null) {
  240. if (arg.getNamespaceURI() != null) {
  241. return false;
  242. }
  243. }
  244. else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
  245. return false;
  246. }
  247. if (getPrefix() == null) {
  248. if (arg.getPrefix() != null) {
  249. return false;
  250. }
  251. }
  252. else if (!getPrefix().equals(arg.getPrefix())) {
  253. return false;
  254. }
  255. if (getNodeValue() == null) {
  256. if (arg.getNodeValue() != null) {
  257. return false;
  258. }
  259. }
  260. else if (!getNodeValue().equals(arg.getNodeValue())) {
  261. return false;
  262. }
  263. /*
  264. if (getBaseURI() == null) {
  265. if (((NodeImpl) arg).getBaseURI() != null) {
  266. return false;
  267. }
  268. }
  269. else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
  270. return false;
  271. }
  272. */
  273. return true;
  274. }
  275. /**
  276. * DOM Level 3 - Experimental:
  277. * Look up the namespace URI associated to the given prefix, starting from this node.
  278. * Use lookupNamespaceURI(null) to lookup the default namespace
  279. *
  280. * @param namespaceURI
  281. * @return th URI for the namespace
  282. * @since DOM Level 3
  283. */
  284. public String lookupNamespaceURI(String specifiedPrefix) {
  285. short type = this.getNodeType();
  286. switch (type) {
  287. case Node.ELEMENT_NODE : {
  288. String namespace = this.getNamespaceURI();
  289. String prefix = this.getPrefix();
  290. if (namespace !=null) {
  291. // REVISIT: is it possible that prefix is empty string?
  292. if (specifiedPrefix== null && prefix==specifiedPrefix) {
  293. // looking for default namespace
  294. return namespace;
  295. } else if (prefix != null && prefix.equals(specifiedPrefix)) {
  296. // non default namespace
  297. return namespace;
  298. }
  299. }
  300. if (this.hasAttributes()) {
  301. NamedNodeMap map = this.getAttributes();
  302. int length = map.getLength();
  303. for (int i=0;i<length;i++) {
  304. Node attr = map.item(i);
  305. String attrPrefix = attr.getPrefix();
  306. String value = attr.getNodeValue();
  307. namespace = attr.getNamespaceURI();
  308. if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
  309. // at this point we are dealing with DOM Level 2 nodes only
  310. if (specifiedPrefix == null &&
  311. attr.getNodeName().equals("xmlns")) {
  312. // default namespace
  313. return value;
  314. } else if (attrPrefix !=null &&
  315. attrPrefix.equals("xmlns") &&
  316. attr.getLocalName().equals(specifiedPrefix)) {
  317. // non default namespace
  318. return value;
  319. }
  320. }
  321. }
  322. }
  323. /*
  324. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  325. if (ancestor != null) {
  326. return ancestor.lookupNamespaceURI(specifiedPrefix);
  327. }
  328. */
  329. return null;
  330. }
  331. /*
  332. case Node.DOCUMENT_NODE : {
  333. return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
  334. }
  335. */
  336. case Node.ENTITY_NODE :
  337. case Node.NOTATION_NODE:
  338. case Node.DOCUMENT_FRAGMENT_NODE:
  339. case Node.DOCUMENT_TYPE_NODE:
  340. // type is unknown
  341. return null;
  342. case Node.ATTRIBUTE_NODE:{
  343. if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
  344. return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
  345. }
  346. return null;
  347. }
  348. default:{
  349. /*
  350. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  351. if (ancestor != null) {
  352. return ancestor.lookupNamespaceURI(specifiedPrefix);
  353. }
  354. */
  355. return null;
  356. }
  357. }
  358. }
  359. /**
  360. * DOM Level 3: Experimental
  361. * This method checks if the specified <code>namespaceURI</code> is the
  362. * default namespace or not.
  363. * @param namespaceURI The namespace URI to look for.
  364. * @return <code>true</code> if the specified <code>namespaceURI</code>
  365. * is the default namespace, <code>false</code> otherwise.
  366. * @since DOM Level 3
  367. */
  368. public boolean isDefaultNamespace(String namespaceURI){
  369. /*
  370. // REVISIT: remove casts when DOM L3 becomes REC.
  371. short type = this.getNodeType();
  372. switch (type) {
  373. case Node.ELEMENT_NODE: {
  374. String namespace = this.getNamespaceURI();
  375. String prefix = this.getPrefix();
  376. // REVISIT: is it possible that prefix is empty string?
  377. if (prefix == null || prefix.length() == 0) {
  378. if (namespaceURI == null) {
  379. return (namespace == namespaceURI);
  380. }
  381. return namespaceURI.equals(namespace);
  382. }
  383. if (this.hasAttributes()) {
  384. ElementImpl elem = (ElementImpl)this;
  385. NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
  386. if (attr != null) {
  387. String value = attr.getNodeValue();
  388. if (namespaceURI == null) {
  389. return (namespace == value);
  390. }
  391. return namespaceURI.equals(value);
  392. }
  393. }
  394. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  395. if (ancestor != null) {
  396. return ancestor.isDefaultNamespace(namespaceURI);
  397. }
  398. return false;
  399. }
  400. case Node.DOCUMENT_NODE:{
  401. return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
  402. }
  403. case Node.ENTITY_NODE :
  404. case Node.NOTATION_NODE:
  405. case Node.DOCUMENT_FRAGMENT_NODE:
  406. case Node.DOCUMENT_TYPE_NODE:
  407. // type is unknown
  408. return false;
  409. case Node.ATTRIBUTE_NODE:{
  410. if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
  411. return ownerNode.isDefaultNamespace(namespaceURI);
  412. }
  413. return false;
  414. }
  415. default:{
  416. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  417. if (ancestor != null) {
  418. return ancestor.isDefaultNamespace(namespaceURI);
  419. }
  420. return false;
  421. }
  422. }
  423. */
  424. return false;
  425. }
  426. /**
  427. *
  428. * DOM Level 3 - Experimental:
  429. * Look up the prefix associated to the given namespace URI, starting from this node.
  430. *
  431. * @param namespaceURI
  432. * @return the prefix for the namespace
  433. */
  434. public String lookupPrefix(String namespaceURI){
  435. // REVISIT: When Namespaces 1.1 comes out this may not be true
  436. // Prefix can't be bound to null namespace
  437. if (namespaceURI == null) {
  438. return null;
  439. }
  440. short type = this.getNodeType();
  441. switch (type) {
  442. /*
  443. case Node.ELEMENT_NODE: {
  444. String namespace = this.getNamespaceURI(); // to flip out children
  445. return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
  446. }
  447. case Node.DOCUMENT_NODE:{
  448. return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
  449. }
  450. */
  451. case Node.ENTITY_NODE :
  452. case Node.NOTATION_NODE:
  453. case Node.DOCUMENT_FRAGMENT_NODE:
  454. case Node.DOCUMENT_TYPE_NODE:
  455. // type is unknown
  456. return null;
  457. case Node.ATTRIBUTE_NODE:{
  458. if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
  459. return getOwnerElement().lookupPrefix(namespaceURI);
  460. }
  461. return null;
  462. }
  463. default:{
  464. /*
  465. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  466. if (ancestor != null) {
  467. return ancestor.lookupPrefix(namespaceURI);
  468. }
  469. */
  470. return null;
  471. }
  472. }
  473. }
  474. /**
  475. * Returns whether this node is the same node as the given one.
  476. * <br>This method provides a way to determine whether two
  477. * <code>Node</code> references returned by the implementation reference
  478. * the same object. When two <code>Node</code> references are references
  479. * to the same object, even if through a proxy, the references may be
  480. * used completely interchangably, such that all attributes have the
  481. * same values and calling the same DOM method on either reference
  482. * always has exactly the same effect.
  483. * @param other The node to test against.
  484. * @return Returns <code>true</code> if the nodes are the same,
  485. * <code>false</code> otherwise.
  486. * @since DOM Level 3
  487. */
  488. public boolean isSameNode(Node other) {
  489. // we do not use any wrapper so the answer is obvious
  490. return this == other;
  491. }
  492. /**
  493. * This attribute returns the text content of this node and its
  494. * descendants. When it is defined to be null, setting it has no effect.
  495. * When set, any possible children this node may have are removed and
  496. * replaced by a single <code>Text</code> node containing the string
  497. * this attribute is set to. On getting, no serialization is performed,
  498. * the returned string does not contain any markup. No whitespace
  499. * normalization is performed, the returned string does not contain the
  500. * element content whitespaces . Similarly, on setting, no parsing is
  501. * performed either, the input string is taken as pure textual content.
  502. * <br>The string returned is made of the text content of this node
  503. * depending on its type, as defined below:
  504. * <table border='1'>
  505. * <tr>
  506. * <th>Node type</th>
  507. * <th>Content</th>
  508. * </tr>
  509. * <tr>
  510. * <td valign='top' rowspan='1' colspan='1'>
  511. * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
  512. * DOCUMENT_FRAGMENT_NODE</td>
  513. * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
  514. * attribute value of every child node, excluding COMMENT_NODE and
  515. * PROCESSING_INSTRUCTION_NODE nodes</td>
  516. * </tr>
  517. * <tr>
  518. * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
  519. * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
  520. * <td valign='top' rowspan='1' colspan='1'>
  521. * <code>nodeValue</code></td>
  522. * </tr>
  523. * <tr>
  524. * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
  525. * <td valign='top' rowspan='1' colspan='1'>
  526. * null</td>
  527. * </tr>
  528. * </table>
  529. * @exception DOMException
  530. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  531. * @exception DOMException
  532. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  533. * fit in a <code>DOMString</code> variable on the implementation
  534. * platform.
  535. * @since DOM Level 3
  536. */
  537. public void setTextContent(String textContent)
  538. throws DOMException {
  539. setNodeValue(textContent);
  540. }
  541. /**
  542. * This attribute returns the text content of this node and its
  543. * descendants. When it is defined to be null, setting it has no effect.
  544. * When set, any possible children this node may have are removed and
  545. * replaced by a single <code>Text</code> node containing the string
  546. * this attribute is set to. On getting, no serialization is performed,
  547. * the returned string does not contain any markup. No whitespace
  548. * normalization is performed, the returned string does not contain the
  549. * element content whitespaces . Similarly, on setting, no parsing is
  550. * performed either, the input string is taken as pure textual content.
  551. * <br>The string returned is made of the text content of this node
  552. * depending on its type, as defined below:
  553. * <table border='1'>
  554. * <tr>
  555. * <th>Node type</th>
  556. * <th>Content</th>
  557. * </tr>
  558. * <tr>
  559. * <td valign='top' rowspan='1' colspan='1'>
  560. * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
  561. * DOCUMENT_FRAGMENT_NODE</td>
  562. * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
  563. * attribute value of every child node, excluding COMMENT_NODE and
  564. * PROCESSING_INSTRUCTION_NODE nodes</td>
  565. * </tr>
  566. * <tr>
  567. * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
  568. * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
  569. * <td valign='top' rowspan='1' colspan='1'>
  570. * <code>nodeValue</code></td>
  571. * </tr>
  572. * <tr>
  573. * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
  574. * <td valign='top' rowspan='1' colspan='1'>
  575. * null</td>
  576. * </tr>
  577. * </table>
  578. * @exception DOMException
  579. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  580. * @exception DOMException
  581. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  582. * fit in a <code>DOMString</code> variable on the implementation
  583. * platform.
  584. * @since DOM Level 3
  585. */
  586. public String getTextContent() throws DOMException {
  587. return getNodeValue(); // overriden in some subclasses
  588. }
  589. /**
  590. * Compares a node with this node with regard to their position in the
  591. * document.
  592. * @param other The node to compare against this node.
  593. * @return Returns how the given node is positioned relatively to this
  594. * node.
  595. * @since DOM Level 3
  596. */
  597. public short compareDocumentPosition(Node other) throws DOMException {
  598. return 0;
  599. }
  600. /**
  601. * The absolute base URI of this node or <code>null</code> if undefined.
  602. * This value is computed according to . However, when the
  603. * <code>Document</code> supports the feature "HTML" , the base URI is
  604. * computed using first the value of the href attribute of the HTML BASE
  605. * element if any, and the value of the <code>documentURI</code>
  606. * attribute from the <code>Document</code> interface otherwise.
  607. * <br> When the node is an <code>Element</code>, a <code>Document</code>
  608. * or a a <code>ProcessingInstruction</code>, this attribute represents
  609. * the properties [base URI] defined in . When the node is a
  610. * <code>Notation</code>, an <code>Entity</code>, or an
  611. * <code>EntityReference</code>, this attribute represents the
  612. * properties [declaration base URI] in the . How will this be affected
  613. * by resolution of relative namespace URIs issue?It's not.Should this
  614. * only be on Document, Element, ProcessingInstruction, Entity, and
  615. * Notation nodes, according to the infoset? If not, what is it equal to
  616. * on other nodes? Null? An empty string? I think it should be the
  617. * parent's.No.Should this be read-only and computed or and actual
  618. * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
  619. * teleconference 30 May 2001).If the base HTML element is not yet
  620. * attached to a document, does the insert change the Document.baseURI?
  621. * Yes. (F2F 26 Sep 2001)
  622. * @since DOM Level 3
  623. */
  624. public String getBaseURI() {
  625. return null;
  626. }
  627. }