|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="docbook.css" type="text/css"?> |
|
3 <!DOCTYPE Book SYSTEM "docbook.dtd"> |
|
4 <Book xmlns:xlink="http://www.w3.org/1999/xlink"> |
|
5 <Title>SoftQuad |
|
6 Inc.</Title> |
|
7 <p xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml"> |
|
8 <h:img src="flamer.gif"/> |
|
9 <img src="flamer.gif"/> |
|
10 <button><b>some text</b></button> |
|
11 </p> |
|
12 <BookInfo> <BookBiblio> <Title>Demo Product Documentation</Title> |
|
13 <AuthorGroup><CorpAuthor>SoftQuad Inc.</CorpAuthor></AuthorGroup> |
|
14 </BookBiblio> </BookInfo> <Preface> <Title><Anchor |
|
15 Id="SDK3"/>Element Overview</Title> |
|
16 <BridgeHead>Introduction to Elements</BridgeHead> |
|
17 <Para>By far the vast majority of objects (apart from text) that authors |
|
18 encounter when traversing a document are Element nodes. </Para> </Preface> |
|
19 <Part> <Title><Anchor Id="SDK273"/>Element Interfaces</Title> |
|
20 <Chapter Label="1"> <Title><Anchor Id="SDK274"/>Elements and |
|
21 Attributes</Title> |
|
22 <Sect1> <Title><Anchor Id="SDK279"/>Introduction to Attributes |
|
23 </Title> |
|
24 <Para>Elements may have attributes associated with them; since the Element |
|
25 interface inherits from Node, the generic Node interface method |
|
26 <Function>getAttributes</Function> may be used to retrieve the set of all |
|
27 attributes for an element. </Para> |
|
28 <Para>There are methods on the Element interface to retrieve either an Attr |
|
29 object by name or an attribute value by name. In XML, where an attribute value |
|
30 may contain entity references, an Attr object should be retrieved to examine |
|
31 the possibly fairly complex sub-tree representing the attribute value. On the |
|
32 other hand, in HTML, where all attributes have simple string values, methods to |
|
33 directly access an attribute value can safely be used as a convenience. </Para> |
|
34 |
|
35 <Para>Before you can access an Attribute, you must first gain access to the |
|
36 associated Element.</Para> </Sect1> |
|
37 <Sect1> <Title><Anchor Id="SDK378"/>Setting the Attribute |
|
38 Values</Title> |
|
39 <Para>Attr objects inherit the Node interface, but since they are not actually |
|
40 child nodes of the element they describe, the DOM does not consider them part |
|
41 of the document tree. Thus, the Node attributes parentNode, previousSibling, |
|
42 and nextSibling have a null value for Attr objects. The DOM takes the view that |
|
43 attributes are properties of elements rather than having a separate identity |
|
44 from the elements they are associated with; this should make it more efficient |
|
45 to implement such features as default attributes associated with all elements |
|
46 of a given type. Furthermore, Attr nodes may not be immediate children of a |
|
47 DocumentFragment. However, they can be associated with Element nodes contained |
|
48 within a DocumentFragment. In short, users and implementors of the DOM need to |
|
49 be aware that Attr nodes have some things in common with other objects |
|
50 inheriting the Node interface, but they also are quite distinct. </Para> |
|
51 <Para>The attribute's effective value is determined as follows:</Para> |
|
52 <ItemizedList Mark="Bullet"> <ListItem> |
|
53 <Para>If this attribute has been explicitly assigned any value, that value is |
|
54 the attribute's effective value</Para></ListItem> <ListItem> |
|
55 <Para>Otherwise, if there is a declaration for this attribute, and that |
|
56 declaration includes a default value, then that default value is the |
|
57 attribute's effective value</Para></ListItem> <ListItem> |
|
58 <Para>Otherwise, the attribute does not exist on this element in the structure |
|
59 model until it has been explicitly added.</Para></ListItem> </ItemizedList> |
|
60 <Para>In XML, where the value of an attribute can contain entity references, |
|
61 the child nodes of the Attr node provide a representation in which entity |
|
62 references are not expanded. These child nodes may be either Text or |
|
63 EntityReference nodes. Because the attribute type may be unknown, there are no |
|
64 tokenized attribute values. </Para> |
|
65 <Para>The following topics describe DOM attributes: </Para> |
|
66 <ItemizedList Mark="Bullet"> <ListItem> |
|
67 <Para> |
|
68 <ULink xlink:type="simple" xlink:show="replace" |
|
69 xlink:href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-637646024">Interface |
|
70 Attr</ULink> </Para></ListItem> <ListItem> |
|
71 <Para> |
|
72 <ULink xlink:type="simple" xlink:show="new" |
|
73 xlink:href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-745549614"> |
|
74 Interface Element</ULink> </Para></ListItem> </ItemizedList> </Sect1></Chapter> |
|
75 |
|
76 <Chapter Label="26" Role="funcref"> <Title><Anchor |
|
77 Id="SDK48"/>DOM Level 1 Core: Element Functions</Title> |
|
78 <RefEntry> <RefMeta><RefEntryTitle> <Anchor Id="setAttribute"/>setAttribute |
|
79 </RefEntryTitle></RefMeta> <RefNameDiv> <RefName>setAttribute</RefName> |
|
80 <RefPurpose>Sets the Attributes on the associated Element object</RefPurpose> |
|
81 <RefClass>Fundamental</RefClass> </RefNameDiv> <RefSynopsisDiv> <Title> |
|
82 <Anchor Id="SDK85"/>Syntax</Title> |
|
83 <RefSect2> <Title>OMG IDL</Title> |
|
84 <Synopsis><Type>void</Type> <Function>setAttribute</Function> (in |
|
85 <Type>DOMString</Type> <Parameter>name</Parameter>, in <Type>DOMString</Type> |
|
86 <Parameter>value</Parameter>) raises (<ErrorType>DOMException</ErrorType>); |
|
87 </Synopsis></RefSect2><RefSect2> <Title><Anchor Id="SDK86"/>Java</Title> |
|
88 <Synopsis><Type>public void</Type> <Function>setAttribute</Function> ( |
|
89 <Type>String</Type> <Parameter>name</Parameter>, <Type>String</Type> |
|
90 <Parameter>value</Parameter>) throws (<ErrorType>DOMException</ErrorType>); |
|
91 </Synopsis> </RefSect2><RefSect2> <Title><Anchor Id="SDK87"/>ECMA Script |
|
92 </Title> |
|
93 <Synopsis> <Function>setAttribute</Function> (<Parameter>name, value |
|
94 </Parameter>)</Synopsis> </RefSect2></RefSynopsisDiv><RefSect1> <Title> |
|
95 <Anchor Id="SDK88"/>Parameters</Title> |
|
96 <VariableList> <VarListEntry><Term> <Parameter>name</Parameter></Term> |
|
97 <ListItem> |
|
98 <Para>(IN) The name of the attribute to create or alter.</Para> </ListItem> |
|
99 </VarListEntry><VarListEntry><Term> <Parameter>value</Parameter></Term> |
|
100 <ListItem> |
|
101 <Para>(IN) Value to set in string form</Para> </ListItem></VarListEntry> |
|
102 </VariableList></RefSect1><RefSect1> <Title><Anchor Id="SDK89"/>Exceptions |
|
103 </Title> |
|
104 <Para>These are the applicable exceptions. </Para> <InformalTable> <TGroup cols="2"> |
|
105 <colspec colname="1" colnum="1" colwidth="0.630in"/> |
|
106 <colspec colname="2" colnum="2" colwidth="5.203in"/> <tbody> |
|
107 <row> <entry colname="1"> |
|
108 <Para>INVALID_CHARACTER_ERR</Para></entry> <entry colname="2"> |
|
109 <Para>Raised if the specified name contains an invalid character.</Para> |
|
110 </entry></row> <row> <entry colname="1"> |
|
111 <Para> NO_MODIFICATION_ALLOWED_ERR</Para></entry> <entry colname="2"> |
|
112 <Para>Raised if this node is readonly.</Para></entry> </row> |
|
113 </tbody> |
|
114 </TGroup></InformalTable></RefSect1><RefSect1> <Title><Anchor |
|
115 Id="SDK90"/>Remarks</Title> |
|
116 <Para> <Function>setAttribute</Function> adds a new attribute. If an attribute |
|
117 with that name is already present in the element, its value is changed to be |
|
118 that of the value parameter. This value is a simple string, it is not parsed as |
|
119 it is being set. So any markup (such as syntax to be recognized as an entity |
|
120 reference) is treated as literal text, and needs to be appropriately escaped by |
|
121 the implementation when it is written out.</Para> |
|
122 <Para> In order to assign an attribute value that contains entity references, |
|
123 the user must create an Attr node plus any Text and EntityReference nodes, |
|
124 build the appropriate subtree, and use <Function>setAttributeNode</Function> to |
|
125 assign it as the value of an attribute. </Para> </RefSect1></RefEntry> |
|
126 </Chapter></Part></Book> |