1. 文書オブジェクトモデルコア
1. Document Object Model Core

1.1 DOMコアインタフェースの概要
1.1. Overview of the DOM Core Interfaces

1.1では,文書オブジェクトにアクセスしそれらを操作するためのオブジェクト及びインタフェースの集合を定義する。1.1で規定する機能(コア 機能)は,ソフトウェア開発者及びウェブスクリプト作成者が,適合する製品の内部で構文解析されたHTML及びXMLの内容にアクセスしそれらを操作できるのに十分なものとする。DOMコアAPIは,DOM API呼出しだけを使って,Documentオブジェクトを生成し存在させることも可能とする。Documentのロード及びそれの永続的な保存は,DOM APIを実装する製品に委ねることとする。

This section defines a set of objects and interfaces for accessing and manipulating document objects. The functionality specified in this section (the Core functionality) is sufficient to allow software developers and web script authors to access and manipulate parsed HTML and XML content inside conforming products. The DOM Core API also allows creation and population of a Document object using only DOM API calls; loading a Document and saving it persistently is left to the product that implements the DOM API.

1.1.1 DOM構造モデル
1.1.1. The DOM Structure Model

DOMは,他の更に特殊化されたインタフェースも実装するNodeオブジェクトの階層として,文書を表現する。ノードのある型は,様々な型の ノードをもってよく,ノードのその他の型は,文書構造においてそれよりも下位に何ももつことができない葉ノードとなる。XML及びHTMLに対して,そのノード型,及びそれらが子供としてどのノード型をもってよいかを,次に示す。

The DOM presents documents as a hierarchy of Node objects that also implement other, more specialized interfaces. Some types of nodes may have child nodes of various types, and others are leaf nodes that cannot have anything below them in the document structure. For XML and HTML, the node types, and which node types they may have as children, are as follows:

DOMは,Nodeの子供又はElementインタフェースのgetElementsByTagNameメソッドが返す element 要素といった順序付きリストを扱うためにNodeListインタフェースも規定する。さらに,Elementの属性などの名前属性が参照するノードの順序なし集合を扱うためにNamedNodeMapも規定する。DOMにおける NodeListオブジェクト及びNamedNodeMapオブジェクトは,活性化している(live)とする。すなわち,元となる文書構造への変更は,すべての関連するNodeListオブジェクト及びNamedNodeMapオブジェクトに反映される。例えば,DOM利用者がElementの子供を含むNodeListオブジェクトを得て,それに続いて,その 要素 に子供を更に追加する(,子供を削除する,又は子供を修正する)場合,それらの変更は,利用者側でそれ以上のことをしなくとも,自動的にNodeListに反映される。同様に,木のNodeへの変更は,NodeList及びNamedNodeMapにおけるそのNodeへのすべての参照に反映される。

The DOM also specifies a NodeList interface to handle ordered lists of Nodes, such as the children of a Node, or the elements returned by the getElementsByTagName method of the Element interface, and also a NamedNodeMap interface to handle unordered sets of nodes referenced by their name attribute, such as the attributes of an Element. NodeList and NamedNodeMap objects in the DOM are live; that is, changes to the underlying document structure are reflected in all relevant NodeList and NamedNodeMap objects. For example, if a DOM user gets a NodeList object containing the children of an Element, then subsequently adds more children to that element (or removes children, or modifies them), those changes are automatically reflected in the NodeList, without further action on the user's part. Likewise, changes to a Node in the tree are reflected in all references to that Node in NodeList and NamedNodeMap objects.

Textインタフェース,Commentインタフェース及びCDATASectionインタフェースは,すべて,CharacterDataインタフェースから継承される。

Finally, the interfaces Text, Comment, and CDATASection all inherit from the CharacterData interface.

1.1.2 メモリ管理
1.1.2. Memory Management

この規定が定義するAPIの大部分は,クラスではなく インタフェース とする。これは,実装には,定義された名前及び規定された操作をもつメソッドの開示だけが必要とされ,直接にそのインタフェースに対応するクラスの実装は必要とはされないことを意味する。これによって,それ自体のデータ構造をもつ既存アプリケーションの上に,又は異なるクラス階層をもつ新しいアプリケーションの上に,薄い張り板を張るようにDOM APIを実装することが可能になる。このことは,構成される必要がある基盤となるオブジェクトがDOMインタフェースと関係をほとんどもたなくともよいので,Java又はC++の意味での通常のコンストラクタは,DOMオブジェクトを生成するために使用できないことも意味する。この問題に対するオブジェクト指向設計での従来の解は,様々なインタフェースを実装するオブジェクトのインスタンスを複数生成する ファクトリ(factory) メソッドを定義することである。インタフェース"X"を実装するオブジェクトは,Documentインタフェースの"createX()"メソッドによって生成される。この理由は,すべてのDOMオブジェクトは,特定の文書の文脈中で活性化(live)していることによる。

Most of the APIs defined by this specification are interfaces rather than classes. That means that an implementation need only expose methods with the defined names and specified operation, not implement classes that correspond directly to the interfaces. This allows the DOM APIs to be implemented as a thin veneer on top of legacy applications with their own data structures, or on top of newer applications with different class hierarchies. This also means that ordinary constructors (in the Java or C++ sense) cannot be used to create DOM objects, since the underlying objects to be constructed may have little relationship to the DOM interfaces. The conventional solution to this in object-oriented design is to define factory methods that create instances of objects that implement the various interfaces. Objects implementing some interface "X" are created by a "createX()" method on the Document interface; this is because all DOM objects live in the context of a specific Document.

DOM水準2のAPIは,DOMImplementationオブジェクトを生成する標準的な方法を定義 しない。すなわち,DOM実装は,これらのDOMインタフェースをブートストラップする独自の方法を提供しなければならない。他のすべてのオブジェクトは,そこから構築できる。

The DOM Level 2 API does not define a standard way to create DOMImplementation objects; DOM implementations must provide some proprietary way of bootstrapping these DOM interfaces, and then all other objects can be built from there.

コアDOM APIは,一般利用者のスクリプト言語,及び主として専門家のプログラマが使用するより挑戦的な言語の両方を含む,広範囲な言語との互換性をもつ設計がなされている。したがって,DOM APIは,多様なメモリ管理方式に渡って動作する必要がある。すなわち,メモリ管理を利用者に全く見せない言語への束縛,すなわち,明示的なコンストラクタを提供するが,未使用メモリを自動的に回収するための自動ガベジコレクション機構を提供する言語(特にJava)への束縛から,オブジェクトメモリを明示的に割り当て,それが使用されている場所を追跡し,再使用のためにそれを明示的に解放することを一般にプログラマに要求する言語(特にC及びC++)への束縛までの様々な方式で動作する必要がある。これらのプラットフォームに渡って一貫性のあるAPIを保証するために,DOMは,メモリ管理の問題に言及せず,代わりに,この問題を実装に任せる。(ECMAScript及びJavaのために)DOM APIが定義する明示的な言語束縛は,いずれも,メモリ管理メソッドを必要としないが,他の言語(特にC又はC++)に対するDOM束縛は,そのサポートを必要としてもよい。これらの拡張は,DOM APIを特定の言語に適合させる者の責任とし,DOM作業グループの責任とはしない。

