-
Notifications
You must be signed in to change notification settings - Fork 4
/
12.txt
140 lines (100 loc) · 7.13 KB
/
12.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
[2] [CODE(DOM)[Text]] 節は、 [CODE(DOM)[Element]]
節や [CODE(DOM)[Attr]] 節の中の文内容
([[XML]] の用語では[[文字データ]]) を取扱います。
[1] [[DOM1]] では、[RUBYB[文節] [[CODE(DOM)[Text]] node]]はどんな種類の子[[節]]も持つことは出来ません。
[4] [CODE(DOMi)[[[CharacterData]]]] を継承して:
,method,[CODE(DOMm)[[[splitText]]]],文節を分割,[DOM1]
[3] 親節の中で、文節が隣接することができますが、
それは XML 的には保存されません。例えば、
[PRE[
<element>
+-- "text1"
+-- "text2"
]PRE]
という文書木 (の断片) は存在し得ますが (そして DOM
を使った処理の結果木としてしばしば作られますが)、
この木を一旦他の形式に直し、再び DOM 木にした時に、
一般には元には戻りません。
[PRE[
XML 文書として保存:
<element>text1text2</element>
再び DOM 木を作成:
<element>
+-- "text1text2"
]PRE]
DOM 木で [[XPointers]] や [[XPath]] を使う時には、
この点に気をつける必要があるかもしれません。
-[DOM1] ''Document Object Model (Core) Level 1'' <http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1312295772>
-[DOM2] ''Document Object Model Core'' <http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1312295772>
- [5] DOM では[[数値文字参照]]に対応する節がありません。文字参照は展開され、文節の一部となります。
[8] [CITE[不要なテキストノードの除去 - 0x集積蔵]] ([TIME[2009-03-31 08:58:52 +09:00]] 版) <http://d.hatena.ne.jp/os0x/20081105/1225861584#c1225901215>
>li要素のouterHTMLプロパティの値を前後に引用符でもつけて表示してみればわかりますが、IEは要素間の空白文字列を要素の子テキストノードに取り込んでしまいます。
* 適合性
[20] [CODE(DOMi)@en[[[Text]]]] [[節点]]の [CODE(DOMa)@en[[[data]]]] の適合性は [[HTML Standard]]
で規定されており、 [[Unicode文字]]のうち[[制御文字]]と[[非文字]]を除いたものとなっています。
[REFS[
- [19] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-11-13 22:45:42 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#text-content>
- [18] [CITE@en[Character set "$html:Unicode-characters - '''['''\u0000''']''' - $unicode:Noncharacter_Code_Point - $html:control-characters"]] ([TIME[2013-11-22 16:20:26 +09:00]] 版) <http://chars.suikawiki.org/set?expr=%24html%3AUnicode-characters+-+%5B%5Cu0000%5D+-+%24unicode%3ANoncharacter_Code_Point+-+%24html%3Acontrol-characters%20|%20$html:space-characters>
]REFS]
[22] [[XML 1.0]] として表現可能な [[Char]] と比較すると次の違いがあります:
- [[U+007F]]、[[C1]]、ほとんどの[[非文字]]は [[Char]] として表現可能ですが、不適合です
- [[U+000C]] は適合していますが、 [[Char]] として表現できません
[REFS[
- [21] [CITE@en[Compare character sets "$html:Unicode-characters - '''['''\u0000''']''' - $unicode:Noncharacter_Code_Point - $html:control-characters | $html:space-characters" and "$xml10-4e:Char"]] ([TIME[2013-11-23 03:30:10 +09:00]] 版) <http://chars.suikawiki.org/set/compare?expr1=%24html%3AUnicode-characters+-+%5B%5Cu0000%5D+-+%24unicode%3ANoncharacter_Code_Point+-+%24html%3Acontrol-characters+%7C+%24html%3Aspace-characters&expr2=%24xml10-4e%3AChar>
]REFS]
* [CODE(DOMi)@en[CDATASection]] 界面
[11] [CODE(DOMi)@en[[[CDATASection]]]] [[DOM]] [[界面]]は [CODE(DOMi)@en[[[Text]]]]
[[界面]]を[[継承]]するものと定義されています。
[12] 「[CODE(DOMi)@en[[[Text]]]] [[節点]]」のような表現は [CODE(DOMc)@en[[[TEXT_NODE]]]] だけなのか、
それとも [CODE(DOMc)@en[[[CDATA_SECTION_NODE]]]] をも含むのか曖昧なので、注意が必要です。
* [CODE(DOMa)@en[nodeType]] [CODE(DOMc)@en[TEXT_NODE]]
[13] [[テキスト節点]]の [CODE(DOMa)@en[[[nodeType]]]] [[属性]]の値は [CODE(DOMi)@en[[[Node]]]]
[[界面]]の[[定数]] [DFN[[CODE(DOMc)@en[[[TEXT_NODE]]]]]]
([CODE(DOM)[[[3]]]]) です。
[25] [CODE(DOMi)@en[Text]] は、[[スロット可能]]です。
[26] [[節点]]の状態、[[スロット可能]]の状態に加え、次の状態を持ちます。
[FIG(list members)[
@@
]FIG]
* 隣接テキスト節点
[6] [[構文解析器]]の出力では、[[テキスト節点]]が隣接することがありません。
[7] [CODE(DOMm)@en[insertAdjacentText]] で隣接[[テキスト節点]]が生じることがあります。
* 関連
[9] [[XML情報集合]]では [CODE(DOMi)@en[[[Text]]]] [[節点]]は[[文字情報項目]]の連続に相当します。
[10] [[XPath 1.0データ・モデル]]では [CODE(DOMi)@en[[[Text]]]] [[節点]]は[[テキスト節点]]に相当します。
ただし [[XPath 1.0]] には [CODE(DOMi)@en[[[Text]]]] と [CODE(DOMi)@en[[[CDATASection]]]]
の区別がありません。
* 歴史
[14] [CITE@en[Web Applications 1.0 r5298 Coalesce text nodes even if they're not parser-inserted.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10221]]
( ([TIME[2010-08-17 05:38:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5297&to=5298>
[15] [CITE@en[Web Applications 1.0 r6968 Hoist requirements on what text can consist of from the text/html syntax to the DOM, so it also applies to XML and script-provided data.]]
( ([TIME[2012-02-07 08:41:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=6967&to=6968>
[16] [CITE[Add constructors for DocumentFragment, Text, and Comment. (DocumentType ... · a2f1e18 · whatwg/dom]]
( ([TIME[2013-02-16 12:38:18 +09:00]] 版))
<https://github.com/whatwg/dom/commit/a2f1e18ff56ecc12643dc54fcf50f0c335beec71>
[17] [CITE@en-US-x-hixie[HTML Standard]]
( ([TIME[2013-11-13 22:45:42 +09:00]] 版))
<http://www.whatwg.org/specs/web-apps/current-work/#text-content>
[23] [CITE@en[XQuery and XPath Data Model 3.0]]
( ([TIME[2014-04-08 07:00:06 +09:00]] 版))
<http://www.w3.org/TR/xpath-datamodel-3/#TextNode>
[24] [CITE@en[Shadow: define slots and slotables · whatwg/dom@a2b04df]]
([TIME[2016-03-24 21:53:01 +09:00]] 版)
<https://github.com/whatwg/dom/commit/a2b04df51b4342d7617c128e80e5aa892889d2e0>
[27] [CITE@en[Specify global object references in more detail]]
([[annevk]]著, [TIME[2016-08-17 19:43:59 +09:00]])
<https://github.com/whatwg/dom/commit/fa8adb6cd107cd845feaeb71c9da208971b670ca>
[28] [CITE@en[CDATASection nodes don't like to be normalized away]]
([[annevk]]著, [TIME[2016-09-01 16:55:38 +09:00]])
<https://github.com/whatwg/dom/commit/e8d5e65fd890ec0ba9299d7b63e911c3187275f9>
[29] [CITE@en[Editorial: use noncharacter and control from Infra]]
([[annevk]]著, [TIME[2017-04-03 19:40:46 +09:00]])
<https://github.com/whatwg/html/commit/70925237a88d9802bfe7224fe9c78b146af615be>
[30] [CITE@en[Align with IDL constructor changes]]
([[autokagami]]著, [TIME[2019-09-24 22:42:56 +09:00]])
<https://github.com/whatwg/dom/commit/57512fac17cf2f1c4c85be4aec178c8086ee5ee4>
[31] [CITE@en[Update to constructor operations · Issue #780 · whatwg/dom]]
([TIME[2020-05-14 14:04:54 +09:00]])
<https://github.com/whatwg/dom/issues/780>