HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2720Make outerHTML and insertAdjacentHTML work on XML too. Reorganise things and define the interaction of XML and the DOM for the purposes of HTML APIs.2009-01-29 05:12
@@ -6173,28 +6173,20 @@ interface <dfn>HTMLDocument</dfn> {
   <span>current document readiness</span> set to the string "loading"
   if the document is associated with an <span>HTML parser</span> or an
   <span>XML parser</span>, or to the string "complete"
   otherwise. Various algorithms during page loading affect this
   value. When the value is set, the user agent must <span>fire a
   simple event</span> called <code
   title="event-readystatechange">readystatechange</code> at the
   <code>Document</code> object.</p> <!-- XXX define
   document.onreadystatechange -->
 
-  <p>When a <code>Document</code> is created by an <span>XML
-  parser</span>, the <span>current document readiness</span> must be
-  changed to "complete" when the parser reaches the end of its input
-  stream.</p> <!-- XXX this should be in its own section, and we
-  should define 'delay the load event' for XML parsing so that we can
-  have the "interactive" state here too. also, XML parser will need to
-  fire the /pending state object/, and the 'load' event, and... -->
-
   <p>The <dfn
   title="dom-document-readyState"><code>readyState</code></dfn> DOM
   attribute must, on getting, return the <span>current document
   readiness</span>.</p>
 
 
 
   <h4><dfn>DOM tree accessors</dfn></h4>
 
   <p><dfn>The <code>html</code> element</dfn> of a document is the
@@ -7846,86 +7838,33 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
     <p>If the new namespace is the <span>HTML namespace</span>, then
     the new qualified name must be <span>converted to lowercase</span>
     before the rename takes place.</p>
 
    </dd>
    
 
   </dl>
 
 
+
   <h3><dfn>Dynamic markup insertion</dfn></h3>
 
-  <p>APIs for dynamically inserting markup into the document interact
-  with the parser, and thus their behavior varies depending on whether
-  they are used with <span>HTML documents</span> (and the <span>HTML
-  parser</span>) or XHTML in <span>XML documents</span> (and the
-  <span>XML parser</span><!-- XXX xref -->). The following table
-  cross-references the various versions of these APIs.</p>
+  <p class="note">APIs for dynamically inserting markup into the
+  document interact with the parser, and thus their behavior, varies
+  depending on whether they are used with <span>HTML documents</span>
+  (and the <span>HTML parser</span>) or XHTML in <span>XML
+  documents</span> (and the <span>XML parser</span>).</p>
 
-  <table>
-   <thead>
-    <tr>
-     <td></td>
-     <th>For documents that are <span>HTML documents</span></th>
-     <th>For documents that are <span>XML documents</span></th>
-    </tr>
-   </thead>
-   <tbody>
-    <tr>
-     <th><code>document.open()</code></th>
-     <td colspan=2><span title="dom-document-open"><code>document.open()</code></span></td>
-    </tr>
-    <tr>
-     <th><dfn title="dom-document-write"><code>document.write()</code></dfn></th>
-     <td><span title="dom-document-write-HTML"><code>document.write()</code> in HTML</span></td>
-     <td><span title="dom-document-write-XML">not supported</span></td>
-    </tr>
-    <tr>
-     <th><dfn title="dom-innerHTML"><code>innerHTML</code></dfn></th>
-     <td><span title="dom-innerHTML-HTML"><code>innerHTML</code> in HTML</span></td>
-     <td><span title="dom-innerHTML-XML"><code>innerHTML</code> in XML</span></td>
-    </tr>
-    <tr>
-     <th><dfn title="dom-outerHTML"><code>outerHTML</code></dfn></th>
-     <td><span title="dom-outerHTML-HTML"><code>outerHTML</code> in HTML</span></td>
-     <td><span title="dom-outerHTML-XML">not supported</span></td>
-    </tr>
-    <tr>
-     <th><dfn title="dom-insertAdjacentHTML"><code>insertAdjacentHTML()</code></dfn></th>
-     <td><span title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML()</code> in HTML</span></td>
-     <td><span title="dom-insertAdjacentHTML-XML">not supported</span></td>
-    </tr>
-   </tbody>
-  </table>
+  <!-- XXX must make sure we spec that innerHTML et al causes mutation
+  events to fire, but document.write() doesn't. (the latter is already
+  req-stated in the parser section, btw) -->
 
-  <p>Regardless of the parsing mode, the <dfn
-  title="dom-document-writeln"><code>document.writeln(...)</code></dfn>
-  method must call the <code
-  title="dom-document-write">document.write()</code> method with the
-  same argument(s), plus an extra argument consisting of a string
-  containing a single line feed character (U+000A).</p>
-
-  <p class="note">The <code title="dom-innerHTML">innerHTML</code>
-  attribute applies to both <code>Element</code> nodes as well as
-  <code>Document</code> nodes. The <code
-  title="dom-outerHTML">outerHTML</code> and <code
-  title="dom-insertAdjacentHTML">insertAdjacentHTML()</code> members,
-  on the other hand, only apply to <code>Element</code> nodes.</p>
-
-  <p class="note">When inserted using the <code
-  title="dom-document-write">document.write()</code> method,
-  <code>script</code> elements execute (typically synchronously), but
-  when inserted using <code
-  title="dom-innerHTML-HTML">innerHTML</code> and <code
-  title="dom-outerHTML-HTML">outerHTML</code> attributes, they do not
-  execute at all.</p>
 
 
   <h4>Controlling the input stream</h4>
 
   <p>The <dfn title="dom-document-open"><code>open()</code></dfn>
   method comes in several variants with different numbers of
   arguments.</p>
 
   <p>When called with two or fewer arguments, the method must act as
   follows:</p>
@@ -8091,30 +8030,45 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
   <code>INVALID_ACCESS_ERR</code> exception.</p>
 
   <p>The <dfn title="dom-document-close"><code>close()</code></dfn>
   method must do nothing if there is no <span>script-created
   parser</span> associated with the document. If there is such a
   parser, then, when the method is called, the user agent must insert
   an <span>explicit "EOF" character</span> at the end of the parser's
   <span>input stream</span>.</p>
 
 
-  <h4>Dynamic markup insertion in HTML</h4>
 
-  <p>In HTML, the <dfn
-  title="dom-document-write-HTML"><code>document.write(...)</code></dfn>
+
+  <h4><code title="dom-document-write">document.write()</code></h4>
+
+  <p>The <dfn
+  title="dom-document-write"><code>document.write(...)</code></dfn>
   method must act as follows:</p>
 
   <ol>
 
    <li>
 
+    <p>If the method was invoked on an <span title="XML documents">XML
+    document</span>, throw an <code>INVALID_ACCESS_ERR</code>
+    exception and abort these steps.</p>
+
+    <!--
+    Where would document.write() insert?
+    Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
+    -->
+
+   </li>
+
+   <li>
+
     <p>If the <span>insertion point</span> is undefined, the <code
     title="dom-document-open">open()</code> method must be called
     (with no arguments) on the <code title="Document">document</code>
     object. If the user <span>refused to allow the document to be
     unloaded</span>, then these steps must be aborted. Otherwise, the
     <span>insertion point</span> will point at just before the end of
     the (empty) <span>input stream</span>.</p>
 
    </li>
 