The Core DOM APIs are designed to be compatible with a wide range of languages, including both general-user scripting languages and the more challenging languages used mostly by professional programmers. Thus, the DOM APIs need to operate across a variety of memory management philosophies, from language bindings that do not expose memory management to the user at all, through those (notably Java) that provide explicit constructors but provide an automatic garbage collection mechanism to automatically reclaim unused memory, to those (especially C/C++) that generally require the programmer to explicitly allocate object memory, track where it is used, and explicitly free it for re-use. To ensure a consistent API across these platforms, the DOM does not address memory management issues at all, but instead leaves these for the implementation. Neither of the explicit language bindings defined by the DOM API (for ECMAScript and Java) require any memory management methods, but DOM bindings for other languages (especially C or C++) may require such support. These extensions will be the responsibility of those adapting the DOM API to a specific language, not the DOM Working Group.

1.1.3 命名規約
1.1.3. Naming Conventions

短く,形式的ではなく,内部矛盾がなく,同様のAPIの利用者に馴染み深い属性名及びメソッド名をもつことはよいことだが,その名前が,DOM実装がサポートする既存のAPIにおける名前と衝突することは望ましくない。さらに,OMG IDL及びECMAScriptの両方とも,異なる名前空間を用いて名前のあいまい性を解消する能力に致命的な限界をもっており,これが,短く,馴染み深い名前の名前衝突を避けることを困難にしている。そこで,DOMでの名前は,すべての環境に渡って一意とするために,長く,記述的になる傾向にある。

While it would be nice to have attribute and method names that are short, informative, internally consistent, and familiar to users of similar APIs, the names also should not clash with the names in legacy APIs supported by DOM implementations. Furthermore, both OMG IDL and ECMAScript have significant limitations in their ability to disambiguate names from different namespaces that make it difficult to avoid naming conflicts with short, familiar names. So, DOM names tend to be long and descriptive in order to be unique across all environments.

作業グループは,様々な用語を用いて内部的に矛盾しないように心掛けもした。ただし,これらの用語は,他のAPIで共通的な区別がなされているとは限らないこともある。例えば,DOM APIは,メソッドが構造モデルを変更する場合にメソッド名"remove(取り除く。名詞は除去。)"を使用し,メソッドが構造モデルの内部の何かを消し去る場合にメソッド名"delete(削除する。名詞は削除。)"を使用する。削除されたものは返されない。取り除かれたものは,それを返すことに意味がある場合には,返されることもある。

The Working Group has also attempted to be internally consistent in its use of various terms, even though these may not be common distinctions in other APIs. For example, the DOM API uses the method name "remove" when the method changes the structural model, and the method name "delete" when the method gets rid of something inside the structure model. The thing that is deleted is not returned. The thing that is removed may be returned, when it makes sense to return it.

1.1.4 APIの継承ビューと平坦ビューとの比較
1.1.4. Inheritance vs. Flattened Views of the API

DOMコア API は,XML文書又はHTML文書へのインタフェースの二つの幾分異なる集合を表現する。それらは, 継承 の階層を用いる"オブジェクト指向"アプローチを表現するインタフェースと,(Java及びC言語に類似した他の言語における)キャスト又は COM 環境での問合せインタフェース呼出しを要求することなしにNodeインタフェース経由ですべての操作を行えるようにする"単純化された"ビューとの二つとする。これらの操作は,Java及びCOMでは幾分高価なものとなるが,DOMは,性能が重要となる環境で使用してもよい。そこで,Nodeインタフェースを使うだけで重要な機能を可能にできるようにする。 継承 階層を"すべてをNodeとする"DOMへのアプローチよりも理解しやすいとする利用者も多いので,よりオブジェクト指向的な API を好む利用者のために,より高位の完全なインタフェースもサポートする。

The DOM Core APIs present two somewhat different sets of interfaces to an XML/HTML document: one presenting an "object oriented" approach with a hierarchy of inheritance, and a "simplified" view that allows all manipulation to be done via the Node interface without requiring casts (in Java and other C-like languages) or query interface calls in COM environments. These operations are fairly expensive in Java and COM, and the DOM may be used in performance-critical environments, so we allow significant functionality using just the Node interface. Because many other users will find the inheritance hierarchy easier to understand than the "everything is a Node" approach to the DOM, we also support the full higher-level interfaces for those who prefer a more object-oriented API.

実際には,このことは, API にある程度の冗長性が存在することを意味する。(DOM2の)作業グループは," 継承 "のアプローチをAPIの基本的なビューとし,Nodeに関する機能の完全な集合を利用者が利用してもよい"余分な"機能と考えている。しかし,そのことは,オブジェクト指向解析が示す他のインタフェース上のメソッドの必要性がなくなるわけではない。もちろん,オブジェクト指向解析がNodeインタフェース上のものと同一な属性又はメソッドを与える場合には,完全に冗長なものを規定はしない。このようにして,Nodeインタフェース上に一般的なnodeName属性が存在する場合であっても,Elementインタフェース上にtagName属性が存在する。これらの二つの属性は,同じ値を含まなければならないが,DOM API には満足を与えなければならない異なる利用者がいるので,両方をサポートすることには価値がある。

