HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/2720

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
Index: source
===================================================================
--- source	(revision 2719)
+++ source	(revision 2720)
@@ -6180,14 +6180,6 @@
   <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
@@ -7853,74 +7845,21 @@
   </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>
@@ -8098,16 +8037,31 @@
   <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>
@@ -8145,7 +8099,7 @@
     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
@@ -8161,108 +8115,88 @@
 
   </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>
+  <h4><code title="dom-document-writeln">document.writeln()</code></h4>
 
-  <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>
+  <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>
 
-  <ol>
 
-   <li>
 
-    <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>
+  <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>
 
-    <p>Remove the children nodes of the <code>Document</code> whose
-    <code title="dom-innerHTML-HTML">innerHTML</code> attribute is
-    being set.</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 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>
 
-   </li>
+  <p>On setting, the following steps must be run:</p>
 
-   <li>
+  <ol>
 
-    <p>Create a new <span>HTML parser</span>, in its initial state,
-    and associate it with the <code>Document</code> node.</p>
-
-   </li>
-
-<!-- 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>
--->
+    <p>If the node'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-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>
 
-    <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>
+    <p>If this raises an exception, then abort these steps.</p>
 
-   </li>
+    <p>Otherwise, let <var title="">new children</var> be the nodes
+    returned.</p>
 
-   <li>
-
-    <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>
-
    </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>
 
@@ -8277,31 +8211,39 @@
    <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>
@@ -8334,27 +8276,32 @@
 
    <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>Let <var title="">target document</var> be the <code
-    title="">ownerDocument</code> of <var title="">target</var>.</p>
+    <p>If this raises an exception, then abort these steps.</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>
 
@@ -8369,12 +8316,14 @@
 
   </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>
 
@@ -8444,26 +8393,31 @@
 
    <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>Let <var title="">target document</var> be the <code
-    title="">ownerDocument</code> of <var title="">target</var>.</p>
+    <p>If this raises an exception, then abort these steps.</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>
 
@@ -8527,221 +8481,8 @@
   </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>
@@ -10039,7 +9780,7 @@
   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
@@ -10302,21 +10043,12 @@
   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
@@ -10395,16 +10127,10 @@
 
     <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>
 
@@ -10786,8 +10512,17 @@
 
   </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>
@@ -10971,7 +10706,7 @@
        <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
@@ -50335,7 +50070,7 @@
     <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
@@ -52932,11 +52667,12 @@
 
 
 
-  <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>
 
@@ -53767,17 +53503,13 @@
   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">
 
@@ -53841,7 +53573,7 @@
   <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>
 
@@ -54494,7 +54226,7 @@
   <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
@@ -56576,7 +56308,7 @@
   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>
 
@@ -57306,11 +57038,12 @@
 
       <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>
 
@@ -58872,9 +58605,9 @@
 
     <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
@@ -58895,7 +58628,7 @@
      <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,
@@ -60757,17 +60490,18 @@
   <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>
@@ -60790,90 +60524,101 @@
 
    <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>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>
+      <p class="note">The parser will reference the <var
+      title="">context</var> element as part of that algorithm.</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>
@@ -60895,9 +60640,13 @@
 
    <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>
@@ -60929,6 +60678,242 @@
 
 
 
+  <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

|