@@ -8138,177 +8092,165 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
    <li>
 
     <p>Otherwise, the tokeniser must process the characters that were
     inserted, one at a time, processing resulting tokens as they are
     emitted, and stopping when the tokeniser reaches the insertion
     point or when the processing of the tokeniser is aborted by the
     tree construction stage (this can happen if a <code>script</code>
     end tag token is emitted by the tokeniser).
 
     <p class="note">If the <code
-    title="dom-document-write-HTML">document.write()</code> method was
+    title="dom-document-write">document.write()</code> method was
     called from script executing inline (i.e. executing because the
     parser parsed a set of <code>script</code> tags), then this is a
     <a href="#nestedParsing">reentrant invocation of the
     parser</a>.</p>
 
    </li>
 
    <li>
 
     <p>Finally, the method must return.</p>
 
    </li>
 
   </ol>
 
-  <hr>
-
-  <p>On getting, the <dfn
-  title="dom-innerHTML-HTML"><code>innerHTML</code></dfn> DOM
-  attribute must return the result of running the <span>HTML fragment
-  serialization algorithm</span> on the node.</p>
-
-  <p>On setting, <strong>if the node is a document</strong>, the <code
-  title="dom-innerHTML-HTML">innerHTML</code> DOM attribute must run
-  the following algorithm:</p>
 
-  <ol>
+  <h4><code title="dom-document-writeln">document.writeln()</code></h4>
 
-   <li>
+  <p>The <dfn
+  title="dom-document-writeln"><code>document.writeln(...)</code></dfn>
+  method, when invoked, must act as if the <code
+  title="dom-document-write">document.write()</code> method had been
+  invoked with the same argument(s), plus an extra argument consisting
+  of a string containing a single line feed character (U+000A).</p>
 
-    <p>If the document has an <span>active parser</span><!--XXX
-    xref-->, then stop that parser, and throw away any pending content
-    in the input stream. <span class="XXX">what about if it
-    doesn't, because it's either like a text/plain, or Atom, or PDF,
-    or XHTML, or image document, or something?</span></p><!-- XXX see
-    also document.open() -->
 
-   </li>
 
-   <li>
 
-    <p>Remove the children nodes of the <code>Document</code> whose
-    <code title="dom-innerHTML-HTML">innerHTML</code> attribute is
-    being set.</p>
+  <h4><code title="dom-innerHTML">innerHTML</code></h4>
 
-   </li>
+  <p>The <dfn title="dom-innerHTML"><code>innerHTML</code></dfn> DOM
+  attribute represents the markup of the node's contents.</p>
 
-   <li>
+  <p>On getting, if the node's document is an <span title="HTML
+  documents">HTML document</span>, then the attribute must return the
+  result of running the <span>HTML fragment serialization
+  algorithm</span> on the node; otherwise, the node's document is an
+  <span title="XML documents">XML document</span>, and the attribute
+  must return the result of running the <span>XML fragment
+  serialization algorithm</span> on the node instead (this might raise
+  an exception instead of returning a string).</p>
 
-    <p>Create a new <span>HTML parser</span>, in its initial state,
-    and associate it with the <code>Document</code> node.</p>
+  <p>On setting, the following steps must be run:</p>
 
-   </li>
+  <ol>
 
-<!-- redundant, the document is forcibly already so labeled if we get here
    <li>
 
-    <p>Mark the <code>Document</code> object as being an <span
-    title="HTML documents">HTML document</span>.</p>
+    <p>If the node's document is an <span title="HTML documents">HTML
+    document</span>: Invoke the <span>HTML fragment parsing
+    algorithm</span>.</p>
 
-   </li>
--->
-
-   <li>
+    <p>If the node's document is an <span title="XML documents">XML
+    document</span>: Invoke the <span>XML fragment parsing
+    algorithm</span>.</p>
 
-    <p>Place into the <span>input stream</span> for the <span>HTML
-    parser</span> just created the string being assigned into the
-    <code title="dom-innerHTML-HTML">innerHTML</code> attribute.</p>
-
-   </li>
+    <p>In either case, the algorithm must be invoked with the string
+    being assigned into the <code
+    title="dom-innerHTML">innerHTML</code> attribute as the <var
+    title="">input</var>. If the node is an <code>Element</code>
+    node, then, in addition, that element must be passed as the <var
+    title="">context</var> element.</p>
 
-   <li>
+    <p>If this raises an exception, then abort these steps.</p>
 
-    <p>Start the parser and let it run until it has consumed all the
-    characters just inserted into the input stream. (The
-    <code>Document</code> node will have been populated with elements
-    and a <code title="event-load">load</code> event will have fired
-    on its <span>browsing context</span>'s <code>Window</code>
-    object.)</p>
+    <p>Otherwise, let <var title="">new children</var> be the nodes
+    returned.</p>
 
    </li>
 
-  </ol>
-
-  <p>Otherwise, if the node is an element, then setting the <code
-  title="dom-innerHTML-HTML">innerHTML</code> DOM attribute must cause
-  the following algorithm to run instead:</p>
-
-  <ol>
-
    <li>
 
-    <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
-    the element whose <code
-    title="dom-innerHTML-HTML">innerHTML</code> attribute is being set
-    as the <var title="">context</var> element, and the string being
-    assigned into the <code
-    title="dom-innerHTML-HTML">innerHTML</code> attribute as the <var
-    title="">input</var>. Let <var title="">new children</var> be the
-    result of this algorithm.</p>
+    <p>If the attribute is being set on a <code>Document</code> node,
+    and that document has an active <span>HTML parser</span> or
+    <span>XML parser</span>, then stop that parser.</p>
+
+    <p class="XXX">what about if it doesn't, because it's either
+    like a text/plain, or Atom, or PDF, or XHTML, or image document,
+    or something?</p><!-- XXX see also document.open() -->
 
    </li>
 
    <li>
 
-    <p>Remove the children of the element whose <code
-    title="dom-innerHTML-HTML">innerHTML</code> attribute is being
-    set, without firing any mutation events.</p>
+    <p>Remove the child nodes of the node whose <code
+    title="dom-innerHTML">innerHTML</code> attribute is being set.</p>
 
    </li>
 
    <li>
 
-    <p>Let <var title="">target document</var> be the <code
-    title="">ownerDocument</code> of the <code>Element</code> node
-    whose <code title="dom-innerHTML-HTML">innerHTML</code> attribute
-    is being set.</p>
+    <p>If the attribute is being set on a <code>Document</code>
+    node, let <var title="">target document</var> be that
+    <code>Document</code> node. Otherwise, the attribute is being
+    set on an <code>Element</code> node; let <var title="">target
+    document</var> be the <code title="">ownerDocument</code> of
+    that <code>Element</code>.</p>
 
    </li>
 
    <li>
 
     <p>Set the <code title="">ownerDocument</code> of all the nodes in
     <var title="">new children</var> to the <var title="">target
     document</var>.</p>
 
    </li>
 
    <li>
 
     <p>Append all the <var title="">new children</var> nodes to the
-    node whose <code title="dom-innerHTML-HTML">innerHTML</code>
-    attribute is being set, preserving their order, without firing any
-    mutation events.</p>
+    node whose <code title="dom-innerHTML">innerHTML</code> attribute
+    is being set, preserving their order, without firing any mutation
+    events.</p>
 
    </li>
 
   </ol>
 