In practice, this means that there is a certain amount of redundancy in the API. The Working Group considers the "inheritance" approach the primary view of the API, and the full set of functionality on Node to be "extra" functionality that users may employ, but that does not eliminate the need for methods on other interfaces that an object-oriented analysis would dictate. (Of course, when the O-O analysis yields an attribute or method that is identical to one on the Node interface, we don't specify a completely redundant one.) Thus, even though there is a generic nodeName attribute on the Node interface, there is still a tagName attribute on the Element interface; these two attributes must contain the same value, but the it is worthwhile to support both, given the different constituencies the DOM API must satisfy.

1.1.5 DOMString
1.1.5. The DOMString type

相互運用性を確実にするために,DOMは,次を規定する。

To ensure interoperability, the DOM specifies the following:

  • 型定義 DOMString
    Type Definition DOMString

    DOMStringは,16ビット単位 の並びとする。

    A DOMString is a sequence of 16-bit units.


    IDL定義
    IDL Definition
    valuetype DOMString sequence<unsigned short>;
    

  • アプリケーションは,([Unicode],及び[ISO/IEC 10646]の追補1で定義された)UTF-16を使ってDOMStringを符号化しなければならない。
    UTF-16符号化は,その広範囲な産業界での実績のために選択された。HTML及びXMLの両方に対して,文書の文字集合(及びそのために数値文字参照の記法)は,UCS [ISO-10646]に基づくことに注意すること。そこで,源となる文書における一つの数値文字参照が,DOMStringでは二つの16ビット単位(高位サロゲート及び低位サロゲート)に対応する場合があってもよい。
    Applications must encode DOMString using UTF-16 (defined in [Unicode] and Amendment 1 of [ISO/IEC 10646]).
    The UTF-16 encoding was chosen because of its widespread industry practice. Note that for both HTML and XML, the document character set (and therefore the notation of numeric character references) is based on UCS [ISO-10646]. A single numeric character reference in a source document may therefore in some cases correspond to two 16-bit units in a DOMString (a high surrogate and a low surrogate).

    備考  DOMは,文字型の名前をDOMStringと定義しているが,(言語)束縛では異なる名前を使用してもよい。例えばJavaに対しては,DOMStringString型に束縛される。これは,その符号化としてUTF-16を使用することによる。

    Note: Even though the DOM defines the name of the string type to be DOMString, bindings may use different names. For example for Java, DOMString is bound to the String type because it also uses UTF-16 as its encoding.

備考  2000年8月の時点で,OMG IDL規定([OMGIDL])は,wstring型を含んでいた。しかし,その定義は,文字の幅(バイト数)及び符号化の決定を折衝に依存するので,DOM API の相互運用性基準を満たさなかった。

Note: As of August 2000, the OMG IDL specification ([OMGIDL]) included a wstring type. However, that definition did not meet the interoperability criteria of the DOM API since it relied on negotiation to decide the width and encoding of a character.

1.1.6 DOMTimeStamp
1.1.6. The DOMTimeStamp type

相互運用性を確実にするために,DOMは,次を規定する。

To ensure interoperability, the DOM specifies the following:

  • 型定義 DOMTimeStamp
    Type Definition DOMTimeStamp
    DOMTimeStampは,ミリ秒の数を表現する。

    A DOMTimeStamp represents a number of milliseconds.


    IDL定義
    IDL Definition
    typedef unsigned long long DOMTimeStamp;
    

  • 備考  DOMは,型DOMTimeStampを使用するが,(言語)束縛では異なる型を使用してもよい。例えばJavaに対しては,DOMTimeStampは,long型に束縛される。ECMAScriptでは,integer型の範囲があまりにも小さいので,TimeStampは,Date型に束縛される。

    Note: Even though the DOM uses the type DOMTimeStamp, bindings may use different types. For example for Java, DOMTimeStamp is bound to the long type. In ECMAScript, TimeStamp is bound to the Date type because the range of the integer type is too small.

1.1.7 DOMにおける文字列比較
1.1.7. String comparisons in the DOM

DOMは,文字列の照合(マッチ,matching)を示す多くのインタフェースをもつ。HTMLプロセサは,一般に,要素 などの名前を大文字に(非常にまれに小文字に)正規化すると仮定する。一方で,XMLは明示的に大文字・小文字を区別する。DOMの目的のためには,文字列照合は,DOMString 16ビット単位 のバイナリ 比較 によってそのまま実行される。さらに,DOMは,あらゆる大文字・小文字の正規化は,DOM構造が構築される 前に,プロセサで行われると仮定する。

The DOM has many interfaces that imply string matching. HTML processors generally assume an uppercase (less often, lowercase) normalization of names for such things as elements, while XML is explicitly case sensitive. For the purposes of the DOM, string matching is performed purely by binary comparison of the 16-bit units of the DOMString. In addition, the DOM assumes that any case normalizations take place in the processor, before the DOM structures are built.

備考  大文字・小文字の正規化に加えて,テキストに対して適用できる付加的な正規化が存在する。W3Cの国際化作業グループでは,どの正規化が必要か,それらをどこで適用するのがよいかを正確に定義することを検討している。W3Cの国際化作業グループは,早い段階で正規化を要求することを期待している。このことは,DOMに読み込まれるデータは,既に正規化されていると仮定することを意味する。この場合,DOM及びその上に構築されるアプリケーションだけが,テキストが変更された場合にテキストは正規化された状態を維持していることを保証しなければならない。詳細については,[Charmod]を参照すること。

Note: Besides case folding, there are additional normalizations that can be applied to text. The W3C I18N Working Group is in the process of defining exactly which normalizations are necessary, and where they should be applied. The W3C I18N Working Group expects to require early normalization, which means that data read into the DOM is assumed to already be normalized. The DOM and applications built on top of it in this case only have to assure that text remains normalized when being changed. For further details, please see [Charmod].

1.1.8 XML名前空間
1.1.8. XML Namespaces

DOM水準2は,XML名前空間[Namespaces]をサポートする。これは,DOM水準1の幾つかのインタフェースを強化し,名前空間に関連する 要素 及び属性を生成し操作できるようにすることによって行われる。

The DOM Level 2 supports XML namespaces [Namespaces] by augmenting several interfaces of the DOM Level 1 Core to allow creating and manipulating elements and attributes associated to a namespace.

DOMに関する限り,XML名前空間 を宣言するために使用する特殊な属性が,今のところ開示されており,他の属性と同様に操作できる。しかし,ノードは,生成されると,永久に 名前空間URI に束縛される。その結果,DOMを使って文書内でノードを移動させても,決して,名前空間接頭辞 にも名前空間URIにも変化は生じない。同様に,名前空間接頭辞及び名前空間URIをもつノードを生成したりノードの名前空間接頭辞を変更しても,適切なXML名前空間を宣言するためにいかなる特殊な属性の追加,削除又は修正が生じることはない。名前空間の妥当性検証は強制されない。DOMアプリケーションの責任とする。特に,接頭辞と名前空間URIとの間の対応付けは強制されないので,一般に,結果として生じる文書は単純には直列化できない。例えば,アプリケーションは,文書を直列化する場合には,使用しているすべての名前空間を宣言しなければならないかもしれない。

As far as the DOM is concerned, special attributes used for declaring XML namespaces are still exposed and can be manipulated just like any other attribute. However, nodes are permanently bound to namespace URIs as they get created. Consequently, moving a node within a document, using the DOM, in no case results in a change of its namespace prefix or namespace URI. Similarly, creating a node with a namespace prefix and namespace URI, or changing the namespace prefix of a node, does not result in any addition, removal, or modification of any special attributes for declaring the appropriate XML namespaces. Namespace validation is not enforced; the DOM application is responsible. In particular, since the mapping between prefixes and namespace URIs is not enforced, in general, the resulting document cannot be serialized naively. For example, applications may have to declare every namespace in use when serializing a document.

DOM水準2は,いかなるURIの正規化又は正準化も実行しない。DOMに与えられたURIは,(例えば,空白などの文字が正しく別扱いされているなどに関して)妥当と仮定され,字句的な検査は実行されない。絶対URI参照は,文字列として扱われ,文字ごとに比較される。相対名前空間URI参照を取り扱う方法は定義しない。相互運用性を確実にするために,絶対名前空間URI参照(すなわち,方式名及びコロンで始まるURI参照)だけを使用するのが望ましい。DOMは字句的な検査を行わないので,DOM水準2のメソッドでは,空文字列は現実の名前空間URIとして扱われることに注意すること。アプリケーションは,名前空間をもつことを望まない場合には,メソッドに対する名前空間URIパラメタとして値nullを使用しなければならない。

DOM Level 2 doesn't perform any URI normalization or canonicalization. The URIs given to the DOM are assumed to be valid (e.g., characters such as whitespaces are properly escaped), and no lexical checking is performed. Absolute URI references are treated as strings and compared literally. How relative namespace URI references are treated is undefined. To ensure interoperability only absolute namespace URI references (i.e., URI references beginning with a scheme name and a colon) should be used. Note that because the DOM does no lexical checking, the empty string will be treated as a real namespace URI in DOM Level 2 methods. Applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

備考  DOMにおいて,すべての名前空間宣言属性は,定義によって,名前空間URI"http://www.w3.org/2000/xmlns/"に束縛される。これらは,名前空間接頭辞 又は 修飾された名前 を"xmlns"とする属性とする。この標準情報(TR)の原規定の作成時には,これはXML名前空間規定[Namespaces]の一部ではないが,将来の版では含まれる予定になっている。

Note: In the DOM, all namespace declaration attributes are by definition bound to the namespace URI: "http://www.w3.org/2000/xmlns/". These are the attributes whose namespace prefix or qualified name is "xmlns". Although, at the time of writing, this is not part of the XML Namespaces specification [Namespaces], it is planned to be incorporated in a future revision.

名前空間をもたない文書の中では,EntityReferenceノードの リストは,常に,対応するEntityの子リストと同じとする。これは,実体が束縛されていない 名前空間接頭辞 を含む文書では正しくない。それらの場合には,対応するEntityReferenceノードの 子孫 が,実体参照が存在する場所に依存して,異なる 名前空間URI に束縛されてよい。DOMではノードは常に同じ名前空間URIに束縛され続けるので,それらEntityReferenceノードを移動させることが,直列化できない文書を生じる可能性もある。このことは,DocumentインタフェースのDOM水準1のcreateEntityReferenceメソッドを,それら実体に対応する実体参照を生成するために使用する場合にも正しい。これは,返されたEntityReference 子孫 は束縛されていないことによる。DOM水準2は,名前空間接頭辞を解決する機構をサポートしない。これらすべての理由のために,それら実体及び実体参照は,使用しないか,又は非常に注意して使用することが望ましい。DOMの将来の水準には,これらを取り扱うための追加のサポートを含まれるかもしれない。

In a document with no namespaces, the child list of an EntityReference node is always the same as that of the corresponding Entity. This is not true in a document where an entity contains unbound namespace prefixes. In such a case, the descendants of the corresponding EntityReference nodes may be bound to different namespace URIs, depending on where the entity references are. Also, because, in the DOM, nodes always remain bound to the same namespace URI, moving such EntityReference nodes can lead to documents that cannot be serialized. This is also true when the DOM Level 1 method createEntityReference of the Document interface is used to create entity references that correspond to such entities, since the descendants of the returned EntityReference are unbound. The DOM Level 2 does not support any mechanism to resolve namespace prefixes. For all of these reasons, use of such entities and entity references should be avoided or used with extreme care. A future Level of the DOM may include some additional support for handling these.

DocumentインタフェースのcreateElementNS及びcreateAttributeNSといった新しいメソッドは,名前空間を意識したアプリケーションが使用することを意図している。名前空間を使用しない単純なアプリケーションは,createElement及びcreateAttributeといったDOM水準1のメソッドを使用できる。この方法で生成される要素及び属性は,名前空間接頭辞,名前空間URI又は局所名をもたない。

The new methods, such as createElementNS and createAttributeNS of the Document interface, are meant to be used by namespace aware applications. Simple applications that do not use namespaces can use the DOM Level 1 methods, such as createElement and createAttribute. Elements and attributes created in this way do not have any namespace prefix, namespace URI, or local name.

備考  DOM水準1のメソッドは,名前空間を無視する。そのために,名前空間を扱わない場合にはこれらのメソッドを使用するのは安全だが,それらと新しいものとを同時に使用することは避けたほうがよい。DOM水準1のメソッドだけが,それらのnodeNameによって属性ノードを識別する。これに対して,名前空間に関係するDOM水準2のメソッドは,それらのnamespaceURI及びlocalNameによって属性ノードを識別する。この基本的な違いのために,メソッドの両方の集合を混合することは,予測できない結果を生じる可能性がある。特に,setAttributeNSを使うと, 要素 は,同じnodeNameをもつが異なるnamespaceURIをもつ二つ(以上)の属性をもつかもしれない。そのnodeNameを用いてgetAttributeを呼び出すと,これら属性のどれかが返される。その結果は,実装に依存する。同様に,setAttributeNodeを使うと,異なるnodeNamesをもつが同じprefix及びnamespaceURIをもつ二つ(以上)の属性をもつかもしれない。この場合,getAttributeNodeNSは,実装に依存する方法で,どちらかの属性を返す。これらの場合に保証されるのは,そのnodeNameによって名前付けされた項目にアクセスするすべてのメソッドが,その同じ項目にアクセスし,そのURI及び局所名によってノードにアクセスするすべてのメソッドが,その同じノードにアクセスする,ということだけになる。例えば,setAttribute及びsetAttributeNSは,getAttribute及びgetAttributeNSがそれぞれ返すノードに影響する。

Note: DOM Level 1 methods are namespace ignorant. Therefore, while it is safe to use these methods when not dealing with namespaces, using them and the new ones at the same time should be avoided. DOM Level 1 methods solely identify attribute nodes by their nodeName. On the contrary, the DOM Level 2 methods related to namespaces, identify attribute nodes by their namespaceURI and localName. Because of this fundamental difference, mixing both sets of methods can lead to unpredictable results. In particular, using setAttributeNS, an element may have two attributes (or more) that have the same nodeName, but different namespaceURIs. Calling getAttribute with that nodeName could then return any of those attributes. The result depends on the implementation. Similarly, using setAttributeNode, one can set two attributes (or more) that have different nodeNames but the same prefix and namespaceURI. In this case getAttributeNodeNS will return either attribute, in an implementation dependent manner. The only guarantee in such cases is that all methods that access a named item by its nodeName will access the same item, and all methods which access a node by its URI and local name will access the same node. For instance, setAttribute and setAttributeNS affect the node that getAttribute and getAttributeNS, respectively, return.

1.2 基礎インタフェース
1.2. Fundamental Interfaces

1.2におけるインタフェースは,基礎的 と考えられ,特に指定されない限り,すべてのHTML DOM実装[DOM Level 2 HTML]を含む,DOMのすべての適合する実装によって完全に実装されなければならない。

The interfaces within this section are considered fundamental, and must be fully implemented by all conforming implementations of the DOM, including all HTML DOM implementations [DOM Level 2 HTML], unless otherwise specified.

DOMアプリケーションは,DOMImplementationインタフェースのhasFeature(feature, version)メソッドを,パラメタ値を(それぞれ)"Core"及び"2.0"として使用して,このモジュールが実装によってサポートされているかどうかを決定してもよい。DOM水準2に適合する実装,すなわちDOM水準2モジュールは,コアモジュールに適合しなければならない。この規定の 適合性 についての追加情報を参照すること。

A DOM application may use the hasFeature(feature, version) method of the DOMImplementation interface with parameter values "Core" and "2.0" (respectively) to determine whether or not this module is supported by the implementation. Any implementation that conforms to DOM Level 2 or a DOM Level 2 module must conform to the Core module. Please refer to additional information about conformance in this specification.

例外 DOMException
Exception DOMException

DOM操作は,"例外的な"状況でだけ,すなわち,(論理的な理由,データの損失,又は実装が不安定になったといういずれかの理由のために,)操作が実行できない場合にだけ,例外を挙げる。一般に,DOMメソッドは,NodeListを使用しているときの範囲外エラーといった,通常の処理中の状況で特定のエラー値を返す。

DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). In general, DOM methods return specific error values in ordinary processing situations, such as out-of-bound errors when using NodeList.

