1.1では,文書オブジェクトにアクセスしそれらを操作するためのオブジェクト及びインタフェースの集合を定義する。1.1で規定する機能(コア 機能)は,ソフトウェア開発者及びウェブスクリプト作成者が,適合する製品の内部で構文解析されたHTML及びXMLの内容にアクセスしそれらを操作できるのに十分なものとする。DOMコアAPIは,DOM API呼出しだけを使って,Documentオブジェクトを生成し存在させることも可能とする。Documentのロード及びそれの永続的な保存は,DOM APIを実装する製品に委ねることとする。
Document object
using only DOM API calls; loading a Document and saving it
persistently is left to the product that implements the DOM
API.
DOMは,他の更に特殊化されたインタフェースも実装するNodeオブジェクトの階層として,文書を表現する。ノードのある型は,様々な型の 子 ノードをもってよく,ノードのその他の型は,文書構造においてそれよりも下位に何ももつことができない葉ノードとなる。XML及びHTMLに対して,そのノード型,及びそれらが子供としてどのノード型をもってよいかを,次に示す。
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:
Document --
Element (最大でも1個),ProcessingInstruction,Comment,DocumentType (最大でも1個)DocumentFragment --
Element,ProcessingInstruction,Comment,Text,CDATASection,EntityReferenceDocumentType --
子供なしEntityReference --
Element,ProcessingInstruction,Comment,Text,CDATASection,EntityReferenceElement --
Element,Text,Comment,ProcessingInstruction,CDATASection,EntityReferenceAttr --
Text,EntityReferenceProcessingInstruction --
子供なしComment --
子供なしText --
子供なしCDATASection --
子供なしEntity --
Element,ProcessingInstruction,Comment,Text,CDATASection,EntityReferenceNotation --
子供なしDocument -- Element (maximum of
one), ProcessingInstruction,
Comment, DocumentType
(maximum of one)DocumentFragment --
Element, ProcessingInstruction,
Comment, Text, CDATASection, EntityReferenceDocumentType
-- no childrenEntityReference -- Element, ProcessingInstruction,
Comment, Text, CDATASection, EntityReferenceElement -- Element, Text, Comment, ProcessingInstruction,
CDATASection, EntityReferenceAttr -- Text, EntityReferenceProcessingInstruction
-- no childrenComment --
no childrenText -- no
childrenCDATASection
-- no childrenEntity -- Element, ProcessingInstruction,
Comment, Text, CDATASection, EntityReferenceNotation -- no
childrenDOMは,Nodeの子供又はElementインタフェースのgetElementsByTagNameメソッドが返す element 要素といった順序付きリストを扱うためにNodeListインタフェースも規定する。さらに,Elementの属性などの名前属性が参照するノードの順序なし集合を扱うためにNamedNodeMapも規定する。DOMにおける NodeListオブジェクト及びNamedNodeMapオブジェクトは,活性化している(live)とする。すなわち,元となる文書構造への変更は,すべての関連するNodeListオブジェクト及びNamedNodeMapオブジェクトに反映される。例えば,DOM利用者がElementの子供を含むNodeListオブジェクトを得て,それに続いて,その 要素 に子供を更に追加する(,子供を削除する,又は子供を修正する)場合,それらの変更は,利用者側でそれ以上のことをしなくとも,自動的にNodeListに反映される。同様に,木のNodeへの変更は,NodeList及びNamedNodeMapにおけるそのNodeへのすべての参照に反映される。
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インタフェースから継承される。
Text, Comment, and CDATASection all
inherit from the CharacterData
interface.
この規定が定義するAPIの大部分は,クラスではなく インタフェース とする。これは,実装には,定義された名前及び規定された操作をもつメソッドの開示だけが必要とされ,直接にそのインタフェースに対応するクラスの実装は必要とはされないことを意味する。これによって,それ自体のデータ構造をもつ既存アプリケーションの上に,又は異なるクラス階層をもつ新しいアプリケーションの上に,薄い張り板を張るようにDOM APIを実装することが可能になる。このことは,構成される必要がある基盤となるオブジェクトがDOMインタフェースと関係をほとんどもたなくともよいので,Java又はC++の意味での通常のコンストラクタは,DOMオブジェクトを生成するために使用できないことも意味する。この問題に対するオブジェクト指向設計での従来の解は,様々なインタフェースを実装するオブジェクトのインスタンスを複数生成する ファクトリ(factory) メソッドを定義することである。インタフェース"X"を実装するオブジェクトは,Documentインタフェースの"createX()"メソッドによって生成される。この理由は,すべてのDOMオブジェクトは,特定の文書の文脈中で活性化(live)していることによる。
Document interface;
this is because all DOM objects live in the context of a specific
Document.
DOM水準2のAPIは,DOMImplementationオブジェクトを生成する標準的な方法を定義 しない。すなわち,DOM実装は,これらのDOMインタフェースをブートストラップする独自の方法を提供しなければならない。他のすべてのオブジェクトは,そこから構築できる。
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作業グループの責任とはしない。
短く,形式的ではなく,内部矛盾がなく,同様のAPIの利用者に馴染み深い属性名及びメソッド名をもつことはよいことだが,その名前が,DOM実装がサポートする既存のAPIにおける名前と衝突することは望ましくない。さらに,OMG IDL及びECMAScriptの両方とも,異なる名前空間を用いて名前のあいまい性を解消する能力に致命的な限界をもっており,これが,短く,馴染み深い名前の名前衝突を避けることを困難にしている。そこで,DOMでの名前は,すべての環境に渡って一意とするために,長く,記述的になる傾向にある。
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(削除する。名詞は削除。)"を使用する。削除されたものは返されない。取り除かれたものは,それを返すことに意味がある場合には,返されることもある。
DOMコア API は,XML文書又はHTML文書へのインタフェースの二つの幾分異なる集合を表現する。それらは, 継承 の階層を用いる"オブジェクト指向"アプローチを表現するインタフェースと,(Java及びC言語に類似した他の言語における)キャスト又は COM 環境での問合せインタフェース呼出しを要求することなしにNodeインタフェース経由ですべての操作を行えるようにする"単純化された"ビューとの二つとする。これらの操作は,Java及びCOMでは幾分高価なものとなるが,DOMは,性能が重要となる環境で使用してもよい。そこで,Nodeインタフェースを使うだけで重要な機能を可能にできるようにする。 継承 階層を"すべてをNodeとする"DOMへのアプローチよりも理解しやすいとする利用者も多いので,よりオブジェクト指向的な API を好む利用者のために,より高位の完全なインタフェースもサポートする。
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 には満足を与えなければならない異なる利用者がいるので,両方をサポートすることには価値がある。
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.
DOMString型
DOMString type
相互運用性を確実にするために,DOMは,次を規定する。
DOMStringを符号化しなければならない。
DOMStringでは二つの16ビット単位(高位サロゲート及び低位サロゲート)に対応する場合があってもよい。
DOMString using UTF-16
(defined in [Unicode] and Amendment 1 of [ISO/IEC
10646]).DOMString (a high
surrogate and a low surrogate).
備考
DOMは,文字型の名前をDOMStringと定義しているが,(言語)束縛では異なる名前を使用してもよい。例えばJavaに対しては,DOMStringはString型に束縛される。これは,その符号化としてUTF-16を使用することによる。
備考
2000年8月の時点で,OMG IDL規定([OMGIDL])は,wstring型を含んでいた。しかし,その定義は,文字の幅(バイト数)及び符号化の決定を折衝に依存するので,DOM API の相互運用性基準を満たさなかった。
DOMTimeStamp型
DOMTimeStamp
type
相互運用性を確実にするために,DOMは,次を規定する。
DOMTimeStampは,ミリ秒の数を表現する。
DOMTimeStamp
represents a number of milliseconds.
typedef unsigned long long DOMTimeStamp;
備考
DOMは,型DOMTimeStampを使用するが,(言語)束縛では異なる型を使用してもよい。例えばJavaに対しては,DOMTimeStampは,long型に束縛される。ECMAScriptでは,integer型の範囲があまりにも小さいので,TimeStampは,Date型に束縛される。
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.
DOMは,文字列の照合(マッチ,matching)を示す多くのインタフェースをもつ。HTMLプロセサは,一般に,要素 などの名前を大文字に(非常にまれに小文字に)正規化すると仮定する。一方で,XMLは明示的に大文字・小文字を区別する。DOMの目的のためには,文字列照合は,DOMStringの 16ビット単位 のバイナリ 比較 によってそのまま実行される。さらに,DOMは,あらゆる大文字・小文字の正規化は,DOM構造が構築される 前に,プロセサで行われると仮定する。
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]を参照すること。
DOM水準2は,XML名前空間[Namespaces]をサポートする。これは,DOM水準1の幾つかのインタフェースを強化し,名前空間に関連する 要素 及び属性を生成し操作できるようにすることによって行われる。
DOMに関する限り,XML名前空間 を宣言するために使用する特殊な属性が,今のところ開示されており,他の属性と同様に操作できる。しかし,ノードは,生成されると,永久に 名前空間URI に束縛される。その結果,DOMを使って文書内でノードを移動させても,決して,名前空間接頭辞 にも名前空間URIにも変化は生じない。同様に,名前空間接頭辞及び名前空間URIをもつノードを生成したりノードの名前空間接頭辞を変更しても,適切なXML名前空間を宣言するためにいかなる特殊な属性の追加,削除又は修正が生じることはない。名前空間の妥当性検証は強制されない。DOMアプリケーションの責任とする。特に,接頭辞と名前空間URIとの間の対応付けは強制されないので,一般に,結果として生じる文書は単純には直列化できない。例えば,アプリケーションは,文書を直列化する場合には,使用しているすべての名前空間を宣言しなければならないかもしれない。
DOM水準2は,いかなるURIの正規化又は正準化も実行しない。DOMに与えられたURIは,(例えば,空白などの文字が正しく別扱いされているなどに関して)妥当と仮定され,字句的な検査は実行されない。絶対URI参照は,文字列として扱われ,文字ごとに比較される。相対名前空間URI参照を取り扱う方法は定義しない。相互運用性を確実にするために,絶対名前空間URI参照(すなわち,方式名及びコロンで始まるURI参照)だけを使用するのが望ましい。DOMは字句的な検査を行わないので,DOM水準2のメソッドでは,空文字列は現実の名前空間URIとして扱われることに注意すること。アプリケーションは,名前空間をもつことを望まない場合には,メソッドに対する名前空間URIパラメタとして値nullを使用しなければならない。
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]の一部ではないが,将来の版では含まれる予定になっている。
名前空間をもたない文書の中では,EntityReferenceノードの 子 リストは,常に,対応するEntityの子リストと同じとする。これは,実体が束縛されていない 名前空間接頭辞 を含む文書では正しくない。それらの場合には,対応するEntityReferenceノードの 子孫 が,実体参照が存在する場所に依存して,異なる 名前空間URI に束縛されてよい。DOMではノードは常に同じ名前空間URIに束縛され続けるので,それらEntityReferenceノードを移動させることが,直列化できない文書を生じる可能性もある。このことは,DocumentインタフェースのDOM水準1のcreateEntityReferenceメソッドを,それら実体に対応する実体参照を生成するために使用する場合にも正しい。これは,返されたEntityReferenceの 子孫 は束縛されていないことによる。DOM水準2は,名前空間接頭辞を解決する機構をサポートしない。これらすべての理由のために,それら実体及び実体参照は,使用しないか,又は非常に注意して使用することが望ましい。DOMの将来の水準には,これらを取り扱うための追加のサポートを含まれるかもしれない。
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又は局所名をもたない。
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がそれぞれ返すノードに影響する。
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におけるインタフェースは,基礎的 と考えられ,特に指定されない限り,すべてのHTML DOM実装[DOM Level 2 HTML]を含む,DOMのすべての適合する実装によって完全に実装されなければならない。
DOMアプリケーションは,DOMImplementationインタフェースのhasFeature(feature, version)メソッドを,パラメタ値を(それぞれ)"Core"及び"2.0"として使用して,このモジュールが実装によってサポートされているかどうかを決定してもよい。DOM水準2に適合する実装,すなわちDOM水準2モジュールは,コアモジュールに適合しなければならない。この規定の 適合性 についての追加情報を参照すること。
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.
DOM操作は,"例外的な"状況でだけ,すなわち,(論理的な理由,データの損失,又は実装が不安定になったといういずれかの理由のために,)操作が実行できない場合にだけ,例外を挙げる。一般に,DOMメソッドは,NodeListを使用しているときの範囲外エラーといった,通常の処理中の状況で特定のエラー値を返す。
NodeList.
実装は,他の状況下では他の例外を挙げるほうがよい。例えば,null引数を渡された場合には,実装は,実装依存の例外を挙げることが望ましい。
null argument
is passed.
例外の概念をサポートしない言語及びオブジェクトシステムも存在する。それらシステムに対しては,そのシステム固有のエラー報告機構を使用して例外条件を示してもよい。例えば,メソッドが,対応するメソッド記述の中にリストとして示されているコードと同様のエラーコードを返す(言語)束縛があってもよい。
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;
発生したエラーの型を示す整数。
備考 他の数値コードは,潜在的な将来の使用のためにW3Cで予約されている。
DOMSTRING_SIZE_ERRHIERARCHY_REQUEST_ERRINDEX_SIZE_ERRINUSE_ATTRIBUTE_ERRINVALID_ACCESS_ERR,DOM水準2で導入
INVALID_CHARACTER_ERRINVALID_MODIFICATION_ERR,DOM水準2で導入
INVALID_STATE_ERR,DOM水準2で導入
NAMESPACE_ERR,DOM水準2で導入
NOT_FOUND_ERRNOT_SUPPORTED_ERRNO_DATA_ALLOWED_ERRNO_MODIFICATION_ALLOWED_ERRSYNTAX_ERR,DOM水準2で導入
WRONG_DOCUMENT_ERR
DOMImplementationインタフェースは,文書オブジェクトモデルのあらゆる特定のインスタンスに独立な操作を実行するために多くのメソッドを提供する。
DOMImplementation interface provides a number
of methods for performing operations that are independent of any
particular instance of the document object model.
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);
};
createDocument,DOM水準2で導入
Documentオブジェクトを生成する。HTML専用のDOM実装は,このメソッドを実装する必要はない。
Document object of the
specified type with its document element. HTML-only DOM
implementations do not need to implement this method.
DOMStringのnamespaceURI
namespaceURI of type DOMString
DOMStringのqualifiedName
qualifiedName of type DOMString
DocumentTypeのdoctype
doctype of type DocumentType
null。
doctypeがnullでない場合,そのNode.ownerDocument属性は,生成されている文書に設定される。
null.doctype is not null, its Node.ownerDocument
attribute is set to the document being created.|
INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
NAMESPACE_ERR:
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:
WRONG_DOCUMENT_ERR: Raised if
doctype has already
been used with a different document or was created from a different
implementation.
|
createDocumentType,DOM水準2で導入
DocumentTypeノードを生成する。実体宣言及び記法は利用可能としない。実体参照拡張及びデフォルト属性追加は出現しない。DOMの将来の版では,DocumentTypeを与える方法を提供することが期待されている。
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.DOMStringのqualifiedName
qualifiedName of type DOMString
DOMStringのpublicId
publicId of type DOMString
DOMStringのsystemId
systemId of type DOMString
|
|
|
INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
NAMESPACE_ERR:
NAMESPACE_ERR: Raised if the
qualifiedName is
malformed.
|
hasFeatureDOMStringのfeature
feature of type DOMString
DOMStringのversion
version of type DOMString
trueを返す。
true.|
|
機能が指定された版で実装されている場合には, true if the feature is implemented in the specified
version, false otherwise.
|
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のすべての子ノードがこのノードの子リストに移動するという結果を生じる。
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文書も表現しない。
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.
DocumentFragmentがDocument(又は実際には子供をとってもよい任意の他のNode)に挿入される場合には,DocumentFragmentそれ自体ではなくDocumentFragmentの子供が,Nodeに挿入される。このことは,利用者が 兄弟 のノードを生成したい場合に,DocumentFragmentを非常に役立つものとする。すなわち,DocumentFragmentは,これらノードの親として動作し,その結果として,利用者は,Nodeインタフェースからの,insertBefore及びappendChildといった標準的なメソッドを利用できるようになる。
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.
interface DocumentFragment : Node {
};
Documentインタフェースは,HTML文書又はXML文書の全体を表現する。概念的には,それは,文書木の ルート であって,文書のデータへの基本的なアクセスを提供する。
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とその要素などを関連付けている。
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.
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);
};
DocumentTypeのdoctype,読取り専用
doctype of type DocumentType,
readonly
DocumentType参照)。文書型宣言をもたないXML文書と同様にHTML文書に対しては,これはnullを返す。DOM水準2は,文書型宣言の編集はサポートしない。docTypeは,insertNode又はremoveNodeといったNodeインタフェースから継承されたメソッドの使用を通した場合を含むいかなる方法でも,警告されることはできない。
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.ElementのdocumentElement,読取り専用
documentElement of type Element,
readonly
tagNameを"HTML"とする要素とする。
DOMImplementationのimplementation,読取り専用
implementation of type DOMImplementation,
readonly
DOMImplementationオブジェクト。DOMアプリケーションは,複数の実装からのオブジェクトを使用してもよい。
DOMImplementation
object that handles this document. A DOM application may use
objects from multiple implementations.createAttributeAttrを生成する。Attrインスタンスは,setAttributeNodeメソッドを使ってElement上に設定できることに注意すること。
createAttributeNSメソッドを使用する。
Attr of the given
name. Note that the Attr instance can
then be set on an Element using the
setAttributeNode method.createAttributeNS method.
|
INVALID_CHARACTER_ERR: 指定された名前が不正な文字を含む場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.
|
createAttributeNS,DOM水準2で導入
DOMStringのnamespaceURI
namespaceURI of type DOMString
DOMStringのqualifiedName
qualifiedName of type DOMString
|
次の属性をもつ新しい
A new
Attr object with the
following attributes:
|
|
INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含んでいる場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
NAMESPACE_ERR:
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/".
|
createCDATASectionCDATASectionを生成する。
CDATASection node
whose value is the specified string.
DOMStringのdata
data of type DOMString
CDATASection内容に対するデータ。
CDATASection
contents.|
新しい
The new
CDATASection
object.
|
|
NOT_SUPPORTED_ERR: この文書がHTML文書の場合に,挙げられる。
NOT_SUPPORTED_ERR: Raised if this document is an HTML
document.
|
createCommentcreateDocumentFragmentDocumentFragmentオブジェクトを生成する。
DocumentFragment
object.
|
新しい
A new
DocumentFragment.
|
createElementElementを実装していることに注意すること。そのために,属性は,返されたオブジェクト上に直接に指定できる。Attrノードが,自動的に生成されその要素に添付される。createElementNSメソッドを使用すること。
Element interface,
so attributes can be specified directly on the returned
object.Attr nodes
representing them are automatically created and attached to the
element.createElementNS method.
DOMStringのtagName
tagName of type DOMString
tagNameパラメタを提供してよいが,DOM実装によって正準的な大文字の形式に対応付けられなければならない。
tagName parameter may be
provided in any case, but it must be mapped to the canonical
uppercase form by the DOM implementation.|
INVALID_CHARACTER_ERR: 指定された名前が不正な文字を含む場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.
|
createElementNS,DOM水準2で導入
DOMStringのnamespaceURI
namespaceURI of type DOMString
DOMStringのqualifiedName
qualifiedName of type DOMString
|
次の属性をもつ新しい
A new
Element object with
the following attributes:
|
|
INVALID_CHARACTER_ERR: 指定された修飾された名前が不正な文字を含む場合に,挙げられる。
INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
NAMESPACE_ERR:
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].
|
createEntityReferenceEntityReferenceオブジェクトを生成する。さらに,参照される実体が既知の場合には,EntityReferenceノードの子リストは,対応するEntityノードの子リストと同じとされる。
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ノードの対応する子孫も束縛されない。すなわち,そのnamespaceURIはnullとなる。DOM水準2は,名前空間接頭辞を解決するいかなる機構もサポートしない。
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.
|
新しい
The new
EntityReference
object.
|
|
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.
|
createProcessingInstructionProcessingInstructionを生成する。
ProcessingInstruction
node given the specified name and data strings.
|
新しい
The new
ProcessingInstruction
object.
|
|
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.
|
createTextNodegetElementById,DOM水準2で導入getElementsByTagNamegetElementsByTagNameNS,DOM水準2で導入importNode,DOM水準2で導入parentNodeはnullとする。源となるノードは,元の文書から変更されたり取り除かれたりしない。このメソッドは,源となるノードの新しいコピーを生成する。
nodeName及びnodeTypeと同一の属性値,及び名前空間(prefix,localName及びnamespaceURI)に関係する属性をともなって,生成される。Node上のcloneNode操作におけるのと同様に,源となるノードは変更されない。
nodeTypeに適切な仕方でコピーされる。このコピーの際に,XML又はHTMLの源(となる文書)の素片がある文書から他の文書へとコピーされた場合には,期待される振る舞いを写し出す試みを行い,XMLの場合には,二つの文書が異なるDTDをもってよいということを認識する。次のリストに,ノードの各々型の詳細を示す。
Attrにおいて,ownerElement属性はnullに設定され,specifiedフラグはtrueに設定される。源となるAttrの 子孫 は,再帰的にインポートされ,その結果生じるノードは,対応する部分木を形成するために再び組み立てられる。
deepパラメタは,Attrノードには影響しないことに注意。それらのノードは,インポートされるときに,常にそれらとともにそれらの子供を運んでくる。
deepオプションがtrueに設定された場合,源となる要素の 子孫 は,再帰的にインポートされ,結果として生じるノードは,対応する部分木を形成するために再び組み立てられる。そうでない場合には,単に,空のDocumentFragmentを生成する。
Documentノードは,インポートできない。DocumentTypeノードは,インポートできない。Attrノードは,生成されたElementに添付される。デフォルト属性は,コピーされ ない。ただし,インポートされている文書がこの要素名に対してデフォルト属性を定義する場合には,それらが割り当てられる。importNodeのdeepパラメタがtrueに設定された場合,源となる要素の 子孫 は,再帰的にインポートされ,結果として生じるノードは,対応する部分木を形成するために再び組み立てられる。
Entityノードはインポートできるが,DOMの現在の公開された版では,DocumentTypeは読取り専用とする。これらインポートされたノードを<