-  <hr>
 
-  <p>On getting, the <dfn
-  title="dom-outerHTML-HTML"><code>outerHTML</code></dfn> DOM
-  attribute must return the result of running the <span>HTML fragment
-  serialization algorithm</span> on a fictional node whose only child
-  is the node on which the attribute was invoked.</p>
 
-  <p>On setting, the <code title="dom-outerHTML-HTML">outerHTML</code>
-  DOM attribute must cause the following algorithm to run:</p>
+  <h4><code title="dom-outerHTML">outerHTML</code></h4>
+
+  <p>The <dfn title="dom-outerHTML"><code>outerHTML</code></dfn> DOM
+  attribute represents the markup of the element and its contents.</p>
+
+  <p>On getting, if the node's document is an <span title="HTML
+  documents">HTML document</span>, then the attribute must return the
+  result of running the <span>HTML fragment serialization
+  algorithm</span> on a fictional node whose only child is the node on
+  which the attribute was invoked; otherwise, the node's document is
+  an <span title="XML documents">XML document</span>, and the
+  attribute must return the result of running the <span>XML fragment
+  serialization algorithm</span> on that fictional node instead (this
+  might raise an exception instead of returning a string).</p>
+
+  <p>On setting, the following steps must be run:</p>
 
   <ol>
 
    <li>
 
     <p>Let <var title="">target</var> be the element whose <code
-    title="dom-innerHTML-HTML">outerHTML</code> attribute is being
+    title="dom-outerHTML">outerHTML</code> attribute is being
     set.</p>
 
    </li>
 
    <li>
 
     <p>If <var title="">target</var> has no parent node, then abort
     these steps. There would be no way to obtain a reference to the
     nodes created even if the remaining steps were run.</p>
 
@@ -8327,61 +8269,68 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
 
     <p>Let <var title="">parent</var> be <var title="">target</var>'s
     parent node, unless that is a <code>DocumentFragment</code> node,
     in which case let <var title="">parent</var> be an arbitrary
     <code>body</code> element.</p>
 
    </li>
 
    <li>
 
-    <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
-    <var title="">parent</var> as the <var title="">context</var>
-    element and the string being assigned into the <code
-    title="dom-outerHTML-HTML">outerHTML</code> attribute as the <var
-    title="">input</var>. Let <var title="">new children</var> be the
-    result of this algorithm.</p>
+    <p>If <var title="">target</var>'s document is an <span
+    title="HTML documents">HTML document</span>: Invoke the <span>HTML
+    fragment parsing algorithm</span>.</p>
 
-   </li>
+    <p>If <var title="">target</var>'s document is an <span title="XML
+    documents">XML document</span>: Invoke the <span>XML fragment
+    parsing algorithm</span>.</p>
 
-   <li>
+    <p>In either case, the algorithm must be invoked with the string
+    being assigned into the <code
+    title="dom-outerHTML">outerHTML</code> attribute as the <var
+    title="">input</var>, and <var title="">parent</var> as the <var
+    title="">context</var> element.</p>
+
+    <p>If this raises an exception, then abort these steps.</p>
 
-    <p>Let <var title="">target document</var> be the <code
-    title="">ownerDocument</code> of <var title="">target</var>.</p>
+    <p>Otherwise, let <var title="">new children</var> be <var
+    title="">target</var>s returned.</p>
 
    </li>
 
    <li>
 
     <p>Set the <code title="">ownerDocument</code> of all the nodes in
-    <var title="">new children</var> to the <var title="">target
-    document</var>.</p>
+    <var title="">new children</var> to <var title="">target</var>'s
+    document.</p>
 
    </li>
 
    <li>
 
     <p>Remove <var title="">target</var> from its parent node and
     insert in its place all the <var title="">new children</var>
     nodes, preserving their order, without firing any mutation
     events.</p>
 
    </li>
 
   </ol>
 
-  <hr>
+
+
+  <h4><code title="dom-insertAdjacentHTML">insertAdjacentHTML()</code></h4>
 
   <p>The <dfn