実装は,他の状況下では他の例外を挙げるほうがよい。例えば,null引数を渡された場合には,実装は,実装依存の例外を挙げることが望ましい。

Implementations should raise other exceptions under other circumstances. For example, implementations should raise an implementation-dependent exception if a null argument is passed.

例外の概念をサポートしない言語及びオブジェクトシステムも存在する。それらシステムに対しては,そのシステム固有のエラー報告機構を使用して例外条件を示してもよい。例えば,メソッドが,対応するメソッド記述の中にリストとして示されているコードと同様のエラーコードを返す(言語)束縛があってもよい。

Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.


IDL定義
IDL Definition
exception DOMException {
  unsigned short   code;
};
// ExceptionCode
const unsigned short      INDEX_SIZE_ERR                 = 1;
const unsigned short      DOMSTRING_SIZE_ERR             = 2;
const unsigned short      HIERARCHY_REQUEST_ERR          = 3;
const unsigned short      WRONG_DOCUMENT_ERR             = 4;
const unsigned short      INVALID_CHARACTER_ERR          = 5;
const unsigned short      NO_DATA_ALLOWED_ERR            = 6;
const unsigned short      NO_MODIFICATION_ALLOWED_ERR    = 7;
const unsigned short      NOT_FOUND_ERR                  = 8;
const unsigned short      NOT_SUPPORTED_ERR              = 9;
const unsigned short      INUSE_ATTRIBUTE_ERR            = 10;
// Introduced in DOM Level 2:
const unsigned short      INVALID_STATE_ERR              = 11;
// Introduced in DOM Level 2:
const unsigned short      SYNTAX_ERR                     = 12;
// Introduced in DOM Level 2:
const unsigned short      INVALID_MODIFICATION_ERR       = 13;
// Introduced in DOM Level 2:
const unsigned short      NAMESPACE_ERR                  = 14;
// Introduced in DOM Level 2:
const unsigned short      INVALID_ACCESS_ERR             = 15;

