|
| 1 | +/* |
| 2 | + * Copyright (c) 2000 World Wide Web Consortium, |
| 3 | + * (Massachusetts Institute of Technology, Institut National de |
| 4 | + * Recherche en Informatique et en Automatique, Keio University). All |
| 5 | + * Rights Reserved. This program is distributed under the W3C's Software |
| 6 | + * Intellectual Property License. This program is distributed in the |
| 7 | + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 8 | + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 9 | + * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more |
| 10 | + * details. |
| 11 | + */ |
| 12 | + |
1 | 13 | package org.w3c.dom; |
2 | 14 |
|
3 | 15 | /** |
4 | | - * The <code>Attr</code> interface represents an attribute in an |
5 | | - * <code>Element</code> object.Typically the allowable values for the |
6 | | - * attribute are defined in a documenttype definition. |
| 16 | + * The <code>Attr</code> interface represents an attribute in an |
| 17 | + * <code>Element</code> object. Typically the allowable values for the |
| 18 | + * attribute are defined in a document type definition. |
7 | 19 | * <p><code>Attr</code> objects inherit the <code>Node</code> interface, but |
8 | 20 | * since they are not actually child nodes of the element they describe, the |
9 | 21 | * DOM does not consider them part of the document tree. Thus, the |
10 | | - * <code>Node</code> attributes <code>parentNode</code>, |
11 | | - * <code>previousSibling</code>, and <code>nextSibling</code> have a null |
12 | | - * value for <code>Attr</code> objects. The DOM takes the view that |
13 | | - * attributes are properties of elements rather than having a separate |
14 | | - * identity from the elements they are associated with; this should make it |
15 | | - * more efficient to implement such features as default attributes associated |
16 | | - * with all elements of a given type. Furthermore, <code>Attr</code> nodes |
17 | | - * may not be immediate children of a <code>DocumentFragment</code>. However, |
18 | | - * they can be associated with <code>Element</code> nodes contained within a |
19 | | - * <code>DocumentFragment</code>. In short, users and implementors of the DOM |
20 | | - * need to be aware that <code>Attr</code> nodes have some things in common |
21 | | - * with other objects inheriting the <code>Node</code> interface, but they |
22 | | - * also are quite distinct. |
| 22 | + * <code>Node</code> attributes <code>parentNode</code> , |
| 23 | + * <code>previousSibling</code> , and <code>nextSibling</code> have a |
| 24 | + * <code>null</code> value for <code>Attr</code> objects. The DOM takes the |
| 25 | + * view that attributes are properties of elements rather than having a |
| 26 | + * separate identity from the elements they are associated with; this should |
| 27 | + * make it more efficient to implement such features as default attributes |
| 28 | + * associated with all elements of a given type. Furthermore, |
| 29 | + * <code>Attr</code> nodes may not be immediate children of a |
| 30 | + * <code>DocumentFragment</code> . However, they can be associated with |
| 31 | + * <code>Element</code> nodes contained within a <code>DocumentFragment</code> |
| 32 | + * . In short, users and implementors of the DOM need to be aware that |
| 33 | + * <code>Attr</code> nodes have some things in common with other objects |
| 34 | + * inheriting the <code>Node</code> interface, but they also are quite |
| 35 | + * distinct. |
23 | 36 | * <p> The attribute's effective value is determined as follows: if this |
24 | 37 | * attribute has been explicitly assigned any value, that value is the |
25 | 38 | * attribute's effective value; otherwise, if there is a declaration for |
|
29 | 42 | * has been explicitly added. Note that the <code>nodeValue</code> |
30 | 43 | * attribute on the <code>Attr</code> instance can also be used to retrieve |
31 | 44 | * the string version of the attribute's value(s). |
32 | | - * <p>In XML, where the value of an attribute can contain entity references, |
| 45 | + * <p> In XML, where the value of an attribute can contain entity references, |
33 | 46 | * the child nodes of the <code>Attr</code> node provide a representation in |
34 | 47 | * which entity references are not expanded. These child nodes may be either |
35 | 48 | * <code>Text</code> or <code>EntityReference</code> nodes. Because the |
36 | 49 | * attribute type may be unknown, there are no tokenized attribute values. |
| 50 | + * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>. |
37 | 51 | */ |
38 | 52 | public interface Attr extends Node { |
39 | | - /** |
40 | | - * Returns the name of this attribute. |
41 | | - */ |
42 | | - public String getName(); |
43 | | - /** |
44 | | - * If this attribute was explicitly given a value in the original document, |
45 | | - * this is <code>true</code>; otherwise, it is <code>false</code>. Note |
46 | | - * that the implementation is in charge of this attribute, not the user. If |
47 | | - * the user changes the value of the attribute (even if it ends up having |
48 | | - * the same value as the default value) then the <code>specified</code> |
49 | | - * flag is automatically flipped to <code>true</code>. To re-specify the |
50 | | - * attribute as the default value from the DTD, the user must delete the |
51 | | - * attribute. The implementation will then make a new attribute available |
52 | | - * with <code>specified</code> set to <code>false</code> and the default |
53 | | - * value (if one exists). |
54 | | - * <br>In summary: If the attribute has an assigned value in the document |
55 | | - * then <code>specified</code> is <code>true</code>, and the value is the |
56 | | - * assigned value. If the attribute has no assigned value in the document |
57 | | - * and has a default value in the DTD, then <code>specified</code> is |
58 | | - * <code>false</code>, and the value is the default value in the DTD. If |
59 | | - * the attribute has no assigned value in the document and has a value of |
60 | | - * #IMPLIED in the DTD, then the attribute does not appear in the |
61 | | - * structure model of the document. |
62 | | - */ |
63 | | - public boolean getSpecified(); |
64 | | - /** |
65 | | - * On retrieval, the value of the attribute is returned as a string. |
66 | | - * Character and general entity references are replaced with their values. |
67 | | - * <br>On setting, this creates a <code>Text</code> node with the unparsed |
68 | | - * contents of the string. |
69 | | - */ |
70 | | - public String getValue(); |
71 | | - public void setValue(String value); |
| 53 | + /** |
| 54 | + * Returns the name of this attribute. |
| 55 | + */ |
| 56 | + public String getName(); |
| 57 | + |
| 58 | + /** |
| 59 | + * If this attribute was explicitly given a value in the original |
| 60 | + * document, this is <code>true</code> ; otherwise, it is |
| 61 | + * <code>false</code> . Note that the implementation is in charge of this |
| 62 | + * attribute, not the user. If the user changes the value of the |
| 63 | + * attribute (even if it ends up having the same value as the default |
| 64 | + * value) then the <code>specified</code> flag is automatically flipped |
| 65 | + * to <code>true</code> . To re-specify the attribute as the default |
| 66 | + * value from the DTD, the user must delete the attribute. The |
| 67 | + * implementation will then make a new attribute available with |
| 68 | + * <code>specified</code> set to <code>false</code> and the default value |
| 69 | + * (if one exists). |
| 70 | + * <br> In summary: If the attribute has an assigned value in the document |
| 71 | + * then <code>specified</code> is <code>true</code> , and the value is |
| 72 | + * the assigned value. If the attribute has no assigned value in the |
| 73 | + * document and has a default value in the DTD, then |
| 74 | + * <code>specified</code> is <code>false</code> , and the value is the |
| 75 | + * default value in the DTD. If the attribute has no assigned value in |
| 76 | + * the document and has a value of #IMPLIED in the DTD, then the |
| 77 | + * attribute does not appear in the structure model of the document. If |
| 78 | + * the <code>ownerElement</code> attribute is <code>null</code> (i.e. |
| 79 | + * because it was just created or was set to <code>null</code> by the |
| 80 | + * various removal and cloning operations) <code>specified</code> is |
| 81 | + * <code>true</code> . |
| 82 | + */ |
| 83 | + public boolean getSpecified(); |
| 84 | + |
| 85 | + /** |
| 86 | + * On retrieval, the value of the attribute is returned as a string. |
| 87 | + * Character and general entity references are replaced with their |
| 88 | + * values. See also the method <code>getAttribute</code> on the |
| 89 | + * <code>Element</code> interface. |
| 90 | + * <br> On setting, this creates a <code>Text</code> node with the unparsed |
| 91 | + * contents of the string. I.e. any characters that an XML processor |
| 92 | + * would recognize as markup are instead treated as literal text. See |
| 93 | + * also the method <code>setAttribute</code> on the <code>Element</code> |
| 94 | + * interface. |
| 95 | + * @exception DOMException |
| 96 | + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
| 97 | + */ |
| 98 | + public String getValue(); |
| 99 | + public void setValue(String value) |
| 100 | + throws DOMException; |
| 101 | + |
| 102 | + /** |
| 103 | + * The <code>Element</code> node this attribute is attached to or |
| 104 | + * <code>null</code> if this attribute is not in use. |
| 105 | + * @since DOM Level 2 |
| 106 | + */ |
| 107 | + public Element getOwnerElement(); |
| 108 | + |
72 | 109 | } |
73 | 110 |
|
0 commit comments