-  title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML(<var
+  title="dom-insertAdjacentHTML"><code>insertAdjacentHTML(<var
   title="">position</var>, <var title="">text</var>)</code></dfn>
-  method, when invoked, must run the following steps:</p>
+  method, when invoked, must run the following algorithm:</p>
 
   <ol>
 
    <li>
 
     <p>Let <var title="">position</var> and <var title="">text</var>
     be the method's first and second arguments, respectively.</p>
 
    </li>
 
@@ -8437,40 +8386,45 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
       <p>Throw a <code>SYNTAX_ERR</code> exception.</p>
 
      </dd>
 
     </dl>
 
    </li>
 
    <li>
 
-    <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
-    the <var title="">context</var> element being that selected by the
-    previous step, and <var title="">input</var> being the method's
-    <var title="">text</var> argument. Let <var title="">new
-    children</var> be the result of this algorithm.</p>
+    <p>If <var title="">target</var>'s document is an <span
+    title="HTML documents">HTML document</span>: Invoke the <span>HTML
+    fragment parsing algorithm</span>.</p>
 
-   </li>
+    <p>If <var title="">target</var>'s document is an <span title="XML
+    documents">XML document</span>: Invoke the <span>XML fragment
+    parsing algorithm</span>.</p>
 
-   <li>
+    <p>In either case, the algorithm must be invoked with <var
+    title="">text</var> as the <var title="">input</var>, and the
+    element selected in by the previous step as the <var
+    title="">context</var> element.</p>
+
+    <p>If this raises an exception, then abort these steps.</p>
 
-    <p>Let <var title="">target document</var> be the <code
-    title="">ownerDocument</code> of <var title="">target</var>.</p>
+    <p>Otherwise, let <var title="">new children</var> be <var
+    title="">target</var>s returned.</p>
 
    </li>
 
    <li>
 
     <p>Set the <code title="">ownerDocument</code> of all the nodes in
-    <var title="">new children</var> to the <var title="">target
-    document</var>.</p>
+    <var title="">new children</var> to <var title="">target</var>'s
+    document.</p>
 
    </li>
 
    <li>
 
     <p>Use the first matching item from this list:</p>
 
     <dl>
 
      <dt>If <var title="">position</var> is an <span>ASCII
@@ -8520,233 +8474,20 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
     </dl>
 
     <p>The above mutations must be performed without firing any
     mutation events.</p>
 
    </li>
 
   </ol>
 
 
-  <!-- XXX must make sure we spec that innerHTML et al causes mutation
-  events to fire, but document.write() doesn't. (the latter is already
-  req-stated in the parser section, btw) -->
-
-  <!-- http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp -->
-  <!-- http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#879
-       note script execution disabled
-       http://lxr.mozilla.org/seamonkey/source/content/base/src/nsContentUtils.cpp#3308
-       http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L295
-       http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L242
-       http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLTokenizer.cpp#L1742
-   -->
-
-
-  <h4>Dynamic markup insertion in XML</h4>
-
-  <p>In an XML context, the <dfn 
-  title="dom-innerHTML-XML"><code>innerHTML</code></dfn> DOM attribute
-  on <code>HTMLElement</code>s must return a string in the form of an
-  <a href="http://www.w3.org/TR/xml/#wf-entities">internal general
-  parsed entity</a>, and on <code>HTMLDocument</code>s must return a
-  string in the form of a <a
-  href="http://www.w3.org/TR/xml/#sec-well-formed">document
-  entity</a>. The string returned must be XML namespace-well-formed
-  and must be an isomorphic serialization of all of that node's child
-  nodes, in document order. 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). For the <code title="dom-innerHTML-XML">innerHTML</code>
-  attribute on <code>HTMLElement</code> objects, 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.<!-- because otherwise round-tripping might break
-  since it'll pick up the surrounding default ns when setting -->
-  (This doesn't apply to the <code
-  title="dom-innerHTML-XML">innerHTML</code> attribute on
-  <code>HTMLDocument</code> objects.) <a href="#refsXML">[XML]</a> <a
-  href="#refsXMLNS">[XMLNS]</a></p>
-
-  <p>If any of the following cases are found in the DOM being
-  serialized, the user agent must raise an
-  <code>INVALID_STATE_ERR</code> exception:</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 title="">PubidChar</code> production. <a
-   href="#refsXML">[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 ("'").</li>
-
-   <li>A node with a prefix or local name containing a U+003A COLON
-   (":").</li>
-
-   <li>An <code>Attr</code> node, <code>Text</code> node,
-   <code>CDATASection</code> node, <code>Comment</code> node, or
-   <code>ProcessingInstruction</code> node whose data contains
-   characters that are not matched by the XML <code
-   title="">Char</code> production. <a href="#refsXML">[XML]</a></li>
-
-   <li>A <code>CDATASection</code> node whose data contains the string
-   "<code title="">]]&gt;</code>".</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 <span>ASCII case-insensitive</span> match for the string "<code
-   title="">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 title="">?></code>".</li>
-
-  </ul>
-
-  <p class="note">These are the only ways to make a DOM
-  unserializable. The DOM enforces all the other XML constraints; for
-  example, trying to set an attribute with a name that contains an
-  equals sign (=) will raised an <code>INVALID_CHARACTER_ERR</code>
-  exception.</p>
-
-  <p>On setting, in an XML context, the <code
-  title="dom-innerHTML-XML">innerHTML</code> DOM attribute on
-  <code>HTMLElement</code>s and <code>HTMLDocument</code>s must run
-  the following algorithm:</p>
-
-  <ol>
-
-   <li>
-
-    <p>The user agent must create a new <span>XML parser</span><!-- XXX xref -->.</p>
-
-   </li>
-
-   <li>
-
-    <p>If the <code title="dom-innerHTML-XML">innerHTML</code>
-    attribute is being set on an element, the user agent must
-    <span>feed the parser</span> just created the string corresponding
-    to the start tag of that 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 Core <code
-    title="">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 Core
-    <code title="">isDefaultNamespace()</code> method on the element
-    would return true.</p>
-
-   </li>
-
-   <li>
-
-    <p>The user agent must <span>feed the parser</span> just created
-    the string being assigned into the <code
-    title="dom-innerHTML-XML">innerHTML</code> attribute.</p>
-
-   </li>
-
-   <li>
-
-    <p>If the <code title="dom-innerHTML-XML">innerHTML</code>
-    attribute is being set on an element, the user agent must
-    <span>feed the parser</span> the string corresponding to the end
-    tag of that element.</p>
-
-   </li>
-
-   <li>
-
-    <p>If the parser found an XML well-formedness or XML namespace
-    well-formedness error, the attribute's setter must raise a
-    <code>SYNTAX_ERR</code> exception and abort these steps.</p>
-
-   </li>
-
-   <li>
-
-    <p>The user agent must remove the children nodes of the node whose
-    <code title="dom-innerHTML-XML">innerHTML</code> attribute is
-    being set.</p>
-
-   </li>
-
-   <li>
-
-    <p>If the attribute is being set on a <code>Document</code> node,
-    let <var title="">new children</var> be the children of the
-    document, preserving their order. Otherwise, the attribute is
-    being set on an <code>Element</code> node; let <var title="">new
-    children</var> be the children of the document's root element,
-    preserving their order.</p>
-
-   </li>
-
-   <li>
-
-    <p>If the attribute is being set on a <code>Document</code> node,
-    let <var title="">target document</var> be that
-    <code>Document</code> node. Otherwise, the attribute is being set
-    on an <code>Element</code> node; let <var title="">target
-    document</var> be the <code title="">ownerDocument</code> of that
-    <code>Element</code>.</p>
-
-   </li>
-
-   <li>
-
-    <p>Set the <code title="">ownerDocument</code> of all the nodes in
-    <var title="">new children</var> to the <var title="">target
-    document</var>.</p>
-
-   </li>
-
-   <li>
-
-    <p>Append all the <var title="">new children</var> nodes to the
-    node whose <code title="dom-innerHTML-XML">innerHTML</code>
-    attribute is being set, preserving their order.</p>
-
-   </li>
-
-  </ol>
-
-  <hr>
-
-  <p>In an XML context, the <dfn
-  title="dom-document-write-XML"><code>document.write()</code></dfn>
-  and <dfn
-  title="dom-insertAdjacentHTML-XML"><code>insertAdjacentHTML()</code></dfn>
-  methods, and the <dfn
-  title="dom-outerHTML-XML"><code>outerHTML</code></dfn> attribute on
-  both getting and setting, must raise an
-  <code>INVALID_ACCESS_ERR</code> exception.</p>
-
-<!--
-Where would document.write() insert?
-Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
--->
-
-
 
 
   <h2 id="semantics">The elements of HTML</h2>
 
   <h3>The root element</h3>
 
   <h4>The <dfn><code>html</code></dfn> element</h4>
 
   <dl class="element">
    <dt>Categories</dt>
@@ -10032,21 +9773,21 @@ people expect to have work and what is necessary.
   of the parent element: it merely has no title.</p>
 
   <p>All descendant elements must be processed, according to their
   semantics, before the <code>style</code> element itself is
   evaluated. For styling languages that consist of pure text, user
   agents must evaluate <code>style</code> elements by passing the
   concatenation of the contents of all the <span title="text
   node">text nodes</span> that are direct children of the
   <code>style</code> element (not any other nodes such as comments or
   elements), in <span>tree order</span>, to the style system. For
-  XML-based styling languages, user agents must pass all the children
+  XML-based styling languages, user agents must pass all the child
   nodes of the <code>style</code> element to the style system.</p>
 
   <p>All <span title="URL">URLs</span> found by the styling language's
   processor must be <span title="resolve a url">resolved</span>,
   relative to the element (or as defined by the styling language),
   when the processor is invoked.<!-- so dynamic changes to the base
   URL don't affect the CSS --></p>
 
   <p class="note">This specification does not specify a style system,
   but CSS is expected to be supported by most Web browsers. <a
@@ -10295,35 +10036,26 @@ people expect to have work and what is necessary.
   <p><code>script</code> elements have four associated pieces of
   metadata. The first is a flag indicating whether or not the script
   block has been <dfn>"already executed"</dfn>. Initially,
   <code>script</code> elements must have this flag unset (script
   blocks, when created, are not "already executed"). When a
   <code>script</code> element is cloned, the "already executed" flag,
   if set, must be propagated to the clone when it is created. The
   second is a flag indicating whether the element was
   <dfn>"parser-inserted"</dfn>. This flag is set by the <span>HTML
   parser</span> and is used to handle <code
-  title="dom-document-write-HTML">document.write()</code> calls. The
-  third and fourth pieces of metadata are <dfn><var>the script block's
+  title="dom-document-write">document.write()</code> calls. The third
+  and fourth pieces of metadata are <dfn><var>the script block's
   type</var></dfn> and <dfn><var>the script block's character
   encoding</var></dfn>. They are determined when the script is run,
   based on the attributes on the element at that time.</p>
 
-  <p>When an <span>XML parser</span><!-- XXX xref --> creates a
-  <code>script</code> element, it must be marked as being
-  <span>"parser-inserted"</span>. When the element's end tag is
-  parsed, the user agent must <span title="running a
-  script">run</span> the <code>script</code> element.</p>
-
-  <p class="note">Equivalent requirements exist for the <span>HTML
-  parser</span>, but they are detailed in that section instead.</p>
-
   <p>When a <code>script</code> element that is marked as neither
   having <span>"already executed"</span> nor being
   <span>"parser-inserted"</span> is <span title="insert an element
   into a document">inserted into a document</span>, the user agent
   must <span title="running a script">run</span> the
   <code>script</code> element.</p>
 
   <p><dfn title="running a script">Running a script</dfn>: When a
   <code>script</code> element is to be run, the user agent must act as
   follows:</p>
@@ -10388,30 +10120,24 @@ people expect to have work and what is necessary.
     for this <code>script</code> element be the same as <span
     title="document's character encoding">the encoding of the document
     itself</span>.</p>
 
    </li>
 
    <li>
 
     <p>If <span title="concept-n-noscript">scripting is
     disabled</span> for the <code>script</code> element, or if the
-    <code>script</code> element was created by an <span>XML
-    parser</span><!-- XXX xref --> that itself was created as part of
-    the processing of the <code
-    title="dom-innerHTML-XML">innerHTML</code> attribute's setter<!--
-    no need to worry about the HTML case, as the HTML parser handles
-    that for us -->, or if the user agent does not <span>support the
-    scripting language</span> given by <var>the script block's
-    type</var> for this <code>script</code> element, then the user
-    agent must abort these steps at this point. The script is not
-    executed.</p>
+    user agent does not <span>support the scripting language</span>
+    given by <var>the script block's type</var> for this
+    <code>script</code> element, then the user agent must abort these
+    steps at this point. The script is not executed.</p>
 
    </li>
 
    <li>
 
     <p>The user agent must set the element's <span>"already
     executed"</span> flag.</p>
 
    </li>
 
@@ -10779,20 +10505,29 @@ o............A....e
 
    <p>The data in this case might be used by the script to generate
    the map of a video game. The data doesn't have to be used that way,
    though; maybe the map data is actually embedded in other parts of
    the page's markup, and the data block here is just used by the
    site's search engine to help users who are looking for particular
    features in their game maps.</p>
 
   </div>
 
+  <p class="note">When inserted using the <code
+  title="dom-document-write">document.write()</code> method,
+  <code>script</code> elements execute (typically synchronously), but
+  when inserted using <code
+  title="dom-innerHTML">innerHTML</code> and <code
+  title="dom-outerHTML">outerHTML</code> attributes, they do not
+  execute at all.</p>
+
+
 
 
   <h5 id="scriptingLanguages">Scripting languages</h5>
 
   <p>A user agent is said to <dfn>support the scripting language</dfn>
   if <var>the script block's type</var> matches the MIME type of a
   scripting language that the user agent implements.</p>
 
   <p>The following lists some MIME types and the languages to which
   they refer:</p>
@@ -10964,21 +10699,21 @@ not-slash     = %x0000-002E / %x0030-%10FFFF
        elements <var title="">the before children</var>.</li>
 
        <li>Take all the children of the <var title="">parent element</var>
        that come <em>after</em> the <code>noscript</code> element, and
        call these elements <var title="">the after children</var>.</li>
 
        <li>Let <var title="">s</var> be the concatenation of all the
        <span>text node</span> children of the <code>noscript</code>
        element.</li>
 
-       <li>Set the <code title="dom-innerHTML-HTML">innerHTML</code>
+       <li>Set the <code title="dom-innerHTML">innerHTML</code>
        attribute of the <var title="">parent element</var> to the value
        of <var title="">s</var>. (This, as a side-effect, causes the
        <code>noscript</code> element to be removed from the
        document.)</li>
 
        <li>Insert <var title="">the before children</var> at the start of
        the <var title="">parent element</var>, preserving their original
        relative order.</li>
 
        <li>Insert <var title="">the after children</var> at the end of the
@@ -50328,21 +50063,21 @@ http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSPr
    <dd><strong>State:</strong> Always false.</dd>
    <dd><strong>Value:</strong> Always the string "<code title="">false</code>".</dd>
 
    <dt><dfn title="command-insertHTML"><code>insertHTML</code></dfn></dt>
    <dd>
     <p><strong>Action:</strong> The user agent must run the following
     steps:</p>
     <ol>
      <li><p>If the document is an <span>XML document</span>, then
      throw an <code>INVALID_ACCESS_ERR</code> exception and abort
-     these steps.</p></li>
+     these steps.</p></li><!-- XXX support XML? -->
      <li><p>If the <var title="">value</var> argument wasn't
      specified, abort these steps without doing anything.</p></li>
      <li><p>If there is a selection, act as if the user had requested
      that <a href="#contenteditable-delete">the selection be
      deleted</a>.</p></li>
      <li><p>Invoke the <span>HTML fragment parsing algorithm</span>
      with an arbitrary orphan <code>body</code> element as the
      <i>context</i> element and with the <var title="">value</var>
      argument as <i>input</i>.</p></li>
      <li><p>Insert the nodes returned by the previous step into the
@@ -52925,25 +52660,26 @@ interface <dfn>MessageChannel</dfn> {
   queue</span> that is to be dispatched on that
   <code>MessagePort</code> object, or while the
   <code>MessagePort</code> object's <span>port message queue</span> is
   open and there exists a <code title="event-message">message</code>
   event in that queue.</p>
   <!-- we might not need to explicitly say the first part of DOM
   Events is fixed to say that events on a task queue prevent GC -->
 
 
 
-  <h2 id="syntax">The HTML syntax</h2>
+  <h2 id="syntax"><dfn>The HTML syntax</dfn></h2>
 
   <p class="note">This section only describes the rules for <code
   title="">text/html</code> resources. Rules for XML resources are
-  defined by the XML specifications.</p>
+  discussed in the section below entitled "<span>The XHTML
+  syntax</span>".</p>
 
   <h3>Writing HTML documents</h3>
 
   <p><em>This section only applies to documents, authoring tools, and
   markup generators. In particular, it does not apply to conformance
   checkers; conformance checkers must use the requirements given in
   the next section ("parsing HTML documents").</em></p>
 
   <p>Documents must consist of the following parts, in the given
   order:</p>
@@ -53760,31 +53496,27 @@ interface <dfn>MessageChannel</dfn> {
   title="">--&gt;</code>).</p>
 
 
 
   <h3 id="parsing">Parsing HTML documents</h3>
 
   <p><em>This section only applies to user agents, data mining tools,
   and conformance checkers.</em></p>
  
   <p>The rules for parsing <span>XML documents</span> (and thus
-  <span>XHTML</span> documents) into DOM trees are covered by the XML
-  and Namespaces in XML specifications, and are out of scope of this
-  specification. <a href="#refsXML">[XML]</a> <a
-  href="#refsXMLNS">[XMLNS]</a> <!-- XXX refs --></p>
+  <span>XHTML</span> documents) into DOM trees are covered by the next
+  section, entitled "<span>The XHTML syntax</span>".</p>
 
   <p>For <span>HTML documents</span>, user agents must use the parsing
   rules described in this section to generate the DOM trees. Together,
   these rules define what is referred to as the <dfn>HTML
-  parser</dfn>.</p><!-- XXX should probably remove that "must" since
-  it'll be redundant with something in the navigating processing model
-  eventually -->
+  parser</dfn>.</p>
 
   <div class="note">
 
    <p>While the HTML form of HTML5 bears a close resemblance to SGML
    and XML, it is a separate language with its own parsing rules.</p>
 
    <p>Some earlier versions of HTML (in particular from HTML2 to
    HTML4) were based on SGML and used SGML parsing rules. However, few
    (if any) web browsers ever implemented true SGML parsing for HTML
    documents; the only user agents to strictly handle HTML as an SGML
@@ -53834,21 +53566,21 @@ interface <dfn>MessageChannel</dfn> {
   is a <code>Document</code> object.</p>
 
   <p class="note">Implementations that <a href="#non-scripted">do not
   support scripting</a> do not have to actually create a DOM
   <code>Document</code> object, but the DOM tree in such cases is
   still used as the model for the rest of the specification.</p>
 
   <p>In the common case, the data handled by the tokenization stage
   comes from the network, but <span title="dynamic markup
   insertion">it can also come from script</span>, e.g. using the <code
-  title="dom-document-write-HTML">document.write()</code> API.</p>
+  title="dom-document-write">document.write()</code> API.</p>
 
   <p><img src="images/parsing-model-overview.png" alt=""></p>
 
   <p id="nestedParsing">There is only one set of state for the
   tokeniser stage and the tree construction stage, but the tree
   construction stage is reentrant, meaning that while the tree
   construction stage is handling one token, the tokeniser might be
   resumed, causing further tokens to be emitted and processed before
   the first token's processing is complete.</p>
 
@@ -54487,21 +54219,21 @@ interface <dfn>MessageChannel</dfn> {
   <span>tokenization</span> stage.</p>
 
   <p>The <dfn>next input character</dfn> is the first character in the
   input stream that has not yet been <dfn>consumed</dfn>. Initially,
   the <em>next input character</em> is the first character in the
   input.</p>
 
   <p>The <dfn>insertion point</dfn> is the position (just before a
   character or just before the end of the input stream) where content
   inserted using <code
-  title="dom-document-write-HTML">document.write()</code> is actually
+  title="dom-document-write">document.write()</code> is actually
   inserted. The insertion point is relative to the position of the
   character immediately after it, it is not an absolute offset into
   the input stream. Initially, the insertion point is
   uninitialized.</p>
 
   <p>The "EOF" character in the tables below is a conceptual character
   representing the end of the <span>input stream</span>. If the parser
   is a <span>script-created parser</span>, then the end of the
   <span>input stream</span> is reached when an <dfn>explicit "EOF"
   character</dfn> (inserted by the <code
@@ -56569,21 +56301,21 @@ interface <dfn>MessageChannel</dfn> {
   <code>Text</code> node, and that <code>Text</code> node was the last
   node that the parser inserted into the document, then the character
   must be appended to that <code>Text</code> node; otherwise, a new
   <code>Text</code> node whose data is just that character must be
   inserted in the appropriate place.</p>
 
   <p id="mutation-during-parsing">DOM mutation events must not fire
   for changes caused by the UA parsing the document. (Conceptually,
   the parser is not mutating the DOM, it is constructing it.) This
   includes the parsing of any content inserted using <code
-  title="dom-document-write-HTML">document.write()</code> and <code
+  title="dom-document-write">document.write()</code> and <code
   title="dom-document-writeln">document.writeln()</code> calls. <a
   href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
 
   <p class="note">Not all of the tag names mentioned below are
   conformant tag names in this specification; many are included to
   handle legacy content. They still form part of the algorithm that
   implementations are required to implement to claim conformance.</p>
 
   <p class="note">The algorithm described below places no limit on the
   depth of the DOM tree generated, or on the length of tag names,
@@ -57299,25 +57031,26 @@ interface <dfn>MessageChannel</dfn> {
 
     <ol>
 
      <li><p><span>Create an element for the token</span> in the
      <span>HTML namespace</span>.</p></li>
 
      <li>
 
       <p>Mark the element as being <span>"parser-inserted"</span>.</p>
 
-      <p class="note">This ensures that, if the script is external, any
-      <code title="dom-document-write-HTML">document.write()</code>
+      <p class="note">This ensures that, if the script is external,
+      any <code title="dom-document-write">document.write()</code>
       calls in the script will execute in-line, instead of blowing the
       document away, as would happen in most other cases. It also
-      prevents the script from executing until the end tag is seen.</p>
+      prevents the script from executing until the end tag is
+      seen.</p>
 
      </li>
 
      <li><p>If the parser was originally created for the <span>HTML
      fragment parsing algorithm</span>, then mark the
      <code>script</code> element as <span>"already
      executed"</span>. (<span>fragment case</span>)</p></li>
 
      <li><p>Append the new element to the <span>current node</span>
      and push it onto the <span>stack of open
@@ -58865,44 +58598,44 @@ interface <dfn>MessageChannel</dfn> {
     <p>Let the <var title="">old insertion point</var> have the
     same value as the current <span>insertion point</span>. Let
     the <span>insertion point</span> be just before the <span>next
     input character</span>.</p>
 
     <p>Increment the parser's <span>script nesting level</span> by
     one.</p>
 
     <p><span title="running a script">Run</span> the <var
     title="">script</var>. This might cause some script to execute,
-    which might cause <span title="dom-document-write-HTML">new
-    characters to be inserted into the tokeniser</span>, and might
-    cause the tokeniser to output more tokens, resulting in a <a
+    which might cause <span title="dom-document-write">new characters
+    to be inserted into the tokeniser</span>, and might cause the
+    tokeniser to output more tokens, resulting in a <a
     href="#nestedParsing">reentrant invocation of the parser</a>.</p>
 
     <p>Decrement the parser's <span>script nesting level</span> by
     one. If the parser's <span>script nesting level</span> is zero,
     then set the <span>parser pause flag</span> to false.</p>
 
     <p>Let the <span>insertion point</span> have the value of the
     <var title="">old insertion point</var>. (In other words,
     restore the <span>insertion point</span> to the value it had
     before the previous paragraph. This value might be the
     "undefined" value.)</p>
 
     <p id="scriptTagParserResumes">At this stage, if there is a
     <span>pending external script</span>, then:</p>
 
     <dl class="switch">
 
      <dt>If the tree construction stage is <a
      href="#nestedParsing">being called reentrantly</a>, say from a
      call to <code
-     title="dom-document-write-HTML">document.write()</code>:</dt>
+     title="dom-document-write">document.write()</code>:</dt>
 
      <dd><p>Set the <span>parser pause flag</span> to true, and abort
      the processing of any nested invocations of the tokeniser,
      yielding control back to the caller. (Tokenization will resume
      when the caller returns to the "outer" tree construction
      stage.)</p></dd>
 
 
      <dt>Otherwise:</dt>
 
@@ -60750,31 +60483,32 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
   <code>script</code> element contain a text node with the text string
   "<code>&lt;/script></code>", or having a <code>p</code> element that
   contains a <code>ul</code> element (as the <code>ul</code> element's
   <span title="syntax-start-tag">start tag</span> would imply the end
   tag for the <code>p</code>).</p>
 
 
   <h3>Parsing HTML fragments</h3>
 
   <p>The following steps form the <dfn>HTML fragment parsing
-  algorithm</dfn>. The algorithm takes as input a DOM
-  <code>Element</code>, referred to as the <var title="">context</var>
-  element, which gives the context for the parser, as well as <var
-  title="">input</var>, a string to parse, and returns a list of zero
-  or more nodes.</p>
+  algorithm</dfn>. The algorithm optionally takes as input an
+  <code>Element</code> node, referred to as the <var
+  title="">context</var> element, which gives the context for the
+  parser, as well as <var title="">input</var>, a string to parse, and
+  returns a list of zero or more nodes.</p>
 
   <p class="note">Parts marked <dfn>fragment case</dfn> in algorithms
   in the parser section are parts that only occur if the parser was
-  created for the purposes of this algorithm. The algorithms have been
-  annotated with such markings for informational purposes only; such
-  markings have no normative weight. If it is possible for a condition
+  created for the purposes of this algorithm (and with a <var
+  title="">context</var> element). The algorithms have been annotated
+  with such markings for informational purposes only; such markings
+  have no normative weight. If it is possible for a condition
   described as a <span>fragment case</span> to occur even when the
   parser wasn't created for the purposes of handling this algorithm,
   then that is an error in the specification.</p>
 
   <ol>
 
    <li>
 
     <p>Create a new <code>Document</code> node, and mark it as being
     an <span title="HTML documents">HTML document</span>.</p>
@@ -60783,103 +60517,114 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
 
    <li>
 
     <p>Create a new <span>HTML parser</span>, and associate it with
     the just created <code>Document</code> node.</p>
 
    </li>
 
    <li>
 
-    <p>Set the <span>HTML parser</span>'s <span>tokenization</span>
-    stage's <span>content model flag</span> according to the <var
-    title="">context</var> element, as follows:</p>
+    <p>If there is a <var title="">context</var> element, run these
+    substeps:</p>
 
-    <dl class="switch">
+    <ol>
 
-     <dt>If it is a <code>title</code> or <code>textarea</code>
-     element</dt>
+     <li>
 
-     <dd>Set the <span>content model flag</span> to
-     the RCDATA state.</dd>
+      <p>Set the <span>HTML parser</span>'s <span>tokenization</span>
+      stage's <span>content model flag</span> according to the <var
+      title="">context</var> element, as follows:</p>
 
+      <dl class="switch">
 
-     <dt>If it is a <code>style</code>, <code>script</code>,
-     <code>xmp</code>, <code>iframe</code>, <code>noembed</code>, or
-     <code>noframes</code> element</dt>
+       <dt>If it is a <code>title</code> or <code>textarea</code>
+       element</dt>
 
-     <dd>Set the <span>content model flag</span> to
-     the CDATA state.</dd>
+       <dd>Set the <span>content model flag</span> to
+       the RCDATA state.</dd>
 
 
-     <dt>If it is a <code>noscript</code> element</dt>
+       <dt>If it is a <code>style</code>, <code>script</code>,
+       <code>xmp</code>, <code>iframe</code>, <code>noembed</code>, or
+       <code>noframes</code> element</dt>
 
-     <dd>If the <span>scripting flag</span> is enabled, set the
-     <span>content model flag</span> to the CDATA
-     state. Otherwise, set the <span>content model flag</span> to the
-     PCDATA state.</dd>
+       <dd>Set the <span>content model flag</span> to
+       the CDATA state.</dd>
 
 
-     <dt>If it is a <code>plaintext</code> element</dt>
+       <dt>If it is a <code>noscript</code> element</dt>
 
-     <dd>Set the <span>content model flag</span> to
-     PLAINTEXT.</dd>
+       <dd>If the <span>scripting flag</span> is enabled, set the
+       <span>content model flag</span> to the CDATA
+       state. Otherwise, set the <span>content model flag</span> to the
+       PCDATA state.</dd>
 
 
-     <dt>Otherwise</dt>
+       <dt>If it is a <code>plaintext</code> element</dt>
 
-     <dd>Set the <span>content model flag</span> to the PCDATA
-     state.</dd>
+       <dd>Set the <span>content model flag</span> to
+       PLAINTEXT.</dd>
 
-    </dl>
 
-   </li>
+       <dt>Otherwise</dt>
 
-   <li>
+       <dd>Leave the <span>content model flag</span> in the PCDATA
+       state.</dd>
 
-    <p>Let <var title="">root</var> be a new <code>html</code> element
-    with no attributes.</p>
+      </dl>
 
-   </li>
+     </li>
 
-   <li>
+     <li>
 
-    <p>Append the element <var title="">root</var> to the
-    <code>Document</code> node created above.</p>
+      <p>Let <var title="">root</var> be a new <code>html</code> element
+      with no attributes.</p>
 
-   </li>
+     </li>
 
-   <li>
+     <li>
 
-    <p>Set up the parser's <span>stack of open elements</span> so that
-    it contains just the single element <var title="">root</var>.</p>
+      <p>Append the element <var title="">root</var> to the
+      <code>Document</code> node created above.</p>
 
-   </li>
+     </li>
 
-   <li>
+     <li>
 
-    <p><span title="reset the insertion mode appropriately">Reset the
-    parser's insertion mode appropriately</span>.</p>
+      <p>Set up the parser's <span>stack of open elements</span> so that
+      it contains just the single element <var title="">root</var>.</p>
 
-    <p class="note">The parser will reference the <var
-    title="">context</var> element as part of that algorithm.</p>
+     </li>
 
-   </li>
+     <li>
 
-   <li>
+      <p><span title="reset the insertion mode appropriately">Reset the
+      parser's insertion mode appropriately</span>.</p>
+
+      <p class="note">The parser will reference the <var
+      title="">context</var> element as part of that algorithm.</p>
 
-    <p>Set the parser's <span><code>form</code> element pointer</span>
-    to the nearest node to the <var title="">context</var> element
-    that is a <code>form</code> element (going straight up the
-    ancestor chain, and including the element itself, if it is a
-    <code>form</code> element), or, if there is no such
-    <code>form</code> element, to null.</p>
+     </li>
+
+     <li>
+
+      <p>Set the parser's <span><code>form</code> element pointer</span>
+      to the nearest node to the <var title="">context</var> element
+      that is a <code>form</code> element (going straight up the
+      ancestor chain, and including the element itself, if it is a
+      <code>form</code> element), or, if there is no such
+      <code>form</code> element, to null.</p>
+
+     </li>
+
+    </ol>
 
    </li>
 
    <li>
 
     <p>Place into the <span>input stream</span> for the <span>HTML
     parser</span> just created the <var title="">input</var>. The
     encoding <span
     title="concept-encoding-confidence">confidence</span> is
     <i>irrelevant</i>.</p>
@@ -60888,22 +60633,26 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
 
    <li>
 
     <p>Start the parser and let it run until it has consumed all the
     characters just inserted into the input stream.</p>
 
    </li>
 
    <li>
 
-    <p>Return all the child nodes of <var title="">root</var>,
-    preserving the document order.</p>
+    <p>If there is a <var title="">context</var> element, return the
+    child nodes of <var title="">root</var>, in <span>tree
+    order</span>.</p>
+
+    <p>Otherwise, return the children of the <code>Document</code>
+    object, in <span>tree order</span>.</p>
 
    </li>
 
   </ol>
 
 
 
   <h3><dfn>Named character references</dfn></h3>
 
   <p>This table lists the character reference names that are supported
@@ -60922,20 +60671,256 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
    > I would add &sub1; (character U+2081), &sub2;
    > (character U+2082) and &sub3; (character U+2083). They
    > would are the equivalent to &sup1;, &sup2;, and &sup3;.
    See also: http://www.w3.org/2003/entities/
   -->
   </div>
 
 
 
 
+  <h2><dfn>The XHTML syntax</dfn></h2>
+
+  <p class="note">This section only describes the rules for XML
+  resources. Rules for <code title="">text/html</code> resources are
+  discussed in the section above entitled "<span>The HTML
+  syntax</span>".</p>
+
+
+  <h3>Writing XHTML documents</h3>
+
+  <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 href="#refsXML">[XML]</a> <a
+  href="#refsXMLNS">[XMLNS]</a></p>
+
+  <p>This specification does not define any syntax-level requirements
+  beyond those defined for XML proper.</p>
+
+
+  <h3>Parsing XHTML documents</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>XML parser</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>An <span>XML parser</span> 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 Core specification. DOM mutation events
+  must not fire for the operations that the <span>XML parser</span>
+  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 in inserted into a document
+  or has its attributes set. <a href="#refsXML">[XML]</a> <a
+  href="#refsXMLNS">[XMLNS]</a> <a href="#refsDOMCORE">[DOMCORE]</a>
+  <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
+
+  <p>Certain algorithms in this specification <dfn title="feed the
+  parser">spoon-feed the parser</dfn> characters one string at a
+  time. In such cases, the <span>XML parser</span> must act as it
+  would have if faced with a single string consisting of the
+  concatenation of all those characters.</p>
+
+  <p>When an <span>XML parser</span> creates a <code>script</code>
+  element, it must be marked as being <span>"parser-inserted"</span>.
+  If the parser was originally created for the <span>XML fragment
+  parsing algorithm</span>, then the element must be marked as
+  <span>"already executed"</span> also. When the element's end tag is
+  parsed, the user agent must <span title="running a
+  script">run</span> the <code>script</code> element. If this causes
+  there to be a <span>pending external script</span>, then the user
+  agent must <span>pause</span> until that script has <span>completed
+  loading</span>, and then <span title="executing a script
+  block">execute it</span>.</p>
+
+  <p class="note">Since the <code
+  title="dom-document-write">document.write()</code> API is not
+  available for <span>XML documents</span>, much of the complexity in
+  the <span>HTML parser</span> is not needed in the <span>XML
+  parser</span>.</p>
+
+  <p>When an <span>XML parser</span> reaches the end of its input, it
+  must <span>stop parsing</span>, following the same rules as the
+  <span>HTML parser</span>.</p>
+
+
+
+  <h3>Serializing XHTML fragments</h3>
+
+  <p>The <dfn>XML fragment serialization algorithm</dfn> for a
+  <code>Document</code> or <code>Element</code> node either returns a
+  fragment of XML that represents that node or raises an
+  exception.</p>
+
+  <p>For <code>Document</code>s, the algorithm must return a string in
+  the form of a <a
+  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>Element</code>s, the algorithm must return a string in
+  the form of an <a
+  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 child nodes, in <span>tree order</span>. 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).</p>
+
+  <p>For <code>Element</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.<!-- because otherwise round-tripping might break since it'll
+  pick up the surrounding default ns when setting --> (This doesn't
+  apply in the <code>Document</code> case.) <a
+  href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a></p>
+
+  <p>If any of the following error cases are found in the DOM subtree
+  being serialized, then the algorithm raises an
+  <code>INVALID_STATE_ERR</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 title="">PubidChar</code> production. <a
+   href="#refsXML">[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 ("'").</li>
+
+   <li>A node with a prefix or local name containing a U+003A COLON
+   (":").</li>
+
+   <li>An <code>Attr</code> node, <code>Text</code> node,
+   <code>CDATASection</code> node, <code>Comment</code> node, or
+   <code>ProcessingInstruction</code> node whose data contains
+   characters that are not matched by the XML <code
+   title="">Char</code> production. <a href="#refsXML">[XML]</a></li>
+
+   <li>A <code>CDATASection</code> node whose data contains the string
+   "<code title="">]]&gt;</code>".</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 <span>ASCII case-insensitive</span> match for the string "<code
+   title="">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 title="">?></code>".</li>
+
+  </ul>
+
+  <p class="note">These are the only ways to make a DOM
+  unserializable. The DOM enforces all the other XML constraints; for
+  example, trying to set an attribute with a name that contains an
+  equals sign (=) will raised an <code>INVALID_CHARACTER_ERR</code>
+  exception.</p>
+
+
+
+  <h3>Parsing XHTML fragments</h3>
+
+  <p>The <dfn>XML fragment parsing algorithm</dfn> for either returns
+  a <code>Document</code> or raises a <code>SYNTAX_ERR</code>
+  exception. Given a string <var title="">input</var> and an optional
+  context element <var title="">context</var>, the algorithm is as
+  follows:</p>
+
+  <ol>
+
+   <li>
+
+    <p>Create a new <span>XML parser</span>.</p>
+
+   </li>
+
+   <li>
+
+    <p>If there is a <var title="">context</var> element, <span>feed
+    the parser</span> just created the string corresponding to the
+    start tag of that 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 Core <code
+    title="">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 Core
+    <code title="">isDefaultNamespace()</code> method on the element
+    would return true.</p>
+
+   </li>
+
+   <li>
+
+    <p><span>Feed the parser</span> just created the string <var
+    title="">input</var>.</p>
+
+   </li>
+
+   <li>
+
+    <p>If there is a <var title="">context</var> element, <span>feed
+    the parser</span> just created the string corresponding to the
+    end tag of that element.</p>
+
+   </li>
+
+   <li>
+
+    <p>If there is an XML well-formedness or XML namespace
+    well-formedness error, then raise a <code>SYNTAX_ERR</code>
+    exception and abort these steps.</p>
+
+   </li>
+
+   <li>
+
+    <p>If there is a <var title="">context</var> element, then return
+    the child nodes of the root element of the resulting
+    <code>Document</code>, in <span>tree order</span>.</p>
+
+    <p>Otherwise, return the children of the <code>Document</code>
+    object, in <span>tree order</span>.</p>
+
+   </li>
+
+  </ol>
+
+
+
+
   <h2 id="rendering">Rendering</h2>
 
   <!-- XXX
 
     Rendering
 
     Default styling
       (have one paragraph or subsection per element)
       :link, :visited { }
       :link { }

|