-
Notifications
You must be signed in to change notification settings - Fork 0
/
xhtml.html
313 lines (278 loc) · 27.7 KB
/
xhtml.html
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!DOCTYPE html>
<html lang="en"><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>HTML 5.1: The XHTML syntax</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="WD" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="styles/styles-html.css" rel="stylesheet" type="text/css">
<link href="https://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css">
<meta content="Bikeshed 1.0.0" name="generator">
<style>.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #708090 } /* Comment */
.highlight .k { color: #990055 } /* Keyword */
.highlight .l { color: #000000 } /* Literal */
.highlight .n { color: #0077aa } /* Name */
.highlight .o { color: #999999 } /* Operator */
.highlight .p { color: #999999 } /* Punctuation */
.highlight .cm { color: #708090 } /* Comment.Multiline */
.highlight .cp { color: #708090 } /* Comment.Preproc */
.highlight .c1 { color: #708090 } /* Comment.Single */
.highlight .cs { color: #708090 } /* Comment.Special */
.highlight .kc { color: #990055 } /* Keyword.Constant */
.highlight .kd { color: #990055 } /* Keyword.Declaration */
.highlight .kn { color: #990055 } /* Keyword.Namespace */
.highlight .kp { color: #990055 } /* Keyword.Pseudo */
.highlight .kr { color: #990055 } /* Keyword.Reserved */
.highlight .kt { color: #990055 } /* Keyword.Type */
.highlight .ld { color: #000000 } /* Literal.Date */
.highlight .m { color: #000000 } /* Literal.Number */
.highlight .s { color: #a67f59 } /* Literal.String */
.highlight .na { color: #0077aa } /* Name.Attribute */
.highlight .nc { color: #0077aa } /* Name.Class */
.highlight .no { color: #0077aa } /* Name.Constant */
.highlight .nd { color: #0077aa } /* Name.Decorator */
.highlight .ni { color: #0077aa } /* Name.Entity */
.highlight .ne { color: #0077aa } /* Name.Exception */
.highlight .nf { color: #0077aa } /* Name.Function */
.highlight .nl { color: #0077aa } /* Name.Label */
.highlight .nn { color: #0077aa } /* Name.Namespace */
.highlight .py { color: #0077aa } /* Name.Property */
.highlight .nt { color: #669900 } /* Name.Tag */
.highlight .nv { color: #0077aa } /* Name.Variable */
.highlight .ow { color: #999999 } /* Operator.Word */
.highlight .mb { color: #000000 } /* Literal.Number.Bin */
.highlight .mf { color: #000000 } /* Literal.Number.Float */
.highlight .mh { color: #000000 } /* Literal.Number.Hex */
.highlight .mi { color: #000000 } /* Literal.Number.Integer */
.highlight .mo { color: #000000 } /* Literal.Number.Oct */
.highlight .sb { color: #a67f59 } /* Literal.String.Backtick */
.highlight .sc { color: #a67f59 } /* Literal.String.Char */
.highlight .sd { color: #a67f59 } /* Literal.String.Doc */
.highlight .s2 { color: #a67f59 } /* Literal.String.Double */
.highlight .se { color: #a67f59 } /* Literal.String.Escape */
.highlight .sh { color: #a67f59 } /* Literal.String.Heredoc */
.highlight .si { color: #a67f59 } /* Literal.String.Interpol */
.highlight .sx { color: #a67f59 } /* Literal.String.Other */
.highlight .sr { color: #a67f59 } /* Literal.String.Regex */
.highlight .s1 { color: #a67f59 } /* Literal.String.Single */
.highlight .ss { color: #a67f59 } /* Literal.String.Symbol */
.highlight .vc { color: #0077aa } /* Name.Variable.Class */
.highlight .vg { color: #0077aa } /* Name.Variable.Global */
.highlight .vi { color: #0077aa } /* Name.Variable.Instance */
.highlight .il { color: #000000 } /* Literal.Number.Integer.Long */
.highlight { background: hsl(24, 20%, 95%); }
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
</style>
</head>
<body class="h-entry">
<div class="head">
<header>
<p data-fill-with="logo"><a href="http://www.w3.org/"><img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72"></a></p>
<h1 class="p-name no-ref allcaps" id="title">HTML 5.1</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Working Draft, <time class="dt-updated" datetime="2016-01-20">20 January 2016</time></span></h2>
</header>
</div>
<nav class="prev_next"> — ← <a href="syntax.html#syntax"><span class="secno">8</span> <span class="content">The HTML syntax</span></a> — <a href="index.html#contents">Table of contents</a> →<a href="rendering.html#rendering"><span class="secno">10</span> <span class="content">Rendering</span></a></nav><nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li>
<a href="xhtml.html#xhtml"><span class="secno">9</span> <span class="content">The XHTML syntax</span></a>
<ol class="toc">
<li><a href="xhtml.html#writing-xhtml-documents"><span class="secno">9.1</span> <span class="content">Writing XHTML documents</span></a>
</li><li><a href="xhtml.html#parsing-xhtml-documents"><span class="secno">9.2</span> <span class="content">Parsing XHTML documents</span></a>
</li><li><a href="xhtml.html#serializing-xhtml-fragments"><span class="secno">9.3</span> <span class="content">Serializing XHTML fragments</span></a>
</li><li><a href="xhtml.html#parsing-xhtml-fragments"><span class="secno">9.4</span> <span class="content">Parsing XHTML fragments</span></a>
</li></ol>
</li></ol>
</nav>
<main>
<section>
<h2 class="heading settled" data-level="9" id="xhtml"><span class="secno">9. </span><span class="content">The XHTML syntax</span><a class="self-link" href="xhtml.html#xhtml"></a></h2>
<p class="note" role="note"> This section only describes the rules for XML resources. Rules for <a href="iana.html#text-html"><code>text/html</code></a> resources are discussed in the section above entitled "<a href="syntax.html#syntax">The HTML syntax</a>". </p>
<div class="impl">
<h3 class="heading settled" data-level="9.1" id="writing-xhtml-documents"><span class="secno">9.1. </span><span class="content">Writing XHTML documents</span><a class="self-link" href="xhtml.html#writing-xhtml-documents"></a></h3>
</div>
<p>The syntax for using HTML with XML, whether in XHTML documents or embedded in other XML
documents, is defined in the XML and Namespaces in XML specifications. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a></p>
<p>This specification does not define any syntax-level requirements beyond those defined for XML
proper.</p>
<p>XML documents may contain a <code>DOCTYPE</code> if desired, but this is not required
to conform to this specification. This specification does not define a public or system
identifier, nor provide a formal DTD.</p>
<p class="note" role="note"> According to the XML specification, XML processors are not guaranteed to process
the external DTD subset referenced in the DOCTYPE. This means, for example, that using <a data-link-type="dfn" href="http://www.w3.org/TR/xml/#dt-entref">entity references</a> for characters in XHTML documents
is unsafe if they are defined in an external file (except for <code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>, <code>&quot;</code> and <code>&apos;</code>). </p>
<div class="impl">
<h3 class="heading settled" data-level="9.2" id="parsing-xhtml-documents"><span class="secno">9.2. </span><span class="content">Parsing XHTML documents</span><a class="self-link" href="xhtml.html#parsing-xhtml-documents"></a></h3>
<p>This section describes the relationship between XML and the DOM, with a particular emphasis on
how this interacts with HTML.</p>
<p>An <dfn data-dfn-type="dfn" data-noexport="" id="xml-parser">XML parser<a class="self-link" href="xhtml.html#xml-parser"></a></dfn>, for the purposes of this specification, is a construct that follows
the rules given in the XML specification to map a string of bytes or characters into a <code>Document</code> object.</p>
<p class="note" role="note"> At the time of writing, no such rules actually exist. </p>
<p>An <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> is either associated with a <code>Document</code> object when it is
created, or creates one implicitly.</p>
<p>This <code>Document</code> must then be populated with DOM nodes that represent the tree
structure of the input passed to the parser, as defined by the XML specification, the Namespaces
in XML specification, and the DOM specification. DOM mutation events must not fire for the
operations that the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> performs on the <code>Document</code>’s tree, but the
user agent must act as if elements and attributes were individually appended and set respectively
so as to trigger rules in this specification regarding what happens when an element is inserted
into a document or has its attributes set, and the DOM specification’s requirements regarding
mutation observers mean that mutation observers <em>are</em> fired (unlike mutation events). <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a> <a data-link-type="biblio" href="references.html#biblio-dom">[DOM]</a> <a data-link-type="biblio" href="references.html#biblio-uievents">[UIEVENTS]</a></p>
<p>Between the time an element’s start tag is parsed and the time either the element’s end tag is
parsed or the parser detects a well-formedness error, the user agent must act as if the element
was in a <a data-link-type="dfn" href="syntax.html#stack-of-open-elements">stack of open elements</a>.</p>
<p class="note" role="note"> This is used, e.g. by the <code><a data-link-type="element" href="semantics.html#elementdef-object">object</a></code> element to avoid instantiating plugins
before the <code><a data-link-type="element" href="semantics.html#elementdef-param">param</a></code> element children have been parsed. </p>
<p>This specification provides the following additional information that user agents should use
when retrieving an external entity: the public identifiers given in the following list all
correspond to <a data-link-type="dfn" href="./entities.dtd#the-url-given-by-this-link">the URL given by this link</a>. (This
URL is a DTD containing the <a data-link-type="dfn" href="http://www.w3.org/TR/xml/#sec-entity-decl">entity declarations</a> for the names listed in the <a href="syntax.html#named-character-references">§8.5 Named character references</a> section.) <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a></p>
<ul class="brief">
<li><code>-//W3C//DTD ;XHTML ;1.0 ;Transitional//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;1.1//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;1.0 ;Strict//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;1.0 ;Frameset//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;Basic ;1.0//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;1.1 ;plus ;MathML ;2.0//EN</code>
</li><li><code>-//W3C//DTD ;XHTML ;1.1 ;plus ;MathML ;2.0 ;plus ;SVG ;1.1//EN</code>
</li><li><code>-//W3C//DTD ;MathML ;2.0//EN</code>
</li><li><code>-//WAPFORUM//DTD ;XHTML ;Mobile ;1.0//EN</code>
</li></ul>
<p>Furthermore, user agents should attempt to retrieve the above external entity’s content when
one of the above public identifiers is used, and should not attempt to retrieve any other external
entity’s content.</p>
<p class="note" role="note"> This is not strictly a <a data-link-type="dfn" href="introduction.html#willful-violation">violation</a> of the XML
specification, but it does contradict the spirit of the XML specification’s requirements. This is
motivated by a desire for user agents to all handle entities in an interoperable fashion without
requiring any network access for handling external subsets. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> </p>
<p>XML parsers can be invoked with <dfn data-dfn-type="dfn" data-lt="XML scripting support disabled|XML scripting support enabled" data-noexport="" id="xml-scripting-support-disabled">XML scripting support enabled or disabled<a class="self-link" href="xhtml.html#xml-scripting-support-disabled"></a></dfn>. Except where otherwise specified, XML parsers are
invoked with <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled">XML scripting support enabled</a>.</p>
<p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> with <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled">XML scripting support enabled</a> creates a <code><a data-link-type="element" href="semantics.html#elementdef-script">script</a></code> element, it
must be marked as being <a data-link-type="dfn" href="semantics.html#parser-inserted">"parser-inserted"</a> and its <a data-link-type="dfn" href="semantics.html#non-blocking">"non-blocking"</a> flag
must be unset. If the parser was originally created for the <a data-link-type="dfn" href="xhtml.html#xml-fragment-parsing-algorithm">XML fragment parsing
algorithm</a>, then the element must be marked as <a data-link-type="dfn" href="semantics.html#already-started">"already started"</a> also. When the
element’s end tag is subsequently parsed, the user agent must <a data-link-type="dfn" href="webappapis.html#performs-a-microtask-checkpoint">perform a microtask checkpoint</a>, and
then prepare the <code><a data-link-type="element" href="semantics.html#elementdef-script">script</a></code> element. If this
causes there to be a <a data-link-type="dfn" href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then the user agent must run
the following steps:</p>
<ol>
<li>Block this instance of the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a>, such that the <a data-link-type="dfn" href="webappapis.html#event-loop">event loop</a> will not run <a data-link-type="dfn" href="webappapis.html#tasks">tasks</a> that invoke it.
</li><li><a data-link-type="dfn" href="webappapis.html#spinning-the-event-loop">Spin the event loop</a> until the parser’s <code>Document</code> <a data-link-type="dfn" href="semantics.html#has-no-style-sheet-that-is-blocking-scripts">has no
style sheet that is blocking scripts</a> and the <a data-link-type="dfn" href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
script</a>’s <a data-link-type="dfn" href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.
</li><li>Unblock this instance of the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a>, such that <a data-link-type="dfn" href="webappapis.html#tasks">tasks</a> that invoke it can again be run.
</li><li><a data-link-type="dfn" href="semantics.html#execute-a-script-block">Execute</a> the <a data-link-type="dfn" href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
script</a>.
</li><li>There is no longer a <a data-link-type="dfn" href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>.
</li></ol>
<p class="note" role="note"> Since the <a class="idl-code" data-link-type="method" href="webappapis.html#dom-document-write"><code>document.write()</code></a> API is not
available for <a data-link-type="dfn" href="infrastructure.html#xml-document">XML documents</a>, much of the complexity in the <a data-link-type="dfn" href="syntax.html#html-parser">HTML parser</a> is not needed in the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a>. </p>
<p class="note" role="note"> When the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> has <a data-link-type="dfn" href="xhtml.html#xml-scripting-support-disabled">XML scripting support disabled</a>,
none of this happens. </p>
<p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> would append a node to a <code><a data-link-type="element" href="semantics.html#elementdef-template">template</a></code> element, it must instead append it to the <code><a data-link-type="element" href="semantics.html#elementdef-template">template</a></code> element’s <a data-link-type="dfn" href="semantics.html#template-contents">template contents</a> (a <code>DocumentFragment</code> node).</p>
<p class="note" role="note"> This is a <a data-link-type="dfn" href="introduction.html#willful-violation">willful violation</a> of the XML specification; unfortunately,
XML is not formally extensible in the manner that is needed for <code>template</code> processing. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> </p>
<p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> creates a <code>Node</code> object, its <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-node-document">node document</a> must be set to the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-node-document">node document</a> of
the node into which the newly created node is to be inserted.</p>
<p>Certain algorithms in this specification <dfn data-dfn-type="dfn" data-lt="feed the parser|spoon-feed the parser" data-noexport="" id="feed-the-parser">spoon-feed the
parser<a class="self-link" href="xhtml.html#feed-the-parser"></a></dfn> characters one string at a time. In such cases, the <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> must act
as it would have if faced with a single string consisting of the concatenation of all those
characters.</p>
<p>When an <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a> reaches the end of its input, it must <a data-link-type="dfn" href="syntax.html#stopped">stop
parsing</a>, following the same rules as the <a data-link-type="dfn" href="syntax.html#html-parser">HTML parser</a>. An <a data-link-type="dfn" href="xhtml.html#xml-parser">XML
parser</a> can also be <a data-link-type="dfn" href="browsers.html#abort-the-document">aborted</a>, which must again be done in
the same way as for an <a data-link-type="dfn" href="syntax.html#html-parser">HTML parser</a>.</p>
<p>For the purposes of conformance checkers, if a resource is determined to be in <a href="xhtml.html#xhtml">the XHTML syntax</a>, then it is an <a data-link-type="dfn" href="infrastructure.html#xml-document">XML document</a>.</p>
<h3 class="heading settled" data-level="9.3" id="serializing-xhtml-fragments"><span class="secno">9.3. </span><span class="content">Serializing XHTML fragments</span><a class="self-link" href="xhtml.html#serializing-xhtml-fragments"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="xml-fragment-serialization-algorithm">XML fragment serialization algorithm<a class="self-link" href="xhtml.html#xml-fragment-serialization-algorithm"></a></dfn> for a <code>Document</code> or <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#element">Element</a></code> node either returns a fragment of XML that represents that node or throws an
exception.</p>
<p>For <code>Document</code>s, the algorithm must return a string in the form of a <a data-link-type="dfn" href="http://www.w3.org/TR/xml/#sec-well-formed">document entity</a>, if none of the error cases
below apply.</p>
<p>For <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#element">Element</a></code>s, the algorithm must return a string in the form of an <a data-link-type="dfn" href="http://www.w3.org/TR/xml/#wf-entities">internal general parsed entity</a>, if none of the
error cases below apply.</p>
<p>In both cases, the string returned must be XML namespace-well-formed and must be an isomorphic
serialization of all of that node’s <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes">relevant child nodes</a>, in <a data-link-type="dfn" href="infrastructure.html#tree-order">tree order</a>.
User agents may adjust prefixes and namespace declarations in the serialization (and indeed might
be forced to do so in some cases to obtain namespace-well-formed XML). User agents may use a
combination of regular text and character references to represent <code>Text</code> nodes in the
DOM.</p>
<p>A node’s <dfn data-dfn-type="dfn" data-noexport="" id="relevant-child-nodes">relevant child nodes<a class="self-link" href="xhtml.html#relevant-child-nodes"></a></dfn> are those that apply given the following rules:</p>
<dl>
<dt>For <code><a data-link-type="element" href="semantics.html#elementdef-template">template</a></code> elements
</dt><dd>The <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes">relevant child nodes</a> are the child nodes of the <code>template</code> element’s <a data-link-type="dfn" href="semantics.html#template-contents">template contents</a>, if any.
</dd><dt>For all other nodes
</dt><dd>The <a data-link-type="dfn" href="xhtml.html#relevant-child-nodes">relevant child nodes</a> are the child nodes of node itself, if any.
</dd></dl>
<p>For <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#element">Element</a></code>s, if any of the elements in the serialization are in no namespace, the
default namespace in scope for those elements must be explicitly declared as the empty string. (This doesn’t apply in the <code>Document</code> case.) <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a></p>
<p>For the purposes of this section, an internal general parsed entity is considered XML
namespace-well-formed if a document consisting of an element with no namespace declarations whose
contents are the internal general parsed entity would itself be XML namespace-well-formed.</p>
<p>If any of the following error cases are found in the DOM subtree being serialized, then the
algorithm must throw an <code>InvalidStateError</code> exception instead of returning a
string:</p>
<ul>
<li>A <code>Document</code> node with no child element nodes.
</li><li>A <code>DocumentType</code> node that has an external subset public identifier that contains
characters that are not matched by the XML <code>PubidChar</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
</li><li>A <code>DocumentType</code> node that has an external subset system identifier that contains
both a U+0022 QUOTATION MARK (") and a U+0027 APOSTROPHE (') or that contains characters that are
not matched by the XML <code>Char</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
</li><li>A node with a local name containing a U+003A COLON (:).
</li><li>A node with a local name that does not match the XML <a data-link-type="dfn" href="http://www.w3.org/TR/xml/#NT-Name"><code>Name</code></a> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
</li><li>An <code>Attr</code> node with no namespace whose local name is the lowercase string "<code>xmlns</code>". <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a>
</li><li>An <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#element">Element</a></code> node with two or more attributes with the same local name and
namespace.
</li><li>An <code>Attr</code> node, <code>Text</code> node, <code>Comment</code> node, or <code>ProcessingInstruction</code> node whose data contains characters that are not matched by
the XML <code>Char</code> production. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a>
</li><li>A <code>Comment</code> node whose data contains two adjacent U+002D HYPHEN-MINUS characters
(-) or ends with such a character.
</li><li>A <code>ProcessingInstruction</code> node whose target name is an <a data-link-type="dfn" href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for the string "<code>xml</code>".
</li><li>A <code>ProcessingInstruction</code> node whose target name contains a U+003A COLON (:).
</li><li>A <code>ProcessingInstruction</code> node whose data contains the string "<code>?></code>".
</li></ul>
<p class="note" role="note"> These are the only ways to make a DOM unserialisable. The DOM enforces all the
other XML constraints; for example, trying to append two elements to a <code>Document</code> node
will throw a <code>HierarchyRequestError</code> exception. </p>
<h3 class="heading settled" data-level="9.4" id="parsing-xhtml-fragments"><span class="secno">9.4. </span><span class="content">Parsing XHTML fragments</span><a class="self-link" href="xhtml.html#parsing-xhtml-fragments"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="xml-fragment-parsing-algorithm">XML fragment parsing algorithm<a class="self-link" href="xhtml.html#xml-fragment-parsing-algorithm"></a></dfn> either returns a <code>Document</code> or throws
a <code>SyntaxError</code> exception. Given a string <var>input</var> and a
context element <var>context</var>, the algorithm is as
follows:</p>
<ol>
<li>
<p>Create a new <a data-link-type="dfn" href="xhtml.html#xml-parser">XML parser</a>.</p>
</li><li>
<p><a data-link-type="dfn" href="xhtml.html#feed-the-parser">Feed the
parser</a> just created the string corresponding to the start tag of the <var>context</var> element, declaring
all the namespace prefixes that are in scope on that element in the DOM, as well as declaring
the default namespace (if any) that is in scope on that element in the DOM.</p>
<p>A namespace prefix is in scope if the DOM <code>lookupNamespaceURI()</code> method
on the element would return a non-null value for that prefix.</p>
<p>The default namespace is the namespace for which the DOM <code>isDefaultNamespace()</code> method on the element would return true.</p>
<p class="note" role="note"> No <code>DOCTYPE</code> is passed to the parser, and therefore no external subset is
referenced, and therefore no entities will be recognized. </p>
</li><li>
<p><a data-link-type="dfn" href="xhtml.html#feed-the-parser">Feed the parser</a> just created the string <var>input</var>.</p>
</li><li>
<p><a data-link-type="dfn" href="xhtml.html#feed-the-parser">Feed the parser</a> just created the string corresponding to the end tag of the <var>context</var> element.</p>
</li><li>
<p>If there is an XML well-formedness or XML namespace well-formedness error, then throw a <code>SyntaxError</code> exception and abort these steps.</p>
</li><li>
<p>If the root
element of the resulting <code>Document</code> has any sibling nodes, then throw a <code>SyntaxError</code> exception and abort these steps.</p>
</li><li>
<p>Return the
child nodes of the root element of the resulting <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#document">Document</a></code>, in <a data-link-type="dfn" href="infrastructure.html#tree-order">tree
order</a>.</p>
</li></ol>
</div>
</section>
</main>
<nav class="prev_next"> — ← <a href="syntax.html#syntax"><span class="secno">8</span> <span class="content">The HTML syntax</span></a> — <a href="index.html#contents">Table of contents</a> →<a href="rendering.html#rendering"><span class="secno">10</span> <span class="content">Rendering</span></a></nav></body></html>