定義グループ ExceptionCode
Definition group ExceptionCode

発生したエラーの型を示す整数。

An integer indicating the type of error generated.

備考  他の数値コードは,潜在的な将来の使用のためにW3Cで予約されている。

Note: Other numeric codes are reserved for W3C for possible future use.

定義済み定数
Defined Constants
DOMSTRING_SIZE_ERR
テキストの指定された範囲がDOMStringに合致しない。
If the specified range of text does not fit into a DOMString
HIERARCHY_REQUEST_ERR
コードが属さない場所に挿入されている。
If any node is inserted somewhere it doesn't belong
INDEX_SIZE_ERR
インデクス若しくは大きさが負数,又は許された値よりも大きい。
If index or size is negative, or greater than the allowed value
INUSE_ATTRIBUTE_ERR
他で既に使用されている属性を追加しようとしている。
If an attempt is made to add an attribute that is already in use elsewhere
INVALID_ACCESS_ERRDOM水準2で導入
introduced in DOM Level 2.
パラメタ又は操作が基礎になるオブジェクトによってサポートされていない。
If a parameter or an operation is not supported by the underlying object.
INVALID_CHARACTER_ERR
名前の中などで,妥当でない又は不正な文字が指定されている。文法に合った文字の定義についてはXML規定の 生成規則2 を,文法に合った名前文字については 生成規則5 を参照すること。
If an invalid or illegal character is specified, such as in a name. See production 2 in the XML specification for the definition of a legal character, and production 5 for the definition of a legal name character.
INVALID_MODIFICATION_ERRDOM水準2で導入
introduced in DOM Level 2.
基礎となるオブジェクトの型を修正しようとしている。
If an attempt is made to modify the type of the underlying object.
INVALID_STATE_ERRDOM水準2で導入
introduced in DOM Level 2.
利用不可能又はもはや利用可能ではないオブジェクトを使用しようとしている。
If an attempt is made to use an object that is not, or is no longer, usable.
NAMESPACE_ERRDOM水準2で導入
introduced in DOM Level 2.
名前空間に関して正しくない方法でオブジェクトを生成又は変更しようとしている。
If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
NOT_FOUND_ERR
ノードが存在しない文脈でそのノードを参照しようとしている。
If an attempt is made to reference a node in a context where it does not exist
NOT_SUPPORTED_ERR
実装は,オブジェクト又は操作の要求された型をサポートしていない。
If the implementation does not support the requested type of object or operation.
NO_DATA_ALLOWED_ERR
データをサポートしないノードに対してデータを指定している。
If data is specified for a node which does not support data
NO_MODIFICATION_ALLOWED_ERR
修正が許されない場所でオブジェクトを修正しようとしている。
If an attempt is made to modify an object where modifications are not allowed
SYNTAX_ERRDOM水準2で導入
introduced in DOM Level 2.
妥当ではない又は不正な文字列が指定されている。
If an invalid or illegal string is specified.
WRONG_DOCUMENT_ERR
ノードを生成した文書以外の(そのノードをサポートしない)異なる文書で,ノードが使用されている。
If a node is used in a different document than the one that created it (that doesn't support it)
インタフェース DOMImplementation
Interface DOMImplementation

DOMImplementationインタフェースは,文書オブジェクトモデルのあらゆる特定のインスタンスに独立な操作を実行するために多くのメソッドを提供する。

The DOMImplementation interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.


IDL定義
IDL Definition
interface DOMImplementation {
  boolean            hasFeature(in DOMString feature, 
                                in DOMString version);
  // Introduced in DOM Level 2:
  DocumentType       createDocumentType(in DOMString qualifiedName, 
                                        in DOMString publicId, 
                                        in DOMString systemId)
                                        raises(DOMException);
  // Introduced in DOM Level 2:
  Document           createDocument(in DOMString namespaceURI, 
                                    in DOMString qualifiedName, 
                                    in DocumentType doctype)
                                        raises(DOMException);
};

メソッド
Methods
createDocumentDOM水準2で導入
introduced in DOM Level 2
文書要素をもつ指定された型のXML Documentオブジェクトを生成する。HTML専用のDOM実装は,このメソッドを実装する必要はない。
Creates an XML Document object of the specified type with its document element. HTML-only DOM implementations do not need to implement this method.
パラメタ
Parameters
DOMStringnamespaceURI
namespaceURI of type DOMString
生成する文書要素の 名前空間URI
The namespace URI of the document element to create.
DOMStringqualifiedName
qualifiedName of type DOMString
生成される文書要素の 修飾された名前
The qualified name of the document element to be created.
DocumentTypedoctype
doctype of type DocumentType
生成される文書の型又はnull
doctypenullでない場合,そのNode.ownerDocument属性は,生成されている文書に設定される。
The type of document to be created or null.
When doctype is not null, its Node.ownerDocument attribute is set to the document being created.
返却値
Return Value

Document  

新しいDocumentオブジェクト。

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.

NAMESPACE_ERR: qualifiedName形式が正しくない場合,qualifiedNameが接頭辞をもちnamespaceURInullになっている場合,又はqualifiedNameが"xml"である接頭辞をもちnamespaceURIが"http://www.w3.org/XML/1998/namespace" [Namespaces]と違っている場合に,挙げられる。

NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace" [Namespaces].

WRONG_DOCUMENT_ERR: doctypeが既に異なる文書とともに使用されているか,異なる実装から生成された場合に,挙げられる。

WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was created from a different implementation.

createDocumentTypeDOM水準2で導入
introduced in DOM Level 2
空のDocumentTypeノードを生成する。実体宣言及び記法は利用可能としない。実体参照拡張及びデフォルト属性追加は出現しない。DOMの将来の版では,DocumentTypeを与える方法を提供することが期待されている。
HTML専用のDOM実装は,このメソッドを実装する必要はない。
Creates an empty DocumentType node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur. It is expected that a future version of the DOM will provide a way for populating a DocumentType.
HTML-only DOM implementations do not need to implement this method.
パラメタ
Parameters
DOMStringqualifiedName
qualifiedName of type DOMString
生成される文書型の 修飾された名前
The qualified name of the document type to be created.
DOMStringpublicId
publicId of type DOMString
外部サブセットの公開識別子。
The external subset public identifier.
DOMStringsystemId
systemId of type DOMString
外部サブセットのシステム識別子。
The external subset system identifier.
返却値
Return Value

DocumentType  

Node.ownerDocumentnullに設定した新しいDocumentTypeノード。

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.

NAMESPACE_ERR: qualifiedNameの形式が正しくない場合に,挙げられる。

NAMESPACE_ERR: Raised if the qualifiedName is malformed.

hasFeature
DOM実装が特定の機能を実装しているかどうかを試験する。
Test if the DOM implementation implements a specific feature.
パラメタ
Parameters
DOMStringfeature
feature of type DOMString
試験する機能の名前。大文字・小文字を区別しない。DOM機能が使用する値は,DOM水準2規定を通じて定義され,適合性の箇条でリストを示す。名前は,XMLの名前 とする。起こり得る(名前の)衝突を避けるために,DOM規定の外部で定義される機能を参照する名前は,その機能を定義する人(又はその人が所属する組織)のインターネットドメイン名の名前を,その構成要素ごとに逆に並べ,これを接頭辞として使うことによって,一意とすることが望ましい。例えば,W3C SVG作業グループは,機能"org.w3c.dom.svg"を定義する。
The name of the feature to test (case-insensitive). The values used by DOM features are defined throughout the DOM Level 2 specifications and listed in the Conformance section. The name must be an XML name. To avoid possible conflicts, as a convention, names referring to features defined outside the DOM specification should be made unique by reversing the name of the Internet domain name of the person (or the organization that the person belongs to) who defines the feature, component by component, and using this as a prefix. For instance, the W3C SVG Working Group defines the feature "org.w3c.dom.svg".
DOMStringversion
version of type DOMString
これは,試験する機能の版番号とする。水準2では,その文字列は,"2.0"又は"1.0"のいずれかを可能とする。版が指定されない場合には,機能のいずれかの版をサポートしていれば,メソッドはtrueを返す。
This is the version number of the feature to test. In Level 2, the string can be either "2.0" or "1.0". If the version is not specified, supporting any version of the feature causes the method to return true.
返却値
Return Value

boolean  

機能が指定された版で実装されている場合には,trueとする。そうでない場合には,falseとする。

true if the feature is implemented in the specified version, false otherwise.

例外なし
No Exceptions

インタフェース DocumentFragment
Interface DocumentFragment

DocumentFragmentは,"軽量の"又は"最小の"Documentとする。文書の木の一部を抽出できたり,文書の新しい素片を生成できたりして欲しいということは,非常によくあることである。切取りなどの利用者命令を実装したり,素片を動かすことによって文書を再編成することを想像してみる。それら素片を保持できるオブジェクトをもつことが望ましく,この目的のためにNodeを使用するのは極めて自然である。Documentオブジェクトがこの役割を果すことができるのは正しいが,Documentオブジェクトは,基礎となる実装に依存して,潜在的には重いオブジェクトになる可能性がある。これを行うために本当に必要なものは,軽量のオブジェクトである。DocumentFragmentは,そうしたオブジェクトとする。

DocumentFragment is a "lightweight" or "minimal" Document object. It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a Node for this purpose. While it is true that a Document object could fulfill this role, a Document object can potentially be a heavyweight object, depending on the underlying implementation. What is really needed for this is a very lightweight object. DocumentFragment is such an object.

さらに,他のNodeの子供としてノードを挿入するなどの,様々な操作には,引数としてDocumentFragmentオブジェクトを取ってもよい。これは,DocumentFragmentのすべての子ノードがこのノードの子リストに移動するという結果を生じる。

Furthermore, various operations -- such as inserting nodes as children of another Node -- may take DocumentFragment objects as arguments; this results in all the child nodes of the DocumentFragment being moved to the child list of this node.

DocumentFragmentノードの子供は,文書の構造を定義するあらゆる部分木の最上位を表現する0個以上のノードになる。DocumentFragmentノードは,整形式のXML文書 である必要はない。(ただし,それらは,複数の最上位ノードをもつことができる整形式のXML解析対象実体に課せられた規則に従う必要はある。)例えば,DocumentFragmentはただ一つの子だけをもつかもしれないし,その子ノードはTextノードになってもよい。それら構造モデルは,HTML文書も整形式XML文書も表現しない。

The children of a DocumentFragment node are zero or more nodes representing the tops of any sub-trees defining the structure of the document. DocumentFragment nodes do not need to be well-formed XML documents (although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a DocumentFragment might have only one child and that child node could be a Text node. Such a structure model represents neither an HTML document nor a well-formed XML document.

DocumentFragmentDocument(又は実際には子供をとってもよい任意の他のNode)に挿入される場合には,DocumentFragmentそれ自体ではなくDocumentFragmentの子供が,Nodeに挿入される。このことは,利用者が 兄弟 のノードを生成したい場合に,DocumentFragmentを非常に役立つものとする。すなわち,DocumentFragmentは,これらノードの親として動作し,その結果として,利用者は,Nodeインタフェースからの,insertBefore及びappendChildといった標準的なメソッドを利用できるようになる。

When a DocumentFragment is inserted into a Document (or indeed any other Node that may take children) the children of the DocumentFragment and not the DocumentFragment itself are inserted into the Node. This makes the DocumentFragment very useful when the user wishes to create nodes that are siblings; the DocumentFragment acts as the parent of these nodes so that the user can use the standard methods from the Node interface, such as insertBefore and appendChild.


IDL定義
IDL Definition
interface DocumentFragment : Node {
};

インタフェース Document
Interface Document

Documentインタフェースは,HTML文書又はXML文書の全体を表現する。概念的には,それは,文書木の ルート であって,文書のデータへの基本的なアクセスを提供する。

The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

要素,テキストノード,注釈,処理命令などはDocumentの内容の外部には存在できないので,Documentインタフェースは,これらオブジェクトを生成するために必要なファクトリ(工場)メソッドも含む。生成されるNodeオブジェクトは,ownerDocument属性をもつが,この属性は,要素などが内部に生成された内容をもつDocumentとその要素などを関連付けている。

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.


IDL定義
IDL Definition
interface Document : Node {
  readonly attribute DocumentType     doctype;
  readonly attribute DOMImplementation  implementation;
  readonly attribute Element          documentElement;
  Element            createElement(in DOMString tagName)
                                        raises(DOMException);
  DocumentFragment   createDocumentFragment();
  Text               createTextNode(in DOMString data);
  Comment            createComment(in DOMString data);
  CDATASection       createCDATASection(in DOMString data)
                                        raises(DOMException);
  ProcessingInstruction createProcessingInstruction(in DOMString target, 
                                                    in DOMString data)
                                        raises(DOMException);
  Attr               createAttribute(in DOMString name)
                                        raises(DOMException);
  EntityReference    createEntityReference(in DOMString name)
                                        raises(DOMException);
  NodeList           getElementsByTagName(in DOMString tagname);
  // Introduced in DOM Level 2:
  Node               importNode(in Node importedNode, 
                                in boolean deep)
                                        raises(DOMException);
  // Introduced in DOM Level 2:
  Element            createElementNS(in DOMString namespaceURI, 
                                     in DOMString qualifiedName)
                                        raises(DOMException);
  // Introduced in DOM Level 2:
  Attr               createAttributeNS(in DOMString namespaceURI, 
                                       in DOMString qualifiedName)
                                        raises(DOMException);
  // Introduced in DOM Level 2:
  NodeList           getElementsByTagNameNS(in DOMString namespaceURI, 
                                            in DOMString localName);
  // Introduced in DOM Level 2:
  Element            getElementById(in DOMString elementId);
};

属性
Attributes
DocumentTypedoctype,読取り専用
doctype of type DocumentType, readonly
この文書に関連付けられた文書型宣言(DocumentType参照)。文書型宣言をもたないXML文書と同様にHTML文書に対しては,これはnullを返す。DOM水準2は,文書型宣言の編集はサポートしない。docTypeは,insertNode又はremoveNodeといったNodeインタフェースから継承されたメソッドの使用を通した場合を含むいかなる方法でも,警告されることはできない。
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 2 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.
ElementdocumentElement,読取り専用
documentElement of type Element, readonly
これは,文書のルート要素である子ノードに直接にアクセスできる 簡便性 のある属性とする。HTML文書に対しては,これは,tagNameを"HTML"とする要素とする。
This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".
DOMImplementationimplementation,読取り専用
implementation of type DOMImplementation, readonly
この文書を取り扱うDOMImplementationオブジェクト。DOMアプリケーションは,複数の実装からのオブジェクトを使用してもよい。
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.
メソッド
Methods
createAttribute
与えられた名前のAttrを生成する。Attrインスタンスは,setAttributeNodeメソッドを使ってElement上に設定できることに注意すること。
修飾された名前及び名前空間URIをもつ属性を生成するためには,createAttributeNSメソッドを使用する。
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
パラメタ
Parameters
DOMStringname
name of type DOMString
属性の名前。
The name of the attribute.
返却値
Return Value

Attr  

nodeName属性をnameに設定し,localName属性,prefix属性及びnamespaceURI属性をnullに設定した新しいAttrオブジェクト。生成される属性の値は,空文字列とする。

A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createAttributeNSDOM水準2で導入
introduced in DOM Level 2
与えられた修飾された名前及び名前空間URIの属性を生成する。HTML専用のDOM実装は,このメソッドを実装する必要はない。
Creates an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.
パラメタ
Parameters
DOMStringnamespaceURI
namespaceURI of type DOMString
生成する属性の名前空間URI
The namespace URI of the attribute to create.
DOMStringqualifiedName
qualifiedName of type DOMString

インスタンス化する属性の修飾された名前
The qualified name of the attribute to instantiate.
返却値
Return Value

Attr  

次の属性をもつ新しいAttrオブジェクト。

A new Attr object with the following attributes:

属性
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix qualifiedNameから抽出した接頭辞,又は接頭辞が存在しない場合にはnull
prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName qualifiedNameから抽出された 局所名
local name, extracted from qualifiedName
Attr.name qualifiedName
Node.nodeValue 空文字列
the empty string
例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含んでいる場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.

NAMESPACE_ERR: qualifiedNameの形式が正しくない場合,qualifiedNameが接頭辞をもちnamespaceURInullの場合,qualifiedNameが"xml"である接頭辞をもちnamespaceURIが"http://www.w3.org/XML/1998/namespace"とは異なっている場合,又はqualifiedNameが"xmlns"であってnamespaceURIが"http://www.w3.org/2000/xmlns/"とは異なっている場合に,挙げられる。

NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", or if the qualifiedName is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".

createCDATASection
値が指定された文字列となるCDATASectionを生成する。
Creates a CDATASection node whose value is the specified string.
パラメタ
Parameters
DOMStringdata
data of type DOMString
CDATASection内容に対するデータ。
The data for the CDATASection contents.
返却値
Return Value

CDATASection  

新しいCDATASectionオブジェクト。

The new CDATASection object.

例外
Exceptions

DOMException  

NOT_SUPPORTED_ERR: この文書がHTML文書の場合に,挙げられる。

NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createComment
指定された文字列を与えたCommentノードを生成する。
Creates a Comment node given the specified string.
パラメタ
Parameters
DOMStringdata
data of type DOMString
ノードに対するデータ。
The data for the node.
返却値
Return Value

Comment  

新しいCommentオブジェクト。

The new Comment object.

例外なし
No Exceptions
createDocumentFragment
空のDocumentFragmentオブジェクトを生成する。
Creates an empty DocumentFragment object.
返却値
Return Value
パラメタなし
No Parameters
例外なし
No Exceptions
createElement
指定された型の要素を生成する。返されるインスタンスは,Elementを実装していることに注意すること。そのために,属性は,返されたオブジェクト上に直接に指定できる。
さらに,デフォルト値をもつ既知の属性が存在する場合には,それらを表現するAttrノードが,自動的に生成されその要素に添付される。
修飾された名前及び名前空間URIをもつ要素を生成するためには,createElementNSメソッドを使用すること。
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS method.
パラメタ
Parameters
DOMStringtagName
tagName of type DOMString
インスタンス化する要素型の名前。XMLに対しては,これは,大文字・小文字を区別する。HTMLに対しては,大文字又は小文字のどちらでtagNameパラメタを提供してよいが,DOM実装によって正準的な大文字の形式に対応付けられなければならない。
The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
返却値
Return Value

Element  

nodeName属性をtagNameに設定し,localName属性,prefix属性及びnamespaceURI属性をnullに設定した新しいElementオブジェクト。

A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createElementNSDOM水準2で導入
introduced in DOM Level 2
与えられた修飾された名前及び名前空間URIの要素を生成する。HTML専用のDOM実装は,このメソッドを実装する必要はない。
Creates an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.
パラメタ
Parameters
DOMStringnamespaceURI
namespaceURI of type DOMString
生成する要素の名前空間URI
The namespace URI of the element to create.
DOMStringqualifiedName
qualifiedName of type DOMString
インスタンス化する要素型の修飾された名前
The qualified name of the element type to instantiate.
返却値
Return Value

Element  

次の属性をもつ新しいElementオブジェクト。

A new Element object with the following attributes:

属性
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix qualifiedNameから抽出された接頭辞,又は接頭辞が存在しない場合にはnull
prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName qualifiedNameから抽出された 局所名
local name, extracted from qualifiedName
Element.tagName qualifiedName
例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.

NAMESPACE_ERR: qualifiedNameの形式が正しくない場合,qualifiedNameが接頭辞をもちnamespaceURInullの場合,又はqualifiedNameが"xml"となる接頭辞をもちnamespaceURIが"http://www.w3.org/XML/1998/namespace" [Namespaces]とは異なる場合に,挙げられる。

NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace" [Namespaces].

createEntityReference
EntityReferenceオブジェクトを生成する。さらに,参照される実体が既知の場合には,EntityReferenceノードの子リストは,対応するEntityノードの子リストと同じとされる。
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.

備考  Entityノードの子孫が束縛されていない 名前空間接頭辞 をもつ場合には,生成されたEntityReferenceノードの対応する子孫も束縛されない。すなわち,そのnamespaceURInullとなる。DOM水準2は,名前空間接頭辞を解決するいかなる機構もサポートしない。

Note: If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.

パラメタ
Parameters
DOMStringname
name of type DOMString
参照する実体の名前。
The name of the entity to reference.
返却値
Return Value

EntityReference  

新しいEntityReferenceオブジェクト。

The new EntityReference object.

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定された名前が不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

NOT_SUPPORTED_ERR: この文書がHTML文書の場合に,挙げられる。

NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createProcessingInstruction
指定された名前及びデータ文字列を与えられたProcessingInstructionを生成する。
Creates a ProcessingInstruction node given the specified name and data strings.
パラメタ
Parameters
DOMStringtarget
target of type DOMString
処理命令のターゲット部分。
The target part of the processing instruction.
DOMStringdata
data of type DOMString
ノードに対するデータ。
The data for the node.
返却値
Return Value

ProcessingInstruction  

新しいProcessingInstructionオブジェクト。

The new ProcessingInstruction object.

例外
Exceptions

DOMException  

INVALID_CHARACTER_ERR: 指定されたターゲットが不正な文字を含む場合に,挙げられる。

INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.

NOT_SUPPORTED_ERR: この文書がHTML文書の場合に,挙げられる。

NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createTextNode
与えられた文字列に対してTextノードを生成する。
パラメタ
DOMStringdata
ノードに対するデータ。
返却値

Text  

新しいTextオブジェクト。

例外なし
getElementByIdDOM水準2で導入
IDelementIdによって与えられるElementを返す。それら要素が存在しない場合には,nullを返す。複数の要素がこのIDをもつ場合には,その振る舞いは定義されない。

備考  DOMの実装は,どの属性がID型となるかを示す情報をもたなければならない。それらが定義されない場合には,名前"ID"をもつ属性は,ID型ではない。属性がID型となるかどうか知らない実装は,nullを返すと期待される。

パラメタ
DOMStringelementId
要素に対する一意なid値。
返却値
Return Value

Element  

(id値が)一致する要素。

例外なし
getElementsByTagName
与えられたタグ名をもつElementを,Document木をあらかじめ順序付けされたたどりで出会う順番に返す。
パラメタ
DOMStringtagname
照合させるタグの名前。特別な値"*"は,すべてのタグと一致する。
返却値

NodeList  

一致したすべてのElementを含む新しいNodeListオブジェクト。

例外なし
getElementsByTagNameNSDOM水準2で導入
与えられた 局所名 及び名前空間URIをもつすべてのElementを,Document木をあらかじめ順序付けされたたどりで出会う順番に並べたNodeListを返す。
パラメタ
DOMStringnamespaceURI
照合させる要素の 名前空間URI。特別な値"*"は,すべての名前空間と一致する。
DOMStringlocalName
照合させる要素の 局所名。特別な値"*"は,すべての局所名と一致する。
返却値

NodeList  

すべての一致するElementを含む新しいNodeListオブジェクト。

例外なし
importNodeDOM水準2で導入
他の文書からこの文書に一つのノードをインポートする。返されるノードは親をもたない。すなわち,parentNodenullとする。源となるノードは,元の文書から変更されたり取り除かれたりしない。このメソッドは,源となるノードの新しいコピーを生成する。
すべてのノードに対して,あるノードをインポートすると,インポートを行う文書の所有するノードオブジェクトが,源となるノードのnodeName及びnodeTypeと同一の属性値,及び名前空間(prefixlocalName及びnamespaceURI)に関係する属性をともなって,生成される。Node上のcloneNode操作におけるのと同様に,源となるノードは変更されない。
付加的な情報が,nodeTypeに適切な仕方でコピーされる。このコピーの際に,XML又はHTMLの源(となる文書)の素片がある文書から他の文書へとコピーされた場合には,期待される振る舞いを写し出す試みを行い,XMLの場合には,二つの文書が異なるDTDをもってよいということを認識する。次のリストに,ノードの各々型の詳細を示す。
ATTRIBUTE_NODE
生成されるAttrにおいて,ownerElement属性はnullに設定され,specifiedフラグはtrueに設定される。源となるAttr 子孫 は,再帰的にインポートされ,その結果生じるノードは,対応する部分木を形成するために再び組み立てられる。
deepパラメタは,Attrノードには影響しないことに注意。それらのノードは,インポートされるときに,常にそれらとともにそれらの子供を運んでくる。
DOCUMENT_FRAGMENT_NODE
deepオプションがtrueに設定された場合,源となる要素の 子孫 は,再帰的にインポートされ,結果として生じるノードは,対応する部分木を形成するために再び組み立てられる。そうでない場合には,単に,空のDocumentFragmentを生成する。
DOCUMENT_NODE
Documentノードは,インポートできない。
DOCUMENT_TYPE_NODE
DocumentTypeノードは,インポートできない。
ELEMENT_NODE
源となる要素の 指定された 属性のノードがインポートされ,生成されたAttrノードは,生成されたElementに添付される。デフォルト属性は,コピーされ ない。ただし,インポートされている文書がこの要素名に対してデフォルト属性を定義する場合には,それらが割り当てられる。importNodedeepパラメタがtrueに設定された場合,源となる要素の 子孫 は,再帰的にインポートされ,結果として生じるノードは,対応する部分木を形成するために再び組み立てられる。
ENTITY_NODE
Entityノードはインポートできるが,DOMの現在の公開された版では,DocumentTypeは読取り専用とする。これらインポートされたノードを<