【この訳に特有な表記規約】
◎表記記号勧告候補からの昇格基準
【この節を成す内容の和訳は省略する。】 ◎ This specification will not advance to Proposed Recommendation before the spec's test suite is completed and two or more independent implementations pass each test, although no single implementation must pass each test. We expect to meet this criteria no sooner than 24 October 2014. The group will also create an Implementation Report.
1. 適合性
【 この節を成す他の内容は、 ~W3C日本語訳 共通~pageに移譲。 】
この仕様は `INFRA$r に依存する。 ◎ This specification depends on the Infra Standard. [INFRA]
2. 拡張能
この仕様に対する~vendorに特有な~proprietaryな拡張は、 強く忌避される。 作者は、 そのような拡張を利用してはナラナイ。 そのような行為は、 当の内容への~accessが特定の~UAの利用者に限られてしまい, 相互運用能の~~悪化と利用者~~層の細分化を招くことになるので。 ◎ Vendor-specific proprietary extensions to this specification are strongly discouraged. Authors must not use such extensions, as doing so reduces interoperability and fragments the user base, allowing only users of specific user agents to access the content in question.
~vendorに特有な拡張が必要な場合、 この仕様を成す将来の~versionとの衝突を防止するため, 【当の~APIを成す】各~memberには~vendorに特有な文字列が接頭されなければナラナイ。 拡張は、 その利用が,この仕様にて定義される機能性に[ 矛盾する/適合しなくなる ]ように定義されてはナラナイ。 ◎ If vendor-specific extensions are needed, the members should be prefixed by vendor-specific strings to prevent clashes with future versions of this specification. Extensions must be defined so that the use of extensions neither contradicts nor causes the non-conformance of functionality defined in the specification.
この仕様に対し ~vendorに中立的な拡張が必要になったときは、[ それに則って,この仕様が更新される ]こともあれば[ この仕様の要件を上書きする拡張~仕様が記される ]こともある。 そのような仕様は、 この仕様に対する適合性~要件の目的において,適用-可能な仕様になる。 ◎ When vendor-neutral extensions to this specification are needed, either this specification can be updated accordingly, or an extension specification can be written that overrides the requirements in this specification. Such an extension specification becomes an applicable specification for the purposes of conformance requirements in this specification.
3. 序論
~DOM(文書~obj~model)は、 各自が~treeに接続されている様々な型の `Node$I たちが成す,~memory内~表現である。 ~DOMと その `Node$I のより深い詳細は、 `HTML$r および `DOM4$r 仕様に述べられる。 ◎ A document object model (DOM) is an in-memory representation of various types of Nodes where each Node is connected in a tree. The [HTML] and [DOM] specifications describe DOM and its Nodes in greater detail.
用語[ `構文解析@ は, ~DOMの文字列~表現を実際の~DOMへ変換するとき/ `直列化-@ は,~DOMを文字列へ変形して戻すとき ]に利用される用語である。 この仕様~自身は、 ~DOMを[ 構文解析する/直列化する ]ための各種~APIを定義することを扱う。 ◎ Parsing is the term used for converting a string representation of a DOM into an actual DOM, and Serializing is the term used to transform a DOM back into a string. This specification concerns itself with defining various APIs for both parsing and serializing a DOM.
例えば, `Element$I の `innerHTML$m ~APIは、[ ~DOMを直列化する/~DOMに構文解析する ]共通的な仕方を与える (それは、 この両方とも行える)。 特定0の `Node$I の~memory内~DOMが次であったとする: ◎ For example: the Element.innerHTML API is a common way to both parse and serialize a DOM (it does both). If a particular Node has the following in-memory DOM:
- `HTMLDivElement^I ( `nodeName^m ~EQ `div^l )
- `HTMLSpanElement^I ( `nodeName^m ~EQ `span^l)
- `Text^I ( `data^m ~EQ `ある^l )
- `HTMLElement^I ( `nodeName^m ~EQ `em^l )
- `Text^I ( `data^m ~EQ `文章。^l )
- `HTMLSpanElement^I ( `nodeName^m ~EQ `span^l)
HTMLDivElement (nodeName: "div")
┃
┣━ HTMLSpanElement (nodeName: "span")
┃ ┃
┃ ┗━ Text (data: "some ")
┃
┗━ HTMLElement (nodeName: "em")
┃
┗━ Text (data: "text!")
`HTMLDivElement^I ~nodeの子~群を直列化するためには、 単純に `Element$I の `innerHTML$m ~propを`取得する^em(読取る) (これは、 直列化を誘発する): ◎ And the HTMLDivElement node is stored in a variable myDiv, then to serialize myDiv's children simply get (read) the Element.innerHTML property (this triggers the serialization):
var %myDiv = /* ある `HTMLDivElement^I ~node */ var %serializedChildren = %myDiv.innerHTML; /* 結果は `<span>ある</span><em>文章。</em>^l になる。 ◎ // serializedChildren has the value: // "<span>some </span><em>text!</em>"
文字列から %myDiv 用の(その既存の子たちを置換して)新たな子を構文解析するためには、 単純に `innerHTML$m ~propを`設定する^em (これは、 アテガわれた文字列の構文解析を誘発する): ◎ To parse new children for myDiv from a string (replacing its existing children), simply set the Element.innerHTML property (this triggers parsing of the assigned string):
%myDiv.innerHTML = `<span>new</span><em>children!</em>^l;
[ ~HTML / ~XML( ~XHTMLは~XMLの一種である) ]における[ `構文解析$, `直列化-$ ]は、 各自の~markup言語の規則に従う。 上の例は,~HTMLの[ 構文解析/直列化 ]を示しているが、 それらに特有な~algoは `HTML$r 仕様に定義される。 この仕様は、 ~XMLを直列化するための~algoを与える。 ~XMLを構文解析するための文法は、 `XML10$r 仕様に述べられる。 ◎ This specification describes two flavors of parsing and serializing: HTML and XML (with XHTML being a type of XML). Each follows the rules of its respective markup language. The above example shows HTML parsing and serialization. The specific algorithms for HTML parsing and serializing are defined in the [HTML] specification. This specification contains the algorithm for XML serializing. The grammar for XML parsing is described in the [XML10] specification.
`往復-@ するとは、 ~DOMを直列化した結果の文字列を,即時に構文解析して~DOMに戻す 【または、そうしたときに元と同じに保たれる】 ことを意味する。 理想的には、 この処理nによる結果の~DOM内のどの `Node$I においても,その属性の~dataは失われることなく同一性が保たれるべきである。 が,~XMLにおいて`往復-$することは、 直列化しても `Node$I の~nsの同一性が保全されるよう配慮しなければナラナイ点で, とりわけ込み入っている (他方、 ~HTMLにおいては,~nsは無視される)。 ◎ Round-tripping a DOM means to serialize and then immediately parse the serialized string back into a DOM. Ideally, this process does not result in any data loss with respect to the identity and attributes of the Node in the DOM. Round-tripping is especially tricky for an XML serialization, which must be concerned with preserving the Node's namespace identity in the serialization (wereas namespaces are ignored in HTML).
次の~memory内~DOMに対する~XML直列化を考える: ◎ Consider the XML serialization of the following in-memory DOM:
- `Element^I ( `nodeName^m ~EQ `root^l )
- `HTMLScriptElement^I ( `nodeName^m ~EQ `script^l)
- `Text^I ( `data^m ~EQ `alert('hello world') ^l )
- `HTMLScriptElement^I ( `nodeName^m ~EQ `script^l)
Element (nodeName: "root")
┃
┗━ HTMLScriptElement (nodeName: "script")
┃
┗━ Text (data: "alert('hello world')")
`script$e 要素の同一性を保全するため、[ ~XML直列化は,当の要素( `HTMLScriptElement@~HEscripting#htmlscriptelement$I )の`~ns$eLを含むこと ]および[ 直列化された文字列は、 `~XML構文解析器$を通して`往復-$すること ]を許容しなければナラナイ。 上の `root^l 要素が変数 %root に格納されたと見做す下で, 次のように~XMLに直列化されたなら: ◎ An XML serialization must include the HTMLScriptElement's namespace in order to preserve the identity of the script element, and to allow the serialized string to round-trip through an XML parser. Assuming that root is in a variable named root:
var %xmlSerialization = `new XMLSerializer()@~HTMLdynamic#dom-xmlserializer-constructor$m.`serializeToString(root)@~HTMLdynamic#dom-xmlserializer-serializetostring$m;
結果は ⇒ `<root><script xmlns="http://www.w3.org/1999/xhtml">alert('hello world')</script></root>^l ◎ // xmlSerialization has the value: // "<root><script xmlns="http://www.w3.org/1999/xhtml">alert('hello world')</script></root>"
4. ~DOMを構文解析する/直列化するための~API
4.1. `DOMParser^I ~interface
`DOMParser@~HTMLdynamic#domparser$I の定義は、 `~HTML標準@~HTMLdynamic#the-domparser-interface$へ移動された。 ◎ The definition of DOMParser has moved to the HTML Standard.
4.2. `XMLSerializer^I ~interface
`XMLSerializer@~HTMLdynamic#xmlserializer$I の定義は、 `~HTML標準@~HTMLdynamic#the-xmlserializer-interface$へ移動された。 ◎ The definition of XMLSerializer has moved to the HTML Standard.
4.3. `InnerHTML^I ~mixin
【 `InnerHTML^I ~interface~mixinは除去され, その `innerHTML^m は `Element^I へ移動された。 】
`Element$I の `innerHTML$m の定義は、 `~HTML標準@~HTMLdynamic#the-innerhtml-property$へ移動された。 ◎ The definition of Element.innerHTML has moved to the HTML Standard.
4.4. `Element$I ~interfaceに対する拡張
`outerHTML@~HTMLdynamic#dom-element-outerhtml$m の定義は、 `~HTML標準@~HTMLdynamic#the-outerhtml-property$へ移動された。 ◎ The definition of Element.outerHTML has moved to the HTML Standard.
`insertAdjacentHTML@~HTMLdynamic#dom-element-insertadjacenthtml$m の定義は、 `~HTML標準@~HTMLdynamic#the-insertadjacenthtml()-method$へ移動された。 ◎ The definition of Element.insertAdjacentHTML has moved to the HTML Standard.
4.5. `Range$I ~interfaceに対する拡張
`createContextualFragment@~HTMLdynamic#dom-range-createcontextualfragment$m の定義は、 `~HTML標準@~HTMLdynamic#the-createcontextualfragment()-method$へ移動された。 ◎ The definition of Range.createContextualFragment() has moved to the HTML Standard.
5. 素片~用の構文解析-法と直列化-法
5.1. 構文解析-法
素片を構文解析する~algoの定義は、 `~HTML標準@~HTMLdynamic#fragment-parsing-algorithm-steps$へ移動された。 ◎ The definition of fragment parsing algorithm has moved to the HTML Standard.
5.2. 直列化-法
素片に直列化する~algoの定義は、 `~HTML標準@~HTMLdynamic#fragment-serializing-algorithm-steps$へ移動された。 ◎ The definition of fragment serializing algorithm has moved to the HTML Standard.
6. ~XML直列化
【 この節は,原文では § 5.2 の下位節として与えられているが、 この訳では独立な節に分離する。 この節が、 この仕様が定義する~modelの主要な部分を成すので。 】
`~XML直列化$は、 以下に挙げる仕方において,~HTML直列化から相違する: ◎ An XML serialization differs from an HTML serialization in the following ways:
-
[ `要素$/`属性$ ]を直列化するときは、 その[ `~ns$eL/`~ns$A ]は,常に保全される。 このことは、 一部の事例では,既存の[ ~ns接頭辞/`~ns接頭辞~宣言$/`既定の~ns宣言$ ]が[ 落とされる/代用される/変更される ](順不同)かもしれないことを意味する。 ~HTML直列化は、 ~nsを保全するよう試みない。 ◎ Elements and attributes will always be serialized such that their namespace is preserved. In some cases this means that an existing prefix, prefix declaration attribute or default namespace declaration attribute might be dropped, substituted or changed. An HTML serialization does not attempt to preserve the namespace.
【 `~ns接頭辞~宣言@ ( `namespace prefix declaration^en ) とは, `既定の~ns@~XNLNS10#dt-defaultNS$を宣言する`属性$の略記であり、 `既定の~ns宣言@ ( `default namespace declaration^en ) とは,`~ns接頭辞@~XNLNS10#dt-prefix$を宣言する`属性$の略記である (いずれも,`~XMLNS~ns$に属する)。 `XMLNS$r 】【 ~ns接頭辞~宣言は、 原文では~ns接頭辞~定義 ( `namespace prefix definition^en / `prefix definition^en ) とも称されるが、 この訳では,一律に~ns接頭辞~宣言と称することにする。 】
- `~HTML~ns$に属さない`要素$のうち,`子$を包含していないものは、 `空~要素~tag$の構文を利用して(すなわち,~XML `EmptyElemTag$P 生成規則に則って)直列化される。 ◎ Elements not in the HTML namespace containing no children, are serialized using the empty-element tag syntax (i.e., according to the XML EmptyElemTag production).
他においては、 `~XML直列化$を生産する~algoは, `~HTML構文解析器$と互換な直列化を生産するよう設計されている。 例えば,`~HTML~ns$に属する`要素$のうち`子$を包含しないものは、 `空~要素~tag$の構文を利用することなく,明示的な[ 開始~tag, 終了~tag ]を伴って直列化される 【`~void要素$であっても】。 ◎ Otherwise, the algorithm for producing an XML serialization is designed to produce a serialization that is compatible with the HTML parser. For example, elements in the HTML namespace that contain no children are serialized with an explicit begin and end tag rather than using the empty-element tag syntax.
`~XML直列化@ を生産する~algoは、 所与の ( `Node$I %~node, 真偽値 `整形式が要求されるか$V ) に対し: ◎ To produce an XML serialization of a Node node given a boolean require well-formed, run the following steps:
-
次に挙げる[ 引数/変数 ]は、[ この~algoから呼出される,この節にて定義される各種~algo ]すべてから参照され,共有される:
- `整形式が要求されるか@V ⇒ この~flagは、 決して変更されない。
- `接頭辞~index@V (以下で宣言される)
【 この規約は、 各種~algoにおける引数の受け渡しに関する記述を簡素化するための,この訳による追加。 】
-
%~ns ~LET ~NULL ◎ Let namespace be null.
注記: %~ns 【この~algoから呼出される各~algoの引数 %~ns, あるいは %継承された~ns 】 は、 `~XML直列化$~algoの中で現在の既定の~nsを追跡するためにあり, 次が生じたときに変更される: ◎ Note namespace tracks the XML serialization algorithm's current default namespace. It is changed when either\
- ある`要素$が`既定の~ns宣言$を有するとき ◎ an Element has a default namespace declaration, or\
- この~algoが,ある`要素$用に[ その自前の~nsに合致する`既定の~ns宣言$ ]を生成するとき ◎ the algorithm generates a default namespace declaration for the Element to match its own namespace.\
この~algoは ~nsなし( ~NULL )から開始するものと見做す。 ◎ The algorithm assumes no namespace (null) to start.
- %接頭辞~map ~LET 新たな`~ns接頭辞~map$ ◎ Let prefix map be «» (a namespace prefix map).
- `接頭辞~mapに追加する$( %接頭辞~map, `xml^l, `~XML~ns$ ) ◎ Add "xml" to prefix map given the XML namespace.
-
`接頭辞~index$V ~LET 1 ◎ Let prefix index be 1.
注記: `接頭辞~index$V は、[ `要素$【! %~node 】の`~ns$eL (あるいは,要素の`属性~list$を成す いずれかの`属性$の`~ns$A) を直列化する際に,相応しい既存の~ns接頭辞が可用でないとき ]に[ 新たな, かつ一意な`接頭辞を生成する$ ]ために利用される。 ◎ Note prefix index is used to generate a new unique prefix when no suitable existing namespace prefix is available to serialize a node's namespace (or the namespace of one of the attributes in node's attribute list). See the generate a prefix algorithm.
-
~RET `~nodeを~XMLに直列化する$( %~node, %~ns, %接頭辞~map )
この段で`整形式~性~error$が投出されたときは、 ~catchして ⇒ ~THROW `InvalidStateError$E
`整形式~性~error@ は、 直列化した結果が整形式にならないことを指示する~~仮想の例外である。
【 この用語は、[ 明確化する/他所の記述を集約する ]ための,この訳による追加。 】
◎ Return the result of running the XML serialization algorithm given node, namespace, prefix map, a mutable reference to prefix index, and require well-formed. If an exception occurs during the execution of the algorithm, then catch that exception and throw an "InvalidStateError" DOMException.
`~nodeを~XMLに直列化する@ ~algoは、 所与の ( `Node$I %~node, 文字列 %~ns, `~ns接頭辞~map$ %接頭辞~map ) に対し, %~node の~interfaceに応じて: ◎ The XML serialization algorithm, given a Node node, a string namespace, a namespace prefix map prefix map, a mutable reference to an integer prefix index, and a boolean require well-formed, must run the following steps: ◎ • If node's interface is:
- `Element$I
- `Element$srz( %~node, %~ns, %~ns接頭辞~map ) ◎ Run the algorithm for XML serializing an Element node given node, namespace, namespace prefix map, prefix index and require well-formed.
- `Document$I
- `Document$srz( %~node, %~ns, %~ns接頭辞~map ) ◎ Run the algorithm for XML serializing a Document node given node, namespace, namespace prefix map, prefix index and require well-formed.
- `Comment$I
- `Comment$srz( %~node ) ◎ Run the algorithm for XML serializing a Comment node given node and require well-formed.
- `CDATASection$I
- `CDATASection$srz( %~node ) ◎ Run the algorithm for XML serializing a CDATASection node given node and require well-formed.
- `Text$I
- `Text$srz( %~node ) ◎ Run the algorithm for XML serializing a Text node given node and require well-formed.
- `DocumentFragment$I
- `DocumentFragment$srz( %~node, %~ns, %~ns接頭辞~map ) ◎ Run the algorithm for XML serializing a DocumentFragment node given node, namespace, namespace prefix map, prefix index and require well-formed.
- `DocumentType$I
- `DocumentType$srz( %~node ) ◎ Run the algorithm for XML serializing a DocumentType node given node and require well-formed.
- `ProcessingInstruction$I
- `ProcessingInstruction$srz( %~node ) ◎ Run the algorithm for XML serializing a ProcessingInstruction node given node and require well-formed.
- `Attr$I
- ~RET 空~文字列 ◎ Return the empty string.
- その他 ◎ Anything else
- ~THROW `TypeError$E ◎ Throw a TypeError.\
- (この~algoが直列化できるものは[ `Node$I / `Attr$I ]に限られる。) ◎ Only Nodes and Attrs can be serialized by this algorithm.
注記: 上で参照された各~algoは、 以下の各~下位節にて詳細される。 ◎ Note Each of the above referenced algorithms are detailed in the sections that follow.
6.1. `Element^srz
`Element@srz ~algoは、 所与の ( `Element$I ~node %~node, 文字列 %継承された~ns【!namespace】, `~ns接頭辞~map$ %接頭辞~map ) に対し: ◎ The algorithm for XML serializing an Element node, given an Element node, a string namespace, a namespace prefix map prefix map, a mutable reference to an integer prefix index, and a boolean require well-formed, must run the following steps:
-
%要素 ~LET %~node
【 この段は、 以下を読み易くするための,この訳による追加(単なる名称変更)。 】
- %局所~名 ~LET %要素 の`局所~名$eL ◎ ↓
- ~IF[ `整形式が要求されるか$V ~EQ ~T ] ⇒ ~IF[ %局所~名 は`003A^U を包含する ]~OR[ %局所~名 は~XML `Name$P 生成規則に合致しない ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and node's local name contains the character ":" (U+003A COLON) or does not match the XML Name production, then throw an exception.\ (The serialization of node would not be well-formed.)
- %~markup ~LET `003C^U ◎ Let markup be "<" (U+003C LESS-THAN SIGN).
- %有修飾~名 ~LET ε【!空~文字列】 ◎ Let qualified name be the empty string. ◎ ↓ Let skip end tag be false.
- %~ns定義~属性を無視するか ~LET ~F ◎ Let ignore namespace definition attribute be false.
- %~map ~LET `~ns接頭辞~mapを複製する$( %接頭辞~map ) ◎ Let map be the result of copy a namespace prefix map given prefix map.
-
%局所~接頭辞~map ~LET 新たな`有順序~map$ ◎ Let local prefixes map be « » (an ordered map from strings to strings).
注記: この~mapを成す各~entryの:
- ~keyは、 文字列であり,ある~ns接頭辞を与える。
- 値は、 文字列であり,ある~nsを与える — 空~文字列は、 ~NULL ~nsを表現する。
注記: この~mapは、 要素ごとに局所的であり: ◎ Note This map is local to each element.\
- 次を確保するために利用される ⇒ 新たな`~ns接頭辞~宣言$が必要になる場合に, 他の接頭辞と競合しない`接頭辞を生成する$。 ◎ It is used to ensure there are no conflicting prefixes if a new namespace prefix attribute needs to be generated.\
- 次を可能化するために利用される ⇒ %要素 用に`要素の属性たちを~XMLに直列化する$ときに, 重複している`~ns接頭辞~宣言$を飛ばす。 ◎ It is also used to enable skipping of duplicate prefix definitions when writing an element's attributes:\
- 次をこの~algoに許容する ⇒ `~ns接頭辞~map$内の接頭辞のうち[ %要素 に局所的に定義されるもの, そうでないもの ]を判別する。 ◎ the map allows the algorithm to distinguish between a prefix in the namespace prefix map that might be locally-defined (to the current Element) and one that is not.
-
%局所的な既定の~ns ~LET `要素の~ns情報を記録する$( %要素【!'s `属性~list$】, %~map, %局所~接頭辞~map ) ◎ Let local default namespace be the result of recording the namespace information for node's attribute list given map and local prefixes map.
注記: この段は、 【%要素 上に】見出された`~ns接頭辞~宣言$で %~map を更新することに加え, %局所~接頭辞~map にも当の定義を追加する。 %局所的な既定の~ns は、 %要素 上に既定の~nsを定義する属性が[ 在るならば それが定義する~ns(空~文字列は ~NULL ~nsを表現する)/ 無いならば ε ]になる。 ◎ Note The above step will update map with any found namespace prefix definitions, add the found prefix definitions to local prefixes map and return the value of a default namespace attribute (which can be empty) if one exists. Otherwise it returns null.
- %~ns ~LET %要素 の`~ns$eL ◎ ↑ Let inherited ns be namespace. ◎ Note inherited ns will be passed down as the namespace argument when serializing node's children. ◎ Let ns be node's namespace.
-
~IF[ %継承された~ns ~EQ %~ns ]: ◎ If inherited ns is ns, then:
注記: %要素 は %継承された~ns 【!現在の既定の~ns】に属する。 この場合、 %要素 は(接頭辞を有していた場合でも)接頭辞を伴わずに, `既定の~ns宣言$も落として直列化されることになる。 例外は, %要素 が`~XML~ns$に属する場合であり、 その事例では,接頭辞 `xml:^l が利用される — この接頭辞は宣言される必要はないので、 それを宣言する労も為されない。 ◎ Note node is in the current default namespace. The steps below serialize node without a prefix (even if it had one), and drop any default namespace declaration. An exception is made if node is in the XML namespace, in which case the "xml:" prefix is used; this prefix does not need to be declared and no effort is made to declare it.
- ~IF[ %局所的な既定の~ns ~NEQ ε ] ⇒ %~ns定義~属性を無視するか ~SET ~T ◎ If local default namespace is not null, then set ignore namespace definition attribute to true.
- %有修飾~名 ~SET %~ns に応じて ⇒# `~XML~ns$ならば `xml:^l / ~ELSE_ 空~文字列 ◎ If ns is the XML namespace, then append the concatenation of "xml:"\
- %有修飾~名 に %局所~名 を付加する ◎ and node's local name to qualified name. ◎ Otherwise, append node's local name to qualified name.
- %~markup に %有修飾~名 を付加する ◎ Append qualified name to markup.
-
~ELSE: ◎ Otherwise:
注記: この場合, %要素 の`~ns$eLは %継承された~ns 【!the context namespace】とは異なるので、 そうなるよう直列化する必要がある。 以下では,可用な~ns接頭辞が[ 在るならば,それを利用する/ 無いならば,`既定の~ns宣言$を利用するか導入する ]ことになる。 ◎ Note inherited ns is not equal to ns; node's own namespace is different from the context namespace. To differentiate node's namespace from the context namespace, the steps below will use a namespace prefix if one is available; if not, they will use or introduce a default namespace declaration.
- %接頭辞 ~LET %要素 の`~ns接頭辞$eL ◎ Let prefix be node's namespace prefix.
-
%候補~接頭辞 ~LET `選好される接頭辞~文字列を検索取得する$( %~map, %~ns, %接頭辞 ) ◎ Let candidate prefix be the result of retrieving a preferred prefix string prefix from map given ns.
注記: %候補~接頭辞 が ~NULL になる事例では ( %~ns へ対応付けられる接頭辞は見出されなかった【!(not even prefix)】)、 この~algoは, 新たな`~ns接頭辞~宣言$( `xmlns:^a )を生成して, %~map に新たな接頭辞を`追加する@#dfn-add$ことになる。 ◎ Note candidate prefix will be null if no prefix was found that maps to ns (not even prefix). In that case, this algorithm will generate a new xmlns attribute and add any new prefix to map below.
-
~IF[ %接頭辞 ~EQ `xmlns^l ]: ◎ If prefix is "xmlns", then:
- ~IF[ `整形式が要求されるか$V ~EQ ~T ] ⇒ ~THROW `整形式~性~error$ ( %要素 は適合な`~XML構文解析器$においては合法に往復しない。) ◎ If require well-formed is true, then throw an exception. An Element with namespace prefix "xmlns" will not legally round-trip in a conforming XML parser.
- %候補~接頭辞 ~SET `xmlns^l ◎ Set candidate prefix to prefix.
-
~IF[ %候補~接頭辞 ~NEQ ~NULL ]: ◎ Found a suitable namespace prefix: if candidate prefix is not null, then:
注記: %要素 の`広義-先祖$のうち いずれかが, %要素 の`~ns$eLへ対応付けられる %候補~接頭辞 を定義する`~ns接頭辞~宣言$を有している。 ◎ Note Either node or one of its ancestors defines that candidate prefix maps to node's namespace.
注記: 以下は、 %接頭辞 【!%要素 の既存の`~ns接頭辞$eL】とは異なる接頭辞を直列化することもある。 しかしながら、 これが起こるのは, %接頭辞 が正しい~nsへ対応付けられていない場合に限られる — `選好される接頭辞~文字列を検索取得する$ときに, すでに %接頭辞 を照合するよう試行したので。 ◎ Note The following could serialize a different prefix than node's existing namespace prefix, if any. However, this only happens if this prefix does not map to the correct namespace, as the retrieving a preferred prefix string algorithm already tried to match the existing prefix.
[`課題 #52@https://github.com/w3c/DOM-Parsing/issues/52$] 次の~XML文書を構文解析してから直列化したとする: ◎ Issue 52: XMLSerializer: Should prefer the default namespace to a prefix declared in an ancestor xml-serialization ◎ Suppose that we have the following XML document, parse it, and serialize it.
<root xmlns:x="uri1"> <table xmlns="uri1"/> </root>
現在の仕様に従うなら、 その結果は: ◎ If we follow the current specification, the serialization result is:
<root xmlns:x="uri1"> <x:table xmlns="uri1"/> </root>
これは、[ Edge, Firefox, Safari, Chrome 73- ]とは互換でない。 ( Chrome 74 は、 上と同じ結果を生産するが,それは修正-中にある。) ◎ It's incompatible with Edge, Firefox, Safari, and Chrome 73-. (Chrome 74 produces the above result, and we're fixing it.)
編集者は、 上の段:
- %候補~接頭辞 ~LET `選好される接頭辞~文字列を検索取得する$( %~map, %~ns, %接頭辞 )
を次のように変更するべきと~~考えている:
-
%候補~接頭辞 ~LET [ ~AND↓ が満たされるならば ~NULL / ~ELSE_ `選好される接頭辞~文字列を検索取得する$( %~map, %~ns, %接頭辞 ) ]:
- %接頭辞 ~EQ ~NULL
-
~OR↓:
- [ %~ns ~EQ ~NULL ]~AND[ %局所的な既定の~ns ~EQ ε 【空~文字列?】 ]
- %~ns ~EQ %局所的な既定の~ns
この挙動~用の`~test事例@https://wpt.live/domparsing/XMLSerializer-serializeToString.html$ ( `"Check if start tag serialization does NOT apply the default namespace if its namespace is declared in an ancestor."^en ) もある。 ◎ WPT domparsing/XMLSerializer-serializeToString.html contains a testcase for this behavior. "Check if start tag serialization does NOT apply the default namespace if its namespace is declared in an ancestor."
-
%有修飾~名 ~SET 次を順に連結した結果:
- %候補~接頭辞
- `003A^U
- %局所~名
-
~IF[ %局所的な既定の~ns ~NIN { ε, `~XML~ns$ } ] ⇒ %継承された~ns ~SET %局所的な既定の~ns に応じて ⇒# 空~文字列ならば ~NULL / ~ELSE_ %局所的な既定の~ns ◎ If local default namespace is not null\ ↓ (node has a default namespace declaration attribute)\ and is not the XML namespace, then: • If local default namespace is the empty string, set inherited ns to null. • Otherwise, set inherited ns to local default namespace.
注記: %要素 は`既定の~ns宣言$を有する。 %継承された~ns が %要素 の`~ns$eLとは相違するアリ性もある。 ◎ Note It is possible that inherited ns differs from node's namespace.
注記: [ `既定の~ns宣言$/`~ns接頭辞~宣言$ ]のうち`~XML~ns$を定義するものは、 %要素 の`属性~list$を成す`属性$たちを直列化するときには,省略される。 ◎ Note Any default namespace definitions or namespace prefixes that define the XML namespace are omitted when serializing attributes in node's attribute list.
- %~markup に %有修飾~名 を付加する ◎ Append qualified name to markup.
-
~ELIF[ %接頭辞 ~NEQ ~NULL ]: ◎ Otherwise, if prefix is not null, then:
注記: %要素 の どの`広義-先祖$【!node (or any parent Node visited by this algorithm) 】にも,[ %要素 の`~ns$eLへ対応付けられる接頭辞 ]を定義する`~ns接頭辞~宣言$は無い — さもなければ、 前~段【!#dfn-found-a-suitable-namespace-prefix】が遂行されるはずなので。 理想的には, %接頭辞 【!%要素 の`~ns接頭辞$eL】を利用したい所だが、[ %接頭辞 を %要素 の`~ns$eL以外の~nsへ対応付ける`~ns接頭辞~宣言$ ]を すでに %要素 が有する事例もある。 その事例においては、 最後の拠所として`接頭辞を生成する$ことになる。 いずれにせよ、 以下において,[ 最終的に利用する接頭辞 ]用に新たな`~ns接頭辞~宣言$を直列化することになる。 ◎ Note By this step, there is no namespace or prefix mapping declaration in node (or any parent Node visited by this algorithm) that defines a prefix that maps to node's namespace; otherwise the step labelled Found a suitable namespace prefix would have been followed. Ideally we would use node's namespace prefix. However, it could be the case that node already declares its own prefix as mapping to something else than its own namespace. In that case we will generate a new prefix as a last resort. In either case, the sub-steps that follow will serialize a new namespace prefix declaration for the prefix we end up using.
- ~IF[ %局所~接頭辞~map[ %接頭辞 ] ~NEQ ε ] ⇒ %接頭辞 ~SET `接頭辞を生成する$( %~map, %~ns ) ◎ If local prefixes map contains prefix, then set prefix to the result of generating a prefix given map, ns, and prefix index.
- `接頭辞~mapに追加する$( %~map, %接頭辞, %~ns ) ◎ Add prefix to map given ns.
-
%有修飾~名 ~SET 次を順に連結した結果:
- %接頭辞
- `003A^U
- %局所~名
- %~markup に %有修飾~名 を付加する ◎ Append qualified name to markup.
-
%~markup に次を順に付加する
- ~SPACE
- `xmlns:^l
- %接頭辞
- `003D^U
- `0022^U
- `属性~値を直列化する$( %~ns )
- `0022^U
注記: これは、 上で %~map へ追加した %接頭辞 用の`~ns接頭辞~宣言$を直列化する。
◎ Append the following to markup, in the order listed: ◎ Note The following serializes a namespace prefix declaration for prefix which was just added to map. ◎ • " " (U+0020 SPACE); • "xmlns:"; • prefix; • "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); • The result of serializing an attribute value given ns and require well-formed; • """ (U+0022 QUOTATION MARK). - ~IF[ %局所的な既定の~ns ~NEQ ε ] ⇒ %継承された~ns ~SET %局所的な既定の~ns に応じて ⇒# 空~文字列ならば ~NULL / ~ELSE_ %局所的な既定の~ns ◎ If local default namespace is not null (node has a default namespace declaration attribute), then: • If local default namespace is the empty string, set inherited ns to null. • Otherwise, set inherited ns to local default namespace.
-
~ELIF[ 【!不要:%局所的な既定の~ns ~EQ ε ~OR 】 %局所的な既定の~ns ~NEQ %~ns ]: ◎ Otherwise, if local default namespace is null, or local default namespace is not null and its value is not equal to ns, then:
注記: %要素 用の~nsは,依然として直列化される必要があるが、 ここでは, %接頭辞 も %候補~接頭辞 も可用でない。 そのため、 この段では,`既定の~ns宣言$を利用して~nsを定義する — 既存の`既定の~ns宣言$が在る場合、 それは置換される。 ◎ Note At this point, the namespace for this node still needs to be serialized, but there's no namespace prefix (or candidate prefix) available; the following uses the default namespace declaration to define the namespace—optionally replacing an existing default declaration if present.
- %~ns定義~属性を無視するか ~SET ~T ◎ Set ignore namespace definition attribute to true.
- %有修飾~名 ~SET %局所~名 ◎ Append node's local name to qualified name.
-
%継承された~ns ~SET %~ns ◎ Set inherited ns to ns.
注記: 新たな既定の~nsは、 直列化において %要素 の`~ns$eLを定義するために利用され, その`子$たちに継承される~ns【!文脈~ns】として動作することになる。 ◎ Note The new default namespace will be used in the serialization to define node's namespace and act as the context namespace for its children.
- %~markup に %有修飾~名 を付加する ◎ Append qualified name to markup.
-
%~markup に次を順に付加する:
- ~SPACE
- `xmlns^l
- `003D^U
- `0022^U
- `属性~値を直列化する$( %~ns )
- `0022^U
注記: これは、 新たな(または既存のものを置換する)`既定の~ns宣言$を直列化する。
◎ Append the following to markup, in the order listed: ◎ Note The following serializes the new (or replacement) default namespace definition. ◎ • " " (U+0020 SPACE); • "xmlns"; • "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); • The result of serializing an attribute value given ns and require well-formed; • """ (U+0022 QUOTATION MARK).
-
~ELSE【!local default namespace is ns.】: ◎ Otherwise: ◎ Note local default namespace is ns.
- %有修飾~名 ~SET %局所~名 ◎ Append node's local name to qualified name.
- %継承された~ns ~SET %~ns ◎ Set inherited ns to ns.
- %~markup に %有修飾~名 を付加する ◎ Append qualified name to markup.
注記: %~ns と %継承された~ns が等しくない場合の各~組合nは,すべて この段の中で取扱われ、 %要素 は,その元の`~ns$eLを保全するよう直列化されることになる。 ◎ Note All of the combinations where ns is not equal to inherited ns are handled above such that node will be serialized preserving its original namespace.
- %~markup に次の結果を付加する ⇒ `要素の属性たちを~XMLに直列化する$( %要素, %~map, %局所~接頭辞~map, %~ns定義~属性を無視するか ) ◎ Append to markup the result of the XML serialization of the attributes of node given map, prefix index, local prefixes map, ignore namespace definition attribute, and require well-formed.
-
~IF[ %要素 の`子~群$は`空$である ]~AND[ ~OR↓ ]…
- %~ns ~NEQ `~HTML~ns$
-
[ %~ns ~EQ `~HTML~ns$ ]~AND[ %局所~名 ~IN { `area^l , `base^l , `basefont^l , `bgsound^l , `br^l , `col^l , `embed^l , `frame^l , `hr^l , `img^l , `input^l , `keygen^l , `link^l , `menuitem^l , `meta^l , `param^l , `source^l , `track^l , `wbr^l } ~FN ]
【~FN これらは、[ `~void要素$/ `HTML$r において`廃用にされた要素@~HTMLobs$/ `HTML$r には言及されていない要素( `menuitem^e ) ]の~tag名を与える。 (これらのうち,廃用にされたものは、 ~void要素であるものとは定義されていないが, `~HTML構文解析器$においては~void要素と同様に扱われる。) 】
…ならば: 【!and set skip end tag to true】
- ~IF[ %~ns ~EQ `~HTML~ns$ ] ⇒ %~markup に ~SPACE を付加する
-
%~markup に次を順に付加する:
- `002F^U
- `003E^U
- ~RET %~markup
注記: %要素 は~~末端~nodeである 【ので、`空~要素~tag$の構文を利用する】。
◎ If ns is the HTML namespace, and node's children is empty, and node's local name is one of the following: "area", "base", "basefont", "bgsound", "br", "col", "embed", "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"; then append the following to markup, in the order listed: • " " (U+0020 SPACE); • "/" (U+002F SOLIDUS). ◎ and set skip end tag to true. ◎ If ns is not the HTML namespace, and node's children is empty, then append "/" (U+002F SOLIDUS) to markup and set skip end tag to true. ◎ Append ">" (U+003E GREATER-THAN SIGN) to markup. ◎ If skip end tag is true, then return markup. node is a leaf node. -
~IF[ %~ns ~EQ `~HTML~ns$ ]~AND[ %局所~名 ~EQ `template^l ] ⇒ %~markup に次の結果を付加する ⇒ `DocumentFragment$srz( %要素 の`~template内容$, %継承された~ns, %~map ) ◎ If ns is the HTML namespace, and node's local name is "template" (this is a template element), append to markup the result of XML serializing a DocumentFragment node given node's template contents (a DocumentFragment), inherited ns, map, prefix index, and require well-formed.
注記: %要素 は `template$e 要素であり, その`~template内容$は `DocumentFragment$I である。 これは、 `~XHTML文書を構文解析する規則@~HTMLxml#parsing-xhtml-documents$の下でも, `~template内容$が往復できるようにする。 ◎ ↑ ◎ Note This allows template content to round-trip, given the rules for parsing XHTML documents.
- ~ELSE ⇒ %要素 の`子~群$を成す ~EACH( %子 ) に対し ⇒ %~markup に次の結果を付加する ⇒ %子 を`~nodeを~XMLに直列化する$( %子, %継承された~ns, %~map ) ◎ Otherwise, for each child of node's children: • Append to markup the result of running the XML serialization algorithm given child, inherited ns, map, prefix index, and require well-formed.
-
%~markup に次を順に付加する:
- `003C^U
- `002F^U
- %有修飾~名
- `003E^U
- ~RET %~markup ◎ Return markup.
6.1.1. ~nsの記録-法
注記: 次の~algoは、 要素に局所的な`~ns接頭辞~宣言$を見出して, それらを %局所~接頭辞~map (初期~時は空)に追加した上で, それらで`~ns接頭辞~map$も更新する。 加えて、 要素に局所的な`既定の~ns宣言$が[ 在るならば それが与える~ns / 無いならば ε ]を返す。 ◎ Note This following algorithm will update the namespace prefix map with any found namespace prefix definitions, add the found prefix definitions to local prefixes map, and return a local default namespace value defined by a default namespace attribute if one exists. Otherwise it returns null.
`要素の~ns情報を記録する@ ~algoは、 所与の ( `要素$ %要素【!list of attributes attributes】, `~ns接頭辞~map$ %~map, `有順序~map$ %局所~接頭辞~map ) に対し: ◎ When recording the namespace information for a list of attributes attributes, given a namespace prefix map map and an ordered map local prefixes map, run the following steps:
-
%既定の~ns属性~値 ~LET ε ◎ Let default namespace attr value be null.
【 この訳では、 原文の ~NULL に代えて ε を利用する。 ~NULL は “~NULL ~ns” と紛らわしいので (原文において,この~algoが返す ~NULL は、 ~NULL ~nsを表現する値ではなく,純粋に無いことを表現する)。 】
-
%要素 の`属性~list$を成す ~EACH( `属性$ %属性 ) に対し: ◎ For each attr of attributes:
注記: この段を成す手続きは、 `~XMLNS~ns$に属する`属性$のみを考慮する下で,~ns接頭辞を見出す (例:
`setAttribute@~DOM4#dom-element-setattribute$m( `xmlns:pretend-prefix^l, `pretend-namespace^l )などを介して~ns宣言に見せかけた属性は、 含まれない)。 ◎ Note The following conditional steps find namespace prefixes. Only attributes in the XMLNS namespace are considered (e.g., attributes made to look like namespace declarations via setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not included).- %属性~ns ~LET %属性 の`~ns$A ◎ Let attribute namespace be attr's namespace.
- %属性~接頭辞 ~LET %属性 の`~ns接頭辞$A ◎ Let attribute prefix be attr's namespace prefix.
- ~IF[ %属性~ns ~NEQ `~XMLNS~ns$ ] ⇒ ~CONTINUE ◎ If attribute namespace is the XMLNS namespace, then:
-
~IF[ %属性~接頭辞 ~EQ ~NULL ]:
-
%既定の~ns属性~値 ~SET %属性 の`値$A
注記: %属性 は`既定の~ns宣言$である。
- ~CONTINUE
-
-
%接頭辞 ~LET %属性 の`局所~名$A
注記: %属性 は`~ns接頭辞~宣言$である。
◎ •• Note •• attribute prefix is not null and attr is a namespace prefix definition. ◎ •• Let prefix definition be attr's local name. - %~ns ~LET %属性 の`値$A ◎ •• Let namespace definition be attr's value.
-
~IF[ %~ns ~EQ `~XML~ns$ ] ⇒ ~CONTINUE ◎ •• If namespace definition is the XML namespace, then continue.
注記: `~XML~ns$を定義する接頭辞は、 完全に無視される (接頭辞が競合し得るときの不必要な作業を避けるため)。 `~XML~ns$に属する`要素$は、[ 常に,当の要素の`局所~名$eLに予約-済み接頭辞 `xml^l を接頭する ]よう,一律に(また,必要yなら上書きするよう)取扱われる。 ◎ •• Note •• XML namespace definitions in prefixes are completely ignored (in order to avoid unnecessary work when there might be prefix conflicts). Elements in the XML namespace are always handled uniformly by prefixing (and overriding if necessary) the element's local name with the reserved "xml" prefix.
-
~IF[ %~ns ~EQ 空~文字列 ] ⇒ %~ns ~SET ~NULL
注記: 空~文字列は、 どの~nsにも属さないことの宣言的な形である。
◎ •• If namespace definition is the empty string (the declarative form of having no namespace), then set namespace definition to null. -
~IF[ `接頭辞が見出されるか否か$( %~map, %接頭辞, %~ns ) ~EQ ~T ] ⇒ ~CONTINUE ◎ •• If prefix definition is found in map given namespace definition, then continue.
注記: この段は、 同じ~nsに対応する`~ns接頭辞~宣言$が, %~map 内に重ねて追加されることを避ける。 これには、[ 後で,子孫~nodeにおける`~ns接頭辞~宣言$が重ねて直列化されること ]を避ける副作用が有る。 ◎ •• Note •• This step avoids adding duplicate prefix definitions for the same namespace in map. This has the side-effect of avoiding later serialization of duplicate namespace prefix declarations in any descendant nodes.
- `接頭辞~mapに追加する$( %~map, %接頭辞, %~ns ) ◎ •• Add prefix definition to map given namespace definition.
- %局所~接頭辞~map[ %接頭辞 ] ~SET %~ns に応じて ⇒# ~NULL ならば 空~文字列/ ~ELSE_ %~ns ◎ •• If namespace definition is null, then set namespace definition to the empty string. ◎ •• Set local prefixes map[prefix definition] to namespace definition.
-
~RET %既定の~ns属性~値 ◎ Return default namespace attr value.
注記: 空~文字列は ε【!~NULL】 に変換されない — それも、 %既定の~ns属性~値 として正当なので。 ◎ Note The empty string is a legitimate return value and is not converted to null.
6.1.2. ~ns接頭辞~map
`~ns接頭辞~map@ は、 `有順序~map$であり,それを成す各~entryの:
- ~keyは、[ ~NULL /`文字列$ ]である。
- 値は、 `接頭辞~list@ と称される,`文字列$たちが成す`~list$である。
注記: 各~keyは、 ある~nsを与える — ~NULL は、 どの~nsにも属さないことを表現する。 ~keyに対応する値がとる`接頭辞~list$は,その~nsへ対応付けられる~ns接頭辞たちを与える。 ◎ Note The keys are namespaces, with null representing no namespace; the values are lists of prefixes that map to that namespace.
`~XML直列化$の開始-時には,空な`~ns接頭辞~map$が作成されることになる。 この~mapは、 新たな`要素$に遭遇するごとに(`~ns接頭辞~mapを複製する$ことにより)~cloneされ, 当の要素~用に新たな結付けを追加することになる (首に,`要素の~ns情報を記録する$際に — 特定0の~ns用に可用な接頭辞が無いときは,新たな~ns宣言も追加する)。 ◎ An empty namespace prefix map will be created at the start of the XML serialization algorithm. Whenever a new Element is encountered, the map will be cloned (copy a namespace prefix map) and new associations will be added for that Element (primarily in recording the namespace information, but also when adding new namespace declarations because no prefix is available for a particular namespace).
所与の~ns用の`接頭辞~list$を成す接頭辞たちの順序は、 出くわした順になる。 `要素$を直列化するときには、 この~list内に当の要素の`~ns接頭辞$eLが[ 在るならば,それ/ 無いならば,この~listを成す最後の接頭辞 ]が利用される。 追加的な詳細は、 `選好される接頭辞~文字列を検索取得する$を見よ。 ◎ The last seen prefix for a given namespace is at the end of its respective list. When serializing, the Element's namespace prefix will be used if it is in the list; otherwise the last prefix in the list is used. See retrieve a preferred prefix string for additional details.
`~ns接頭辞~mapを複製する@ ~algoは、 所与の ( `~ns接頭辞~map$ %~map ) に対し: ◎ To copy a namespace prefix map map:
- %複製 ~LET 新たな`~ns接頭辞~map$ ◎ Let copy be a new namespace prefix map.
- %~map を成す ~EACH( %~key → %値 ) に対し ⇒ %複製[ %~key ] ~SET %値 を`~cloneする$ ◎ For each key → value in map: • Set copy[key] to a clone of value.
- ~RET %複製 ◎ Return copy.
`選好される接頭辞~文字列を検索取得する@ ~algoは、 所与の ( `~ns接頭辞~map$ %~map, ~ns %~ns, [ ~NULL/文字列 ] %選好される接頭辞 ) に対し: ◎ To retrieve a preferred prefix string preferred prefix (a string or null) from the namespace prefix map map given a namespace ns:
- %接頭辞~list ~LET %~map[ %~ns ] ◎ ↓
- ~IF[ %接頭辞~list ~EQ ε ] ⇒ ~RET ~NULL ◎ If map does not contain ns, return null. ◎ Let candidates be map[ns].
- ~Assert: %接頭辞~list は`空$でない。 ◎ Assert: candidates is not empty.
- ~IF[ 【! 不要:If prefix is not null, then:】 %選好される接頭辞 ~IN %接頭辞~list ] ⇒ ~RET %選好される接頭辞 ◎ If prefix is not null, then: • For each prefix of candidates: •• If prefix is preferred prefix, return prefix.
- ~RET %接頭辞~list[ %接頭辞~list の`~size$ ~MINUS 1 ] ◎ Return candidates[size of candidates - 1].
`接頭辞~mapに追加する@ ~algoは、 所与の ( `~ns接頭辞~map$ %~map, 文字列 %接頭辞, %~ns ) に対し:
- ~IF[ %~map[ %~ns ] ~EQ ε ] ⇒ %~map[ %~ns ] ~SET « »
- %~map[ %~ns ] に %接頭辞 を`付加する$
注記: `選好される接頭辞~文字列を検索取得する$手続きは、 `接頭辞~list$を利用して, 所与の~nsを結付けている接頭辞のうち最も近過去に利用されたもの — 当の~listを成す最後の接頭辞 — を追跡する。 この~listは、 より早く出くわした同じ接頭辞を重複して包含し得る (そうなってもかまわない)。 ◎ Note The steps in retrieve a preferred prefix string use the list to track the most recently used prefix associated with a given namespace, which will be the prefix at the end of the list. This list can contain duplicates of the same prefix seen earlier (and that's OK).
6.1.3. 要素の属性たちの直列化-法
`要素の属性たちを~XMLに直列化する@ ~algoは、 所与の ( `要素$ %要素, `~ns接頭辞~map$ %~map, `有順序~map$ %局所~接頭辞~map, 真偽値 %~ns定義~属性を無視するか ) に対し: ◎ The XML serialization of the attributes of an Element element given a namespace prefix map map, a mutable reference to an integer prefix index, an ordered map local prefixes map, a boolean ignore namespace definition attribute, and a boolean require well-formed, is the result of the following algorithm:
- %結果 ~LET 空~文字列 ◎ Let result be the empty string.
-
%局所~名~集合 ~LET 新たな`有順序~集合$ ◎ Let localname set be « » (an empty ordered set).
注記: この集合は、 %要素 の各`属性$が処理されるに伴い, 当の属性の ( `~ns$A, `局所~名$A ) が成す一意な~tupleたちで拡充されることになる。 ◎ Note localname set will contain tuples of unique attribute (namespace, local name) pairs, and is populated as each attr is processed.\
注記: この集合は、 `整形式が要求されるか$V ~EQ ~F の下では,不必要になる。 ~T の場合、[ `要素$の`属性~list$を成す 2 個の`属性$は、 同じ ( `~ns$A, `局所~名$A ) を有し得ない ]とする整形式~拘束を施行するために利用される。 これが生じ得るのは、 当の要素が[ 接頭辞のみ相違する 2 個の属性を有するとき ]である。 ◎ If require well-formed is true, it is used to enforce the well-formed constraint that an element cannot have two attributes with the same namespace and local name. This can occur when two otherwise identical attributes on the same element differ only by their prefix values. If require well-formed is false, localname set is unnecessary.
-
%要素 の`属性~list$を成す ~EACH( `属性$ %属性 ) に対し: ◎ For each attr of element's attribute list:
- %局所~名 ~LET %属性 の`局所~名$A ◎ ↓
- %属性~値 ~LET %属性 の`値$A ◎ ↓
- %属性~ns ~LET %属性 の`~ns$A ◎ Let attribute namespace be attr's namespace.
- %属性~名 ~LET 新たな`~tuple$ ( %属性~ns, %局所~名 ) ◎ Let attrName be a new tuple (attribute namespace, attr's local name).
- ~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ %属性~名 ~IN %局所~名~集合 ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and localname set contains attrName, then throw an exception. The serialization of attr would not be well-formed.
- %局所~名~集合 に %属性~名 を`付加する$set ◎ Append attrName to localname set.
- %候補~接頭辞 ~LET ~NULL ◎ Let candidate prefix be null.
-
~IF[ %属性~ns ~NEQ ~NULL ]: ◎ If attribute namespace is not null, then:
- %接頭辞 ~LET %属性 の`~ns接頭辞$A ◎ Let prefix be attr's namespace prefix.
- %候補~接頭辞 ~SET `選好される接頭辞~文字列を検索取得する$( %~map, %属性~ns, %接頭辞 ) ◎ Set candidate prefix to the result of retrieving a preferred prefix string prefix from map given attribute namespace.
-
~IF[ %属性~ns ~EQ `~XMLNS~ns$ ]: ◎ If attribute namespace is the XMLNS namespace, then:
-
~IF[ ~OR↓ ]… ◎ If any of the following are true, then continue:
-
%属性~値 ~EQ `~XML~ns$ ◎ attr's value is the XML namespace;
注記: `~XML~ns$は、 宣言し直せないので,`往復-$時にも生残る (接頭辞 `xml^l を定義するものを除き)。 この問題を避けるため,この~algoは、 `~XML~ns$に属する要素には,常に `xml^l を接頭することに加え、 上の条件に見られるとおり,関係する定義を落とす。 ◎ Note The XML namespace cannot be redeclared and survive round-tripping (unless it defines the prefix "xml"). To avoid this problem, this algorithm always prefixes elements in the XML namespace with "xml" and drops any related definitions as seen in the above condition.
-
~AND↓:
- %接頭辞 ~EQ ~NULL
- %~ns定義~属性を無視するか ~EQ ~T
注記: %要素 の`既定の~ns宣言$【!既定の~ns属性】は,飛ばされる。
◎ prefix is null and ignore namespace definition attribute is true (the Element's default namespace attribute is to be skipped); -
~AND↓: ◎ ↓
- %接頭辞 ~NEQ ~NULL
- %局所~接頭辞~map[ %局所~名 ] ~IN { ε, %属性~値 }
- 次の結果 ~EQ ~T ⇒ `接頭辞が見出されるか否か$( %~map, %局所~名, %属性~値 )
注記: 現在の`~ns接頭辞~宣言$は、 以前に[ %要素 ではなく,その先祖~要素 ]上で【!exactly】定義されたものであった。 ◎ (the current namespace prefix definition was exactly defined previously—on an ancestor element, not element).
…ならば ⇒ ~CONTINUE ◎ ↑
-
-
~IF[ `整形式が要求されるか$V ~EQ ~T ]: ◎ ↓
-
~IF[ %属性~値 ~EQ `~XMLNS~ns$ ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and attr's value is the XMLNS namespace, then throw an exception.\
注記: この属性の直列化は、 妥当でない~XMLを生産する — `~XMLNS~ns$は、 予約-済みであり, ~XML構文解析を介しては要素の~nsとして適用できないので。 ◎ The serialization of this attribute would produce invalid XML because the XMLNS namespace is reserved and cannot be applied as an element's namespace via XML parsing.
注記: ~DOM~APIは、 `~XMLNS~ns$に属する要素の作成を許容するが, 厳密な `qualifications^en を伴う。 ◎ Note DOM APIs do allow creation of elements in the XMLNS namespace but with strict qualifications.
-
~IF[ %属性~値 ~EQ 空~文字列 ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and attr's value is the empty string, then throw an exception.\
注記: `~ns接頭辞~宣言$は、 ~nsを未宣言にする用途には利用できない (代わりに`既定の~ns宣言$を利用すること)。 ◎ Namespace prefix declarations cannot be used to undeclare a namespace (use a default namespace declaration instead).
-
- ~IF[ %接頭辞 ~EQ `xmlns^l ] ⇒ %候補~接頭辞 ~LET `xmlns^l ◎ If prefix is "xmlns", then set candidate prefix to "xmlns".
-
-
~ELIF[ %候補~接頭辞 ~EQ ~NULL ]: ◎ Otherwise (attribute namespace is not the XMLNS namespace), if candidate prefix is null:
- ~IF[ %接頭辞 ~NEQ ~NULL ]~AND[ %局所~接頭辞~map[ %接頭辞 ] ~EQ ε ] ⇒ %候補~接頭辞 ~SET %接頭辞 ◎ If prefix is not null and local prefixes map does not contain prefix, set candidate prefix to prefix.
- ~ELSE ⇒ %候補~接頭辞 ~SET `接頭辞を生成する$( %~map, %属性~ns ) ◎ Otherwise, set candidate prefix to the result of generating a prefix given map, attribute namespace, and prefix index.
- `接頭辞~mapに追加する$( %~map, %候補~接頭辞, %属性~ns ) ◎ Add candidate prefix to map given attribute namespace.
- %局所~接頭辞~map[ %候補~接頭辞 ] ~SET %属性~ns に応じて ⇒# ~NULL ならば空~文字列/ ~ELSE_ %属性~ns ◎ Let map value be the empty string if attribute namespace is null, and attribute namespace otherwise. ◎ Set local prefixes map[candidate prefix] to map value.
-
%結果 に次を順に付加する:
- ~SPACE
- `xmlns:^l
- %候補~接頭辞
- `003D^U
- `0022^U
- `属性~値を直列化する$( %属性~ns )
- `0022^U
- %結果 に ~SPACE を付加する ◎ Append " " (U+0020 SPACE) to result.
-
~IF[ %候補~接頭辞 ~NEQ ~NULL ] ⇒ %結果 に次を順に付加する:
- %候補~接頭辞
- `003A^U
-
~IF[ ~AND↓ ]…
- `整形式が要求されるか$V ~EQ ~T
-
%局所~名 は ~OR↓ を満たす:
- `003A^U が在る
- ~XML `Name$P 生成規則に合致しない文字が在る
- %局所~名 ~EQ `xmlns^l
- %属性~ns ~EQ ~NULL
…ならば ⇒ ~THROW `整形式~性~error$
◎ If require well-formed is true, and attr's local name contains the character ":" (U+003A COLON) or does not match the XML Name production or equals "xmlns" and attribute namespace is null, then throw an exception. The serialization of attr would not be well-formed. -
%結果 に次を順に付加する:
- %局所~名
- `003D^U
- `0022^U
- `属性~値を直列化する$( %属性~値 )
- `0022^U
- ~RET %結果 ◎ Return result.
`属性~値を直列化する@ ~algoは、 所与の ( [ ~NULL /文字列 ] %属性~値 ) に対し: ◎ When serializing an attribute value given a string or null attribute value and a boolean require well-formed, run the following steps:
- ~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ %属性~値 には~XML `Char$P 生成規則に合致しない文字が在る ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and attribute value contains characters that are not matched by the XML Char production, then throw an exception. The serialization of attribute value would not be well-formed.
- %結果 ~LET 空~文字列 ◎ ↓
- ~IF[ %属性~値 ~EQ ~NULL ] ⇒ ~RET %結果 ◎ If attribute value is null, then return the empty string.
-
%属性~値 を成す ~EACH( %文字 ) に対し ⇒ %結果 に[ %文字 に応じて,次に与える文字列 ]を付加する ⇒# `0026^U ならば `&^l / `0022^U ならば `"^l / `003C^U ならば `<^l / `0009^U `CHARACTER TABULATION^cn ならば `	^l / `000A^U `LINE FEED^cn ならば `
^l / `000D^U `CARRIAGE RETURN^cn ならば `
^l / ~ELSE_ %文字 ◎ Otherwise, return attribute value, first replacing any occurrences of the following: • "&" with "&" • """ with """ • "<" with "<" • U+0009 CHARACTER TABULATION with "	" • U+000A LINE FEED (LF) with "
" • U+000D CARRIAGE RETURN (CR) with "
"
注記: これは、 各種~browserの挙動に合致する。 加えて、 文字 `003E^U も置換することにより, ~XML仕様の `AttValue$P 生成規則による文法を超える要件を課す。 【と記されているが、 `003E^U を置換しないよう更新された。】 ◎ Note This matches behavior present in browsers, and goes above and beyond the grammar requirement in the XML specification's AttValue production by also replacing ">" characters.
- ~RET %結果 ◎ ↑
6.1.4. ~ns接頭辞の生成-法
`接頭辞を生成する@ ~algoは、 所与の ( `~ns接頭辞~map$ %~map, 文字列 %新たな~ns ) に対し: ◎ To generate a prefix given a namespace prefix map map, a string new namespace, and a mutable reference to an integer prefix index:
-
%生成された接頭辞 ~LET 次を順に連結した結果:
- `ns^l
-
`接頭辞~index$V を直列化した結果
【 正確にどう直列化するかは述べられていない — 常識的には、 最短な十進表現になるであろうが。 】
- `接頭辞~index$V ~INCBY 1 ◎ Increment the value of prefix index by one.
- `接頭辞~mapに追加する$( %~map, %生成された接頭辞, %新たな~ns ) ◎ Add generated prefix to map given new namespace.
- ~RET %生成された接頭辞 ◎ Return the value of generated prefix.
この~algoが生成する接頭辞は、 既存の接頭辞と競合するアリ性がある。 [`課題 #44@https://github.com/w3c/DOM-Parsing/issues/44$] ◎ Issue 44: It's possible for 'generate a prefix' algorithm to generate a prefix conflicting with an existing one xml-serialization ◎ https://w3c.github.io/DOM-Parsing/#generating-namespace-prefixes
この~algoは、 生成された接頭辞たちの存在を検査することなく `ns1^l, `ns2^l, 等々を生成するだけである。 なので,次の例は、 現在の仕様に従うならば, `child^e 要素に 2 個の `xmlns:ns1^c を直列化する。 すでに, `~test事例@https://wpt.live/domparsing/XMLSerializer-serializeToString.html$ ( `Check if "ns1" is generated even if the element already has xmlns:ns1.^en ) もある。 ◎ The algorithm just generates 'ns1', 'ns2', ... without checking existence of generated prefixes. So, the following example serializes two xmlns:ns1 on child element if we follow the current specification. WPT domparsing/XMLSerializer-serializeToString.html already has a test case ("Check if "ns1" is generated even if the element already has xmlns:ns1.").
const %root = (new DOMParser()).parseFromString('<root xmlns:ns2="uri2"><child xmlns:ns1="uri1" xmlns:a0="uri1" xmlns:NS1="uri1"/></root>', 'text/xml').documentElement;
%root.firstChild.setAttributeNS('uri3', 'attr1', 'value1');
console.log((new XMLSerializer()).serializeToString(%root));
この~algoは、 生成される接頭辞が`見出され@#dfn-found$なくなるまで,~loopするべきである。 ◎ The algorithm should have a loop until a generated prefix is not found.
6.2. `Document^srz
`Document@srz ~algoは、 所与の ( `Document$I ~node %~node, 文字列 %継承された~ns【!namespace】, `~ns接頭辞~map$ %接頭辞~map ) に対し: ◎ The algorithm for XML serializing a Document node, given a Document node, a string namespace, a namespace prefix map prefix map, a mutable reference to an integer prefix index, and a boolean require well-formed, must run the following steps:
- ~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ %~node の`文書~要素$ ~EQ ~NULL ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and node's document element is null, then throw an exception.\ The serialization of node would not be well-formed. ◎ Otherwise:
- %直列化された文書 ~LET 空~文字列 ◎ • Let serialized document be the empty string.
-
%~node の`子~群$を成す ~EACH( %子 ) に対し ⇒ %直列化された文書 に次の結果を付加する ⇒ `~nodeを~XMLに直列化する$( %子, %継承された~ns, %接頭辞~map【!map】 ) ◎ • For each child of node's children: •• Append to serialized document the result of running the XML serialization algorithm given child, inherited ns, map, prefix index, and require well-formed.
注記: これは、 次に挙げるものも直列化することになる:
- `文書~要素$の前後にある任意個数の[ `ProcessingInstruction$I / `Comment$I ]~node
- 1 個以下の `DocumentType$I ~node
( `Text$I ~nodeは、 `Document$I の`子$としては許容されない。)
◎ • Note • This will serialize any number of ProcessingInstruction and Comment nodes both before and after the document element, as well as at most one DocumentType node. (Text nodes are not allowed as children of a Document.) - ~RET %直列化された文書 ◎ • Return serialized document.
6.3. `Comment^srz
`Comment@srz ~algoは、 所与の ( `Comment$I ~node %~node ) に対し: ◎ The algorithm for XML serializing a Comment node, given a Comment node, and a boolean require well-formed, must run the following steps:
- %~data ~LET %~node の`~data$ ◎ ↓
-
~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ %~data は ~OR↓ を満たす ]…
- ~XML `Char$P 生成規則に合致しない文字が在る
- 2 個の `002D^U が成す並びが在る
- `002D^U で終端している
…ならば ⇒ ~THROW `整形式~性~error$
◎ If require well-formed is true, and node's data contains characters that are not matched by the XML Char production or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception.\ The serialization of node would not be well-formed. -
~RET 次を順に連結した結果:
- `<!--^l
- %~data
- `-->^l
6.4. `CDATASection^srz
`CDATASection@srz ~algoは、 所与の ( `CDATASection$I ~node %~node ) に対し: ◎ The algorithm for XML serializing a CDATASection node, given a CDATASection node, and a boolean require well-formed, must run the following steps:
-
~RET 次を順に連結した結果:
- `<![CDATA[^l
- %~node の`~data$
- `]]>^l
6.5. `Text^srz
`Text@srz ~algoは、 所与の ( `Text$I ~node %~node ) に対し: ◎ The algorithm for XML serializing a Text node, given a Text node, and a boolean require well-formed, must run the following steps:
- %~data ~LET %~node の`~data$ ◎ Let markup be node's data.
- ~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ %~data 内に~XML `Char$P 生成規則に合致しない文字が在る ] ⇒ ~THROW `整形式~性~error$ ◎ If require well-formed is true, and markup contains characters that are not matched by the XML Char production, then throw an exception.\ The serialization of node would not be well-formed.
- %~markup ~LET 空~文字列 ◎ ↑↓
- %~data を成す ~EACH( %文字 ) に対し,順に ⇒ %~markup に[ %文字 に応じて,次に与える文字列 ]を付加する ⇒# `0026^U ならば `&^l / `003C^U ならば `<^l / `003E^U ならば `>^l / ~ELSE_ %文字 ◎ Replace any occurrences of "&" in markup by "&". ◎ Replace any occurrences of "<" in markup by "<". ◎ Replace any occurrences of ">" in markup by ">".
- ~RET %~markup ◎ Return markup.
6.6. `DocumentFragment^srz
`DocumentFragment@srz ~algoは、 所与の ( `DocumentFragment$I ~node %~node, 文字列 %継承された~ns【!namespace】, `~ns接頭辞~map$ %接頭辞~map ) に対し: ◎ The algorithm for XML serializing a DocumentFragment node, given a DocumentFragment node, a string namespace, a namespace prefix map prefix map, a mutable reference to an integer prefix index, and a boolean require well-formed, must run the following steps:
- %~markup ~LET 空~文字列 ◎ Let markup be the empty string.
- %~node の`子~群$を成す ~EACH( %子 ) に対し ⇒ %~markup に次の結果を付加する ⇒ `~nodeを~XMLに直列化する$( %子, %継承された~ns, %接頭辞~map【!map】 ) ◎ For each child of node's children: • Append to markup the result of running the XML serialization algorithm given child, inherited ns, map, prefix index, and require well-formed.
- ~RET %~markup ◎ Return markup.
6.7. `DocumentType^srz
`DocumentType@srz ~algoは、 所与の ( `DocumentType$I ~node %~node ) に対し: ◎ The algorithm for XML serializing a DocumentType node, given a DocumentType node, and a boolean require well-formed, must run the following steps:
- %公な~ID ~LET %~node の`公な~ID$dT ◎ ↓
- %~system~ID ~LET %~node の`~system~ID$dT ◎ ↓
-
~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ ~OR↓ ]…
- %公な~ID 内に[ ~XML `PubidChar$P 生成規則に合致しない文字 ]が在る
- %~system~ID 内に[ ~XML `Char$P 生成規則に合致しない文字 ]が在る
- %~system~ID 内に[ `0022^U, `0027^U ]どちらも在る
…ならば ⇒ ~THROW `整形式~性~error$
◎ If require well-formed is true, and node's public ID contains characters that are not matched by the XML PubidChar production, then throw an exception.\ The serialization of node would not be well-formed. ◎ If require well-formed is true, and node's system ID contains characters that are not matched by the XML Char production or that contains both a """ (U+0022 QUOTATION MARK) and a "'" (U+0027 APOSTROPHE), then throw an exception.\ The serialization of node would not be well-formed. -
%~markup ~LET 次を順に連結した結果:
- `003C^U
- `0021^U
- `DOCTYPE^l
- ~SPACE
- %~node の`名前$dT【!原文誤 #dfn-name 】 — %~node が`~HTML文書$に属する場合、 この値は小文字のみからなる。
-
~IF[ %公な~ID ~NEQ 空~文字列 ] ⇒ %~markup に次を順に付加する:
- ~SPACE
- `PUBLIC^l
- ~SPACE
- `~IDを直列化する$( %公な~ID )
-
~IF[ %~system~ID ~NEQ 空~文字列 ]~AND[ %公な~ID ~EQ 空~文字列 ] ⇒ %~markup に次を順に付加する:
- ~SPACE
- `SYSTEM^l
-
~IF[ %~system~ID ~NEQ 空~文字列 ] ⇒ %~markup に次を順に付加する:
- ~SPACE
- `~IDを直列化する$( %~system~ID )
- %~markup に `003E^U を付加する ◎ Append ">" (U+003E GREATER-THAN SIGN) to markup.
- ~RET %~markup ◎ Return markup.
`~IDを直列化する@ ~algoは、 所与の ( %~ID ) に対し: ◎ The serialization of the ID id is the result of the following steps:
- %引用符 ~LET %~ID 内に `0022^U は[ 在るならば `0027^U / 無いならば `0022^U ] ◎ If id contains """ (U+0022 QUOTATION MARK), let q be "'" (U+0027 APOSTROPHE), and let q be """ (U+0022 QUOTATION MARK) otherwise.
-
~RET 次を順に連結した結果:
- %引用符
- %~ID
- %引用符
6.8. `ProcessingInstruction^srz
`ProcessingInstruction@srz ~algoは、 所与の ( `ProcessingInstruction$I ~node %~node ) に対し: ◎ The algorithm for XML serializing a ProcessingInstruction node, given a ProcessingInstruction node, and a boolean require well-formed, must run the following steps:
- %~target ~LET %~node の`~target$pI ◎ ↓
- %~data ~LET %~node の`~data$ ◎ ↓
-
~IF[ `整形式が要求されるか$V ~EQ ~T ]~AND[ ~OR↓ ]…
- %~target 内に `003A^U が在る
- %~target は`~ASCII大小無視$で `xml^l に合致する
- %~data 内に~XML `Char$P 生成規則に合致しない文字が在る
- %~data 内に `?>^l ( `003F^U `003E^U )が在る
…ならば ⇒ ~THROW `整形式~性~error$
◎ If require well-formed is true, and node's target contains a ":" (U+003A COLON) character or is an ASCII case-insensitive match for "xml", then throw an exception.\ The serialization of node would not be well-formed. ◎ If require well-formed is true, and node's data contains characters that are not matched by the XML Char production or contains "?>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN), then throw an exception.\ The serialization of node would not be well-formed. -
~RET 次を順に連結した結果:
- `003C^U
- `003F^U
- %~target
- ~SPACE
- %~data
- `003F^U
- `003E^U
依存関係
【 この節を成す内容の和訳は省略する。 】
改訂~履歴
この仕様の最後の公表からの変更点(規範的でない)を以下に要約する。 この仕様の編集者草案の完全な改訂~履歴は `W3C Github Repository@https://github.com/w3c/DOM-Parsing/commits/gh-pages$cite にて見出せる。 より旧い改訂は、 `W3C Mercurial server@https://dvcs.w3.org/hg/innerhtml/summary/$cite にある。 ◎ The following is an informative summary of the changes since the last publication of this specification. A complete revision history of the Editor's Drafts of this specification can be found at the W3C Github Repository and older revisions at the W3C Mercurial server.
- 2016 年 6 月の作業草案にて、 文書を編成し直した: 単体的な~XML直列化~algoは、 数節に~~分解した。 依存関係を明確化した。 ~XML直列化~algoは、 相互運用可能な~browserの挙動に近くなるよう更新された。 ◎ 2016-06 WD - Editorial restructuring of the document; monolithic XML serialization algorithm factored into sections. Dependencies clarified. XML Serialization algorithm updated to get closer to interoperable browser behavior.
- `前回の Last Call 文書からの規範的でない変更点@https://dvcs.w3.org/hg/innerhtml/raw-file/tip/LC2_comments.html$ を組入れた。 ◎ Incorporated non-normative changes from previous Last Call document.
謝辞
この仕様が基づいている元の `DOM Parsing and Serialization Living Standard^cite を作成して保守された[ Ms2ger 氏と WHATWG の他の方々による元の作業 ]に感謝する: ◎ We acknowledge with gratitude the original work of Ms2ger and others at the WHATWG, who created and maintained the original DOM Parsing and Serialization Living Standard upon which this specification is based.
以下に挙げる方々に: ◎ Thanks to\
C. Scott Ananian, Victor Costan, Aryeh Gregor, Anne van Kesteren, Arkadiusz Michalski, Simon Pieters, Henri Sivonen, Josh Soref and Boris Zbarsky, for their useful comments.
`HTML$r にて[ `innerHTML$m 属性, `outerHTML@~HTMLdynamic#dom-element-outerhtml$m 属性, `insertAdjacentHTML()@~HTMLdynamic#dom-element-insertadjacenthtml$m ~method ]を最初に定義され,有用な~commentを書かれた `Ian Hickson^en 氏に特別な謝意を。 ◎ Special thanks to Ian Hickson for first defining the innerHTML and outerHTML attributes, and the insertAdjacentHTML method in [HTML] and his useful comments.