Add the candidate CR document
authortravil
Thu, 05 Jun 2014 15:57:19 -0700
changeset 72 e14bd5590323
parent 71 d86d21f30860
child 73 d69286304cc3
Add the candidate CR document
CR-DOM-Parsing-20140624.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CR-DOM-Parsing-20140624.html	Thu Jun 05 15:57:19 2014 -0700
@@ -0,0 +1,2125 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" typeof="bibo:Document w3p:CR" about="" property="dcterms:language" content="en">
+<head>
+    <meta charset="UTF-8">
+    <title>DOM Parsing and Serialization</title>
+    <style>
+        /* Make these stand-out more... */
+        .externalDFN {
+            font-style: italic;
+            background-color: #fff9d6;
+        }
+        /* Switch statement */
+        dl.switch dt::before {
+            content: "↪ ";
+            margin-left: 1em;
+        }
+        /* Better spacing around various lists (implied paragraph children) */
+        ol > li, section:not(#toc) ul > li, section dl > dt {
+            margin: 1em 0;
+        }
+        var { color: maroon; }
+        /* domintro styling */
+        dl.domintro {
+            background-color: rgb(221, 255, 221);
+            padding: 1em 0.5em 1em 2em;
+            clear: both;
+        }
+        dl.domintro dt {
+            color: black;
+        }
+        dl.domintro > dd {
+            color: green;
+        }
+        dl.domintro::before {
+            float: right;
+            background-color: white;
+            display: block;
+            border: 2px solid black;
+            color: green;
+            margin-top: -20px;
+            padding: 2px;
+            content: "This box is non-normative. Implementation requirements are given below this box.";
+        }
+        /* Fancy table stuff */
+        table {
+            border-collapse: collapse;
+        }
+        thead tr {
+            border-bottom: 2px solid black;
+        }
+        tbody tr:not(:last-child) {
+            border-bottom: 1px solid black;
+        }
+        td {
+            border-left: 1px solid black;
+            padding: 4px;
+        }
+        /* Extra IDL :-) */
+        .extraidl {
+            line-height: 120%;
+            padding: 1em;
+            border-top: 1px solid #90b8de;
+            border-bottom: 1px solid #90b8de;
+        }
+        .extraidl:before {
+            width: 150px;
+            color: #fff;
+            padding: 3px;
+            font-weight: bold;
+            font-family: initial;
+            margin: -1em 0 1em -1em;
+            display: block;
+            content: "WebIDL";
+            background-color: rgb(144, 184, 222);
+        }
+    </style>
+    
+    
+<style>/*****************************************************************
+ * ReSpec 3 CSS
+ * Robin Berjon - http://berjon.com/
+ *****************************************************************/
+
+/* --- INLINES --- */
+em.rfc2119 { 
+    text-transform:     lowercase;
+    font-variant:       small-caps;
+    font-style:         normal;
+    color:              #900;
+}
+
+h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
+h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
+    border: none;
+}
+
+dfn {
+    font-weight:    bold;
+}
+
+a.internalDFN {
+    color:  inherit;
+    border-bottom:  1px solid #99c;
+    text-decoration:    none;
+}
+
+a.externalDFN {
+    color:  inherit;
+    border-bottom:  1px dotted #ccc;
+    text-decoration:    none;
+}
+
+a.bibref {
+    text-decoration:    none;
+}
+
+cite .bibref {
+    font-style: normal;
+}
+
+code {
+    color:  #ff4500;
+}
+
+/* --- TOC --- */
+.toc a, .tof a {
+    text-decoration:    none;
+}
+
+a .secno, a .figno {
+    color:  #000;
+}
+
+ul.tof, ol.tof {
+    list-style: none outside none;
+}
+
+.caption {
+    margin-top: 0.5em;
+    font-style:   italic;
+}
+
+/* --- TABLE --- */
+table.simple {
+    border-spacing: 0;
+    border-collapse:    collapse;
+    border-bottom:  3px solid #005a9c;
+}
+
+.simple th {
+    background: #005a9c;
+    color:  #fff;
+    padding:    3px 5px;
+    text-align: left;
+}
+
+.simple th[scope="row"] {
+    background: inherit;
+    color:  inherit;
+    border-top: 1px solid #ddd;
+}
+
+.simple td {
+    padding:    3px 10px;
+    border-top: 1px solid #ddd;
+}
+
+.simple tr:nth-child(even) {
+    background: #f0f6ff;
+}
+
+/* --- DL --- */
+.section dd > p:first-child {
+    margin-top: 0;
+}
+
+.section dd > p:last-child {
+    margin-bottom: 0;
+}
+
+.section dd {
+    margin-bottom:  1em;
+}
+
+.section dl.attrs dd, .section dl.eldef dd {
+    margin-bottom:  0;
+}
+
+@media print {
+    .removeOnSave {
+        display: none;
+    }
+}
+</style><style>/* --- ISSUES/NOTES --- */
+div.issue-title, div.note-title {
+    padding-right:  1em;
+    min-width: 7.5em;
+    color: #b9ab2d;
+}
+div.issue-title { color: #e05252; }
+div.note-title { color: #2b2; }
+div.issue-title span, div.note-title span {
+    text-transform: uppercase;
+}
+div.note, div.issue {
+    margin-top: 1em;
+    margin-bottom: 1em;
+}
+.note > p:first-child, .issue > p:first-child { margin-top: 0 }
+.issue, .note {
+    padding: .5em;
+    border-left-width: .5em;
+    border-left-style: solid;
+}
+div.issue, div.note {
+    padding: 1em 1.2em 0.5em;
+    margin: 1em 0;
+    position: relative;
+    clear: both;
+}
+span.note, span.issue { padding: .1em .5em .15em; }
+
+.issue {
+    border-color: #e05252;
+    background: #fbe9e9;
+}
+.note {
+    border-color: #52e052;
+    background: #e9fbe9;
+}
+
+
+</style><style>/* --- WEB IDL --- */
+pre.idl {
+    border-top: 1px solid #90b8de;
+    border-bottom: 1px solid #90b8de;
+    padding:    1em;
+    line-height:    120%;
+}
+
+pre.idl::before {
+    content:    "WebIDL";
+    display:    block;
+    width:      150px;
+    background: #90b8de;
+    color:  #fff;
+    font-family:    initial;
+    padding:    3px;
+    font-weight:    bold;
+    margin: -1em 0 1em -1em;
+}
+
+.idlType {
+    color:  #ff4500;
+    font-weight:    bold;
+    text-decoration:    none;
+}
+
+/*.idlModule*/
+/*.idlModuleID*/
+/*.idlInterface*/
+.idlInterfaceID, .idlDictionaryID, .idlCallbackID, .idlEnumID {
+    font-weight:    bold;
+    color:  #005a9c;
+}
+a.idlEnumItem {
+    color:  #000;
+    border-bottom:  1px dotted #ccc;
+    text-decoration: none;
+}
+
+.idlSuperclass {
+    font-style: italic;
+    color:  #005a9c;
+}
+
+/*.idlAttribute*/
+.idlAttrType, .idlFieldType, .idlMemberType {
+    color:  #005a9c;
+}
+.idlAttrName, .idlFieldName, .idlMemberName {
+    color:  #ff4500;
+}
+.idlAttrName a, .idlFieldName a, .idlMemberName a {
+    color:  #ff4500;
+    border-bottom:  1px dotted #ff4500;
+    text-decoration: none;
+}
+
+/*.idlMethod*/
+.idlMethType, .idlCallbackType {
+    color:  #005a9c;
+}
+.idlMethName {
+    color:  #ff4500;
+}
+.idlMethName a {
+    color:  #ff4500;
+    border-bottom:  1px dotted #ff4500;
+    text-decoration: none;
+}
+
+/*.idlCtor*/
+.idlCtorName {
+    color:  #ff4500;
+}
+.idlCtorName a {
+    color:  #ff4500;
+    border-bottom:  1px dotted #ff4500;
+    text-decoration: none;
+}
+
+/*.idlParam*/
+.idlParamType {
+    color:  #005a9c;
+}
+.idlParamName, .idlDefaultValue {
+    font-style: italic;
+}
+
+.extAttr {
+    color:  #666;
+}
+
+/*.idlSectionComment*/
+.idlSectionComment {
+    color: gray;
+}
+
+/*.idlConst*/
+.idlConstType {
+    color:  #005a9c;
+}
+.idlConstName {
+    color:  #ff4500;
+}
+.idlConstName a {
+    color:  #ff4500;
+    border-bottom:  1px dotted #ff4500;
+    text-decoration: none;
+}
+
+/*.idlException*/
+.idlExceptionID {
+    font-weight:    bold;
+    color:  #c00;
+}
+
+.idlTypedefID, .idlTypedefType {
+    color:  #005a9c;
+}
+
+.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
+    color:  #c00;
+    font-weight:    normal;
+}
+
+.excName a {
+    font-family:    monospace;
+}
+
+.idlRaises a.idlType, .excName a.idlType {
+    border-bottom:  1px dotted #c00;
+}
+
+.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
+    width:  45px;
+    text-align: center;
+}
+.excGetSetTrue, .prmNullTrue, .prmOptTrue { color:  #0c0; }
+.excGetSetFalse, .prmNullFalse, .prmOptFalse { color:  #c00; }
+
+.idlImplements a {
+    font-weight:    bold;
+}
+
+dl.attributes, dl.methods, dl.constants, dl.constructors, dl.fields, dl.dictionary-members {
+    margin-left:    2em;
+}
+
+.attributes dt, .methods dt, .constants dt, .constructors dt, .fields dt, .dictionary-members dt {
+    font-weight:    normal;
+}
+
+.attributes dt code, .methods dt code, .constants dt code, .constructors dt code, .fields dt code, .dictionary-members dt code {
+    font-weight:    bold;
+    color:  #000;
+    font-family:    monospace;
+}
+
+.attributes dt code, .fields dt code, .dictionary-members dt code {
+    background:  #ffffd2;
+}
+
+.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code {
+    color:  #005a9c;
+    background:  transparent;
+    font-family:    inherit;
+    font-weight:    normal;
+    font-style: italic;
+}
+
+.methods dt code {
+    background:  #d9e6f8;
+}
+
+.constants dt code {
+    background:  #ddffd2;
+}
+
+.constructors dt code {
+    background:  #cfc;
+}
+
+.attributes dd, .methods dd, .constants dd, .constructors dd, .fields dd, .dictionary-members dd {
+    margin-bottom:  1em;
+}
+
+table.parameters, table.exceptions {
+    border-spacing: 0;
+    border-collapse:    collapse;
+    margin: 0.5em 0;
+    width:  100%;
+}
+table.parameters { border-bottom:  1px solid #90b8de; }
+table.exceptions { border-bottom:  1px solid #deb890; }
+
+.parameters th, .exceptions th {
+    color:  #fff;
+    padding:    3px 5px;
+    text-align: left;
+    font-family:    initial;
+    font-weight:    normal;
+    text-shadow:    #666 1px 1px 0;
+}
+.parameters th { background: #90b8de; }
+.exceptions th { background: #deb890; }
+
+.parameters td, .exceptions td {
+    padding:    3px 10px;
+    border-top: 1px solid #ddd;
+    vertical-align: top;
+}
+
+.parameters tr:first-child td, .exceptions tr:first-child td {
+    border-top: none;
+}
+
+.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
+    width:  100px;
+}
+
+.parameters td.prmType {
+    width:  120px;
+}
+
+table.exceptions table {
+    border-spacing: 0;
+    border-collapse:    collapse;
+    width:  100%;
+}
+</style><link href="https://www.w3.org/StyleSheets/TR/W3C-CR" rel="stylesheet"><!--[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
+<body class="h-entry" id="respecDocument" role="document"><div class="head" id="respecHeader" role="contentinfo">
+  <p>
+    
+      <a href="http://www.w3.org/"><img width="72" height="48" alt="W3C" src="https://www.w3.org/Icons/w3c_home"></a>
+    
+  </p>
+  <h1 class="title p-name" id="title" property="dcterms:title">DOM Parsing and Serialization</h1>
+  
+    <h2 id="subtitle" property="bibo:subtitle">DOMParser, XMLSerializer, innerHTML, and similar APIs</h2>
+  
+  <h2 id="w3c-candidate-recommendation-24-june-2014" property="dcterms:issued" content="2014-06-24T07:00:00.000Z" datatype="xsd:dateTime"><abbr title="World Wide Web Consortium">W3C</abbr> Candidate Recommendation <time class="dt-published" datetime="2014-06-24">24 June 2014</time></h2>
+  <dl>
+    
+      <dt>This version:</dt>
+      <dd><a class="u-url" href="http://www.w3.org/TR/2014/CR-DOM-Parsing-20140624/">http://www.w3.org/TR/2014/CR-DOM-Parsing-20140624/</a></dd>
+      <dt>Latest published version:</dt>
+      <dd><a href="http://www.w3.org/TR/DOM-Parsing/">http://www.w3.org/TR/DOM-Parsing/</a></dd>
+    
+    
+      <dt>Latest editor's draft:</dt>
+      <dd><a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html">https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html</a></dd>
+    
+    
+      <dt>Test suite:</dt>
+      <dd><a href="http://w3c-test.org/domparsing/">http://w3c-test.org/domparsing/</a></dd>
+    
+    
+      <dt>Implementation report:</dt>
+      <dd><a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/implementationReport.html">https://dvcs.w3.org/hg/innerhtml/raw-file/tip/implementationReport.html</a></dd>
+    
+    
+    
+    
+      <dt>Previous version:</dt>
+      <dd><a href="http://www.w3.org/TR/2014/WD-DOM-Parsing-20140501/" rel="dcterms:replaces">http://www.w3.org/TR/2014/WD-DOM-Parsing-20140501/</a></dd>
+    
+    
+    <dt>Editor:</dt>
+    <dd class="p-author h-card vcard" inlist="" rel="bibo:editor"><span typeof="foaf:Person"><span class="p-name fn" property="foaf:name">Travis Leithead</span>, <a class="p-org org h-org h-card" href="http://www.microsoft.com" rel="foaf:workplaceHomepage">Microsoft</a>, <span class="ed_mailto"><a class="u-email email" href="mailto:travis.leithead@microsoft.com" rel="foaf:mbox">travis.leithead@microsoft.com</a></span></span>
+</dd>
+
+    
+    
+  </dl>
+  
+  
+  
+  
+    
+      <p class="copyright">
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
+        2014
+        
+        <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+        (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
+        <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
+        <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), 
+        
+        All Rights Reserved.
+        
+        <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
+        
+          <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
+        
+        rules apply.
+      </p>
+    
+  
+  <hr>
+</div>
+
+    <section class="introductory" id="abstract" typeof="bibo:Chapter" property="dcterms:abstract" datatype="" rel="bibo:Chapter" resource="#abstract"><h2 id="h2_abstract" role="heading" aria-level="1">Abstract</h2>
+       <p>This specification defines various APIs for programmatic access to
+          HTML and generic XML parsers by web applications for use in parsing
+          and serializing DOM nodes.</p>
+    </section><section class="introductory" id="sotd" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#sotd"><h2 id="h2_sotd" role="heading" aria-level="1">Status of This Document</h2>
+  
+    
+      
+        <p>
+          <em>This section describes the status of this document at the time of its publication.
+          Other documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the
+          latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a> at
+          http://www.w3.org/TR/.</em>
+        </p>
+        
+        <p>This specification is based on the original work of the <a href="http://domparsing.spec.whatwg.org/">
+            DOM Parsing and Serialization</a> Living Specification, though it has diverged in terms of
+            supported features, normative requirements, and algorithm specificity. As appropriate,
+            relevant fixes from the living specification are incorporated into this document.
+    </p>
+        <p>
+          This document was published by the <a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a> as a Candidate Recommendation.
+          
+            This document is intended to become a <abbr title="World Wide Web Consortium">W3C</abbr> Recommendation.
+          
+          
+            If you wish to make comments regarding this document, please send them to 
+            <a href="mailto:www-dom@w3.org?subject=DOM-Parsing">www-dom@w3.org</a> 
+            (<a href="mailto:www-dom-request@w3.org?subject=subscribe">subscribe</a>,
+            <a href="http://lists.w3.org/Archives/Public/www-dom/">archives</a>)
+              with <code>DOM-Parsing</code> at the start of your email's subject.
+          
+          
+          
+            <abbr title="World Wide Web Consortium">W3C</abbr> publishes a Candidate Recommendation to indicate that the document is believed to be
+            stable and to encourage implementation by the developer community. This Candidate
+            Recommendation is expected to advance to Proposed Recommendation no earlier than
+            24 October 2014.
+          
+          
+            All comments are welcome.
+          
+        </p>
+        
+          <p>
+            Please see the Working Group's  <a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/implementationReport.html">implementation
+            report</a>.
+          </p>
+        
+        
+          <p>
+            Publication as a Candidate Recommendation does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr>
+            Membership. This is a draft document and may be updated, replaced or obsoleted by other
+            documents at any time. It is inappropriate to cite this document as other than work in
+            progress.
+          </p>
+        
+        
+        
+        <p>
+          
+            This document was produced by a group operating under the 
+            <a id="sotd_patent" href="http://www.w3.org/Consortium/Patent-Policy-20040205/" rel="w3p:patentRules" about="">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent
+            Policy</a>.
+          
+          
+          
+            
+              <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent
+              disclosures</a> 
+            
+            made in connection with the deliverables of the group; that page also includes
+            instructions for disclosing a patent. An individual who has actual knowledge of a patent
+            which the individual believes contains
+            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
+            Claim(s)</a> must disclose the information in accordance with
+            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
+            6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
+          
+          
+        </p>
+        
+      
+    
+  
+</section><section id="toc"><h2 class="introductory" id="h2_toc" role="heading" aria-level="1">Table of Contents</h2><ul class="toc" id="respecContents" role="directory"><li class="tocline"><a class="tocxref" href="#conformance"><span class="secno">1. </span>Conformance</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#dependencies"><span class="secno">1.1 </span>Dependencies</a></li><li class="tocline"><a class="tocxref" href="#extensibility"><span class="secno">1.2 </span>Extensibility</a></li></ul></li><li class="tocline"><a class="tocxref" href="#terminology"><span class="secno">2. </span>Terminology</a></li><li class="tocline"><a class="tocxref" href="#namespaces"><span class="secno">3. </span>Namespaces</a></li><li class="tocline"><a class="tocxref" href="#parsing-and-serializing-nodes"><span class="secno">4. </span>Parsing and serializing <span title="node" class="formerLink">Node</span>s</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#parsing"><span class="secno">4.1 </span>Parsing</a></li><li class="tocline"><a class="tocxref" href="#serializing"><span class="secno">4.2 </span>Serializing</a></li></ul></li><li class="tocline"><a class="tocxref" href="#the-domparser-interface"><span class="secno">5. </span>The <code>DOMParser</code> interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#methods"><span class="secno">5.1 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#the-xmlserializer-interface"><span class="secno">6. </span>The <code>XMLSerializer</code> interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#methods-1"><span class="secno">6.1 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#extensions-to-the-element-interface"><span class="secno">7. </span>Extensions to the <code><span title="element" class="formerLink">Element</span></code> interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes"><span class="secno">7.1 </span>Attributes</a></li><li class="tocline"><a class="tocxref" href="#methods-2"><span class="secno">7.2 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#extensions-to-the-range-interface"><span class="secno">8. </span>Extensions to the <code><span title="range" class="formerLink">Range</span></code> interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#methods-3"><span class="secno">8.1 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#revision-history"><span class="secno">A. </span>Revision History</a></li><li class="tocline"><a class="tocxref" href="#acknowledgements"><span class="secno">B. </span>Acknowledgements</a></li><li class="tocline"><a class="tocxref" href="#references"><span class="secno">C. </span>References</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">C.1 </span>Normative references</a></li><li class="tocline"><a class="tocxref" href="#informative-references"><span class="secno">C.2 </span>Informative references</a></li></ul></li></ul></section>
+
+    
+
+    <section class="introductory" id="crec" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#crec">
+        <h2 id="h2_crec" role="heading" aria-level="1">Candidate Recommendation Exit Criteria</h2>
+        <p>This specification will not advance to Proposed Recommendation before the spec's 
+            <a href="http://w3c-test.org/domparsing/">test suite</a> is completed and two or 
+            more independent implementations pass each test, although no single implementation 
+            must pass each test. We expect to meet this criteria no sooner than 24 October 2014.
+            The group will also create an 
+            <a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/implementationReport.html">Implementation Report</a>.
+    </p></section>
+    
+    <!-- <section id="issues" class="introductory">
+        <h1>Issues</h1>
+
+        <p class=issue>Open issues that appear throughout the remainder of this
+        document will be highlighted like this.</p>
+    </section> -->
+
+    <section id="conformance" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#conformance"><!--OddPage--><h2 id="h2_conformance" role="heading" aria-level="1"><span class="secno">1. </span>Conformance</h2>
+<p>
+  As well as sections marked as non-normative, all authoring guidelines, diagrams, examples,
+  and notes in this specification are non-normative. Everything else in this specification is
+  normative.
+</p>
+<p>
+  The key words <em title="MUST" class="rfc2119">MUST</em>, <em title="MUST NOT" class="rfc2119">MUST NOT</em>, <em title="REQUIRED" class="rfc2119">REQUIRED</em>, <em title="SHOULD" class="rfc2119">SHOULD</em>, <em title="SHOULD NOT" class="rfc2119">SHOULD NOT</em>, <em title="RECOMMENDED" class="rfc2119">RECOMMENDED</em>, <em title="MAY" class="rfc2119">MAY</em>,
+  and <em title="OPTIONAL" class="rfc2119">OPTIONAL</em> in this specification are to be interpreted as described in [<cite><a class="bibref" href="#bib-RFC2119">RFC2119</a></cite>].
+</p>
+
+        <p>Requirements phrased in the imperative as part of algorithms
+        (such as "strip any leading space characters" or "return false and
+        terminate these steps") are to be interpreted with the meaning of the
+        key word ("must", "should", "may", etc) used in introducing the
+        algorithm.</p>
+
+        <p>Conformance requirements phrased as algorithms or specific steps
+        may be implemented in any manner, so long as the end result is
+        equivalent. (In particular, the algorithms defined in this
+        specification are intended to be easy to follow, and not intended to
+        be performant.)</p>
+
+        <p id="hardwareLimitations">User agents may impose
+        implementation-specific limits on otherwise unconstrained inputs,
+        e.g. to prevent denial of service attacks, to guard against running
+        out of memory, or to work around platform-specific limitations.</p>
+
+        <p>When a method or an attribute is said to call another method or
+        attribute, the user agent must invoke its internal API for that
+        attribute or method so that e.g. the author can't change the behavior
+        by overriding attributes or methods with custom properties or functions
+        in ECMAScript.</p>
+
+        <p>Unless otherwise stated, string comparisons are done in a <a title="case-sensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#case-sensitive">
+        case-sensitive</a> manner.</p>
+
+        <p>If an algorithm calls into another algorithm, any exception that is
+        thrown by the latter (unless it is explicitly caught), must cause the
+        former to terminate, and the exception to be propagated up to
+        <em>its</em> caller.</p>
+
+        <section id="dependencies">
+            <h3 id="h3_dependencies" role="heading" aria-level="2"><span class="secno">1.1 </span>Dependencies</h3>
+
+            <p>The IDL fragments in this specification must be interpreted as
+            required for conforming IDL fragments, as described in the Web IDL
+            specification. [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]</p>
+
+            <p>Some of the terms used in this specification are defined in
+            [<cite><a class="bibref" href="#bib-DOM4">DOM4</a></cite>], [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>], and [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>].
+        </p></section>
+
+        <section id="extensibility">
+            <h3 id="h3_extensibility" role="heading" aria-level="2"><span class="secno">1.2 </span>Extensibility</h3>
+
+            <p>Vendor-specific proprietary extensions to this specification are
+            strongly discouraged. Authors must not use such extensions, as
+            doing so reduces interoperability and fragments the user base,
+            allowing only users of specific user agents to access the content in
+            question.</p>
+
+            <p>If vendor-specific extensions are needed, the members should be
+            prefixed by vendor-specific strings to prevent clashes with future
+            versions of this specification. Extensions must be defined so that
+            the use of extensions neither contradicts nor causes the
+            non-conformance of functionality defined in the specification.</p>
+
+            <p>When vendor-neutral extensions to this specification are needed,
+            either this specification can be updated accordingly, or an
+            extension specification can be written that overrides the
+            requirements in this specification. When someone applying this
+            specification to their activities decides that they will recognise
+            the requirements of such an extension specification, it becomes an
+            <dfn title="other applicable specifications" id="dfn-other-applicable-specifications">applicable
+            specification</dfn> for the purposes of conformance requirements in
+            this specification.</p>
+            <!-- http://www.w3.org/mid/17E341CD-E790-422C-9F9A-69347EE01CEB@iki.fi -->
+        </section>
+    </section>
+
+    <section id="terminology">
+        <!--OddPage--><h2 id="h2_terminology" role="heading" aria-level="1"><span class="secno">2. </span>Terminology</h2>
+
+        <p>The term <dfn id="dfn-context-object">context object</dfn> means the object on which the method or
+        attribute being discussed was called.
+    </p></section>
+
+    <section id="namespaces">
+        <!--OddPage--><h2 id="h2_namespaces" role="heading" aria-level="1"><span class="secno">3. </span>Namespaces</h2>
+
+        <p>The <dfn title="html-ns" id="dfn-html-ns">HTML namespace</dfn> is <code>http://www.w3.org/1999/xhtml</code>.
+        <p>The <dfn title="xml-ns" id="dfn-xml-ns">XML namespace</dfn> is <code>http://www.w3.org/XML/1998/namespace</code>.
+        <p>The <dfn title="xmlns-ns" id="dfn-xmlns-ns">XMLNS namespace</dfn> is <code>http://www.w3.org/2000/xmlns/</code>.
+    </p></section>
+
+    <section id="parsing-and-serializing-nodes">
+        <!--OddPage--><h2 id="h2_parsing-and-serializing-nodes" role="heading" aria-level="1"><span class="secno">4. </span>Parsing and serializing <a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a>s</h2>
+
+        <section id="parsing">
+            <h3 id="h3_parsing" role="heading" aria-level="2"><span class="secno">4.1 </span>Parsing</h3>
+
+            <p>The following steps form the
+            <dfn title="concept-parse-fragment" id="dfn-concept-parse-fragment">fragment parsing algorithm</dfn>, whose
+            arguments are a <var>markup</var> string and a
+            <var>context element</var>:
+
+            <ol>
+              <li>
+                <p>If the <var>context element</var>'s
+                <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                is an <a title="html-document" class="externalDFN" href="http://www.w3.org/TR/dom/#html-document">HTML document</a>: let
+                <var>algorithm</var> be the
+                <a title="html-fragment-parsing-algorithm" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#html-fragment-parsing-algorithm">HTML
+                fragment parsing algorithm</a>.</p>
+
+                <p>If the <var>context element</var>'s
+                <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                is an <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML document</a>: let
+                <var>algorithm</var> be the
+                <a title="xml-fragment-parsing-algorithm" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#xml-fragment-parsing-algorithm">XML
+                fragment parsing algorithm</a>.</p>
+              </li>
+
+              <li>Let <var>new children</var> be the result of invoking <var>algorithm</var> with <var>markup</var> as
+              the <var>input</var>, and <var>context element</var> as the
+              <var><a title="concept-frag-parse-context" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#concept-frag-parse-context">context</a></var>
+              element.</li>
+
+              <li>Let <var>fragment</var> be a new
+              <code><a title="documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#documentfragment">DocumentFragment</a></code> whose
+              <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+              is <var>context element</var>'s
+              <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>.
+
+              <li><a title="concept-node-append" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-append">Append</a>
+              each <a title="concept-node" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node">node</a> in
+              <var>new children</var> to <var>fragment</var>
+              (in <a title="concept-tree-order" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-order">tree order</a>).
+
+              <div class="note"><div class="note-title" id="h_note_1" role="heading" aria-level="3"><span>Note</span></div><p>This ensures the
+              <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+              for the new <a title="concept-node" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node">nodes</a> is correct.
+
+              </p></div><li>Return the value of <var>fragment</var>.
+            </li></ol>
+    </section>
+
+    <section id="serializing">
+        <h3 id="h3_serializing" role="heading" aria-level="2"><span class="secno">4.2 </span>Serializing</h3>
+        <p>The following steps form the
+            <dfn title="concept-fragment-serializing-algorithm" id="dfn-concept-fragment-serializing-algorithm">fragment serializing algorithm</dfn>,
+            whose arguments are a <code><a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a></code>
+            <var>node</var> and a flag <dfn title="concept-well-formed" id="dfn-concept-well-formed">require well-formed</dfn>:
+
+        <ol>
+            <li>Let <var>context document</var> be the value of <var>node</var>'s
+                <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>.
+            <li>If <var>context document</var> is an
+                <a title="html-document" class="externalDFN" href="http://www.w3.org/TR/dom/#html-document">HTML document</a>,
+                return an <a title="concept-serialize-html" class="internalDFN" href="#dfn-concept-serialize-html">HTML serialization</a> of <var>node</var>.
+            <li>Otherwise, <var>context document</var> is an
+                <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML document</a>;
+                return an <a title="concept-serialize-xml" class="internalDFN" href="#dfn-concept-serialize-xml">XML serialization</a> of <var>node</var>
+                passing the flag <var>require well-formed</var>.
+            <div class="note"><div class="note-title" id="h_note_2" role="heading" aria-level="3"><span>Note</span></div><p>The <a title="concept-serialize-xml" class="internalDFN" href="#dfn-concept-serialize-xml">XML serialization</a> defined in this document
+                conforms to the requirements of the <a title="xml-fragment-serialization-algorithm" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#xml-fragment-serialization-algorithm">XML fragment serialization algorithm</a> defined in [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>].</p></div>
+        </li></ol>
+
+        <p>To produce an <dfn title="concept-serialize-html" id="dfn-concept-serialize-html">HTML serialization</dfn> of a
+            <code><a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a></code> <var>node</var>, the user agent
+            must run the
+            <a title="html-fragment-serialization-algorithm" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#html-fragment-serialization-algorithm">HTML
+            fragment serialization algorithm</a> [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>] on <var>node</var> and return the string produced.
+
+        <p>To produce an <dfn title="concept-serialize-xml" id="dfn-concept-serialize-xml">XML serialization</dfn> of a
+            <code><a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a></code> <var>node</var> given a
+            flag <var>require well-formed</var>, run the following steps:
+        <ol>
+            <li>Let <dfn title="concept-context-namespace" id="dfn-concept-context-namespace">context namespace</dfn> be <code>null</code>.
+                The <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a> is changed when a
+                <var>node</var> serializes a different default namespace definition from its parent. The
+                algorithm assumes no namespace to start.
+            <li>Let <dfn title="concept-namespace-prefix-map" id="dfn-concept-namespace-prefix-map">namespace prefix map</dfn> be a new map
+                for associating <code>namespaceURI</code> and namespace <code>prefix</code> pairs, where
+                <code>namespaceURI</code> values are the map's keys, and <code>prefix</code> values are
+                the map's key values. The <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>
+                will be populated by previously seen namespaceURIs and their most recent prefix associations
+                for a subtree. <span class="note"><strong>Note:</strong> the
+                <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> only associates a single
+                prefix value with a given namespaceURI. During serialization, if different namespace prefixes
+                are found that map to the same namespaceURI, the last one encountered "wins" by replacing the
+                existing key value in the map with the new prefix value.</span>
+            <li>Initialize the <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> with the
+                <a title="xml-ns" class="internalDFN" href="#dfn-xml-ns">XML namespace</a> key and string "<code>xml</code>" as the key value.
+            <li>Let <dfn title="concept-generated-prefix" id="dfn-concept-generated-prefix">generated namespace prefix index</dfn> be an integer
+                with a value of <code>1</code>. The <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace
+                prefix index</a> is used to generate a new unique prefix value when no suitable existing
+                namespace prefix is available to serialize a <var>node</var>'s namespaceURI (or the namespaceURI
+                of one of <var>node</var>'s attributes). <span class="note">See the
+                <a title="concept-generate-prefix" class="internalDFN" href="#dfn-concept-generate-prefix">generate a prefix</a> algorithm.</span>
+            <li>Return the result of running the <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization
+                algorithm</a> on <var>node</var> passing the <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context
+                namespace</a>, <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>,
+                <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a> reference, and the
+                flag <var>require well-formed</var>. If an <dfn title="concept-algorithm-exception" id="dfn-concept-algorithm-exception">exception</dfn>
+                occurs during the execution of the algorithm, then catch that exception and throw a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with
+                name "<code><a title="invalidstateerror" class="externalDFN" href="http://www.w3.org/TR/dom/#invalidstateerror">InvalidStateError</a></code>".
+        </li></ol>
+
+        <p>An <a title="concept-serialize-xml" class="internalDFN" href="#dfn-concept-serialize-xml">XML serialization</a> differs from an
+            <a title="concept-serialize-html" class="internalDFN" href="#dfn-concept-serialize-html">HTML serialization</a> in the following ways:
+        <ul>
+            <li><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Elements</a> and
+                <a title="concept-attribute" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-attribute">attributes</a>
+                will always be serialized such that their namespaceURI is preserved. In some cases
+                this means that an existing prefix, prefix declaration attribute or default namespace
+                declaration attribute might be dropped, substituted or changed.
+                An <a title="concept-serialize-html" class="internalDFN" href="#dfn-concept-serialize-html">HTML serialization</a> does not attempt to
+                preserve the namespaceURI.
+            <li><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Elements</a> not in the
+                <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a> containing no <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">children</a>, are serialized using
+                the self-closing tag syntax (i.e., according to the <code>EmptyElemTag</code>
+                production of [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>]).
+        </li></ul>
+
+        <p>Otherwise, the algorithm for producing an <a title="concept-serialize-xml" class="internalDFN" href="#dfn-concept-serialize-xml">XML serialization</a>
+            is designed to produce a serialization that is compatible with the
+            <a title="html-parser" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#html-parser">HTML parser</a>. For example,
+            elements in the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>closing tag syntax [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>].
+
+        <div class="note"><div class="note-title" id="h_note_3" role="heading" aria-level="3"><span>Note</span></div><p>Per [<cite><a class="bibref" href="#bib-DOM4">DOM4</a></cite>], <code><a title="interface-attr" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-attr">Attr</a></code>
+            objects do not inherit from <code><a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a></code>, and thus cannot
+            be serialized by the <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization algorithm</a>.
+            An attempt to serialize an <code><a title="interface-attr" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-attr">Attr</a></code>
+            object will result in a <code>TypeError</code> exception [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>].
+
+        </p></div><p>To run the <dfn title="concept-xml-serialization-algorithm" id="dfn-concept-xml-serialization-algorithm">XML serialization algorithm</dfn> on
+            a <var>node</var> given a <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a>
+            <var>namespace</var>, a <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>
+            <var>prefix map</var>, a <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a>
+            <var>prefix index</var>, and a flag <var>require well-formed</var>, the user agent must run the
+            appropriate steps, depending on <var>node</var>'s interface:</p>
+
+        <dl class="switch">
+            <dt><code><a title="interface-element" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-element">Element</a></code>
+            <dd>
+                <p>Run the following algorithm:
+                <ol>
+                    <!-- "namespace" was passed via the caller, it's the default namespace scope -->
+                    <!-- "prefix map" was passed via the caller, it's the namespace->prefix map -->
+                    <!-- "prefix index" was passed via the caller, it's a number for generating prefixes if necessary -->
+                    <!-- "require well-formed" was passed via the caller, it's a flag (true/false) for whether certain validation steps should be taken during serialization. -->
+                    <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                        <code>true</code>), and this <var>node</var>'s
+                        <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                        attribute contains the character "<code>:</code>" (U+003A COLON) or does not match the
+                        XML <code>Name</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>], then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an
+                        exception</a>; the serialization of this <var>node</var> would not be a well-formed element.
+                    <li>Let <var>markup</var> be the string "<code>&lt;</code>" (U+003C LESS-THAN SIGN).
+                    <li>Let <var>qualified name</var> be an empty string.
+                    <li>Let a <var>skip end tag</var> flag have the value <code>false</code>.
+                    <li>Let an <var>ignore namespace definition attribute</var> flag have the value <code>false</code>.
+                    <li>Let <var>map</var> be a copy of the <var>prefix map</var>.
+                    <li>Let <var>element prefixes list</var> be an empty list. <span class="note">This list is
+                        local to each element. Its purpose is to ensure that there are no conflicting prefixes
+                        should a new namespace prefix attribute need to be generated.</span>
+                    <li>Let <var>duplicate prefix definition</var> be <code>null</code>.
+                    <li>Let <var>local default namespace</var> be the result of
+                        <a title="concept-record-namespace-info" class="internalDFN" href="#dfn-concept-record-namespace-info">recording the namespace information</a> for
+                        <var>node</var> given <var>map</var>, <var>element prefixes list</var>, and
+                        <var>duplicate prefix definition</var>.
+                    <div class="note"><div class="note-title" id="h_note_4" role="heading" aria-level="3"><span>Note</span></div><p>This above step will update the <var>map</var> with any found namespace prefix
+                        definitions, add the found prefix definitions to the <var>element prefixes list</var>, optionally
+                        set the <var>duplicate prefix definition</var> value, and return a local default namespace
+                        value defined by a default namespace attribute if one exists. Otherwise it returns
+                        <code>null</code>.</p></div>
+                    <li>Let <var>inherited ns</var> be a copy of <var>namespace</var>.
+                    <li>Let <var>ns</var> be the value of <var>node</var>'s
+                        <code><a title="dom-element-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-namespaceuri">namespaceURI</a></code>
+                        attribute.
+                    <li>If <var>inherited ns</var> is equal to <var>ns</var>, then:
+                    <ol>
+                        <li>If <var>local default namespace</var> is not <code>null</code>, then set <var>ignore
+                            namespace definition attribute</var> to <code>true</code>.
+                        <li>If <var>ns</var> is the <a title="xml-ns" class="internalDFN" href="#dfn-xml-ns">XML namespace</a>, then let <var>qualified name</var>
+                            be the concatenation of the string "<code>xml:</code>" and the value of <var>node</var>'s
+                            <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                        <li>Otherwise, let <var>qualified name</var> be the value of <var>node</var>'s
+                            <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                            <span class="note">The <var>node</var>'s prefix is always dropped.</span>
+                        <li>Append the value of <var>qualified name</var> to <var>markup</var>.
+                    </li></ol>
+                    <li>Otherwise, <var>inherited ns</var> is not equal to <var>ns</var> (the <var>node</var>'s
+                        own namespace is different from the context namespace of its parent). Run these sub-steps:
+                    <!-- The serialization algorithm must differentiate this node's namespace from it's parent's default
+                        namespace. There are two ways to do this: (1) [preferred due to assumed minimum length] use a
+                        namespace prefix if one is available or (2) use a default namespace declaration. Both cases can
+                        run into conflicts with existing attributes on the element and are handled accordingly. -->
+                    <ol>
+                        <li>Let <var>prefix</var> be the value of <var>node</var>'s
+                            <code><a title="dom-element-prefix" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-prefix">prefix</a></code>
+                            attribute.
+                        <li>Let <var>candidate prefix</var> be a value from <var>map</var> where there exists a key in
+                            <var>map</var> that matches the value of <var>ns</var> or if there is no such key, then let
+                            <var>candidate prefix</var> be <code>null</code>.
+                        <!-- Found a suitable prefix to use, either locally, or inherited through a parent node that
+                            matches the node's namespaceURI. This prefix will be used in serialization even if the node
+                            doesn't have a real prefix. -->
+                        <li>If <var>candidate prefix</var> is not <code>null</code> (a suitable namespace prefix is defined
+                            which maps to <var>ns</var>), then:
+                        <ol>
+                            <li>Let <var>qualified name</var> be the concatenation of <var>candidate prefix</var>,
+                                "<code>:</code>" (U+003A COLON), and <var>node</var>'s <code>
+                                <a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                                <span class="note">There exists on this <var>node</var> or the <var>node</var>'s ancestry a
+                                namespace prefix definition that defines the <var>node</var>'s namespace.</span>
+                            <li>If <var>local default namespace</var> is not <code>null</code> (there exists a locally-defined
+                                default namespace declaration attribute), then let <var>inherited ns</var> get the value of
+                                <var>ns</var>.
+                            <li>Append the value of <var>qualified name</var> to <var>markup</var>.
+                        </li></ol>
+                        <!-- Now there's no existing namespace->prefix mapping to override; try to use a prefix: -->
+                        <li>Otherwise, if <var>prefix</var> is not <code>null</code> and <var>local default namespace</var> is
+                            <code>null</code>, then:
+                        <ol>
+                            <li>If the <var>element prefixes list</var> contains the value of <var>prefix</var>, then
+                                let <var>prefix</var> be the result of
+                                <a title="concept-generate-prefix" class="internalDFN" href="#dfn-concept-generate-prefix">generating a prefix</a> providing as input the
+                                <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> <var>map</var>,
+                                <var>node</var>'s <var>ns</var> string, and the <var>prefix index</var> integer.
+                            <li>Otherwise, append to <var>map</var> a new key <var>ns</var> whose key value is
+                                <var>prefix</var>.
+                            <!-- Prefix is now either real or generated, and added to the map. -->
+                            <li>Let <var>qualified name</var> be the concatenation
+                            of <var>prefix</var>, "<code>:</code>" (U+003A COLON), and <var>node</var>'s
+                            <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                            <li>Append the value of <var>qualified name</var> to <var>markup</var>.
+                            <li>Append the following to <var>markup</var>, in the order listed: <span class="note">The following
+                                serializes the new namespace/prefix association just added to the <var>map</var>.</span>
+                            <ol>
+                                <li>"<code> </code>" (U+0020 SPACE);
+                                <li>The string "<code>xmlns:</code>";
+                                <li>The value of <var>prefix</var>;
+                                <li>"<code>="</code>" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
+                                <li>The result of <a title="concept-serialize-attr-value" class="internalDFN" href="#dfn-concept-serialize-attr-value">serializing an attribute value</a>
+                                    given <var>ns</var> and the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag
+                                    as input;
+                                <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                            </li></ol>
+                        </li></ol>
+                        <!-- Giving up on the prefix route, try to use a default namespace instead (stomping on an existing
+                             one if necessary) and dropping the node's prefix -->
+                        <li>Otherwise, if <var>local default namespace</var> is <code>null</code>, or <var>local default
+                            namespace</var> is not <code>null</code> and its value is not equal to <var>ns</var>, then:
+                        <ol>
+                            <li>Set the <var>ignore namespace definition attribute</var> flag to <code>true</code>.
+                            <li>Let <var>qualified name</var> be the value of <var>node</var>'s <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                            <li>Let the value of <var>inherited ns</var> be <var>ns</var>. <span class="note">The new
+                                default namespace will be used in the serialization to define this <var>node</var>'s
+                                namespace and act as the context namespace for its <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">children</a>.</span>
+                            <li>Append the value of <var>qualified name</var> to <var>markup</var>.
+                            <li>Append the following to <var>markup</var>, in the order listed: <span class="note">The following
+                                serializes the new (or replacement) default namespace definition.</span>
+                            <ol>
+                                <li>"<code> </code>" (U+0020 SPACE);
+                                <li>The string "<code>xmlns</code>";
+                                <li>"<code>="</code>" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
+                                <li>The result of <a title="concept-serialize-attr-value" class="internalDFN" href="#dfn-concept-serialize-attr-value">serializing an attribute value</a>
+                                    given <var>ns</var> and the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag
+                                    as input;
+                                <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                            </li></ol>
+                        </li></ol>
+                        <!-- Finally, regardless of prefix, the node has a local default namespace that matches 'ns'.
+                            So, we'll just use that and drop the prefix -->
+                        <li>Otherwise, the <var>node</var> has a <var>local default namespace</var> that matches
+                            <var>ns</var>. Let <var>qualified name</var> be the value of <var>node</var>'s
+                            <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>,
+                            let the value of <var>inherited ns</var> be <var>ns</var>, and append the value of
+                            <var>qualified name</var> to <var>markup</var>.
+                    </li></ol>
+                    <li>Append to <var>markup</var> the result of the
+                        <a title="concept-serialize-xml-attributes" class="internalDFN" href="#dfn-concept-serialize-xml-attributes">XML serialization of <var>node</var>'s
+                        attributes</a> given the
+                        <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> <var>map</var>,
+                        the <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated prefix index</a> <var>prefix index</var>, the
+                        flag <var>ignore namespace definition attribute</var> and the value of <var>duplicate
+                        prefix definition</var>.
+                    <li>If <var>ns</var> is the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>,
+                        and the <var>node</var>'s list of
+                        <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">children</a>
+                        is empty, and the <var>node</var>'s
+                        <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                        matches any one of the following
+                        <a title="void-elements" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#void-elements">void elements</a>:
+                        "<code>area</code>",
+                        "<code>base</code>",
+                        "<code>basefont</code>",
+                        "<code>bgsound</code>",
+                        "<code>br</code>",
+                        "<code>col</code>",
+                        "<code>embed</code>",
+                        "<code>frame</code>",
+                        "<code>hr</code>",
+                        "<code>img</code>",
+                        "<code>input</code>",
+                        "<code>keygen</code>",
+                        "<code>link</code>",
+                        "<code>menuitem</code>",
+                        "<code>meta</code>",
+                        "<code>param</code>",
+                        "<code>source</code>",
+                        "<code>track</code>",
+                        "<code>wbr</code>";
+                        then append the following to <var>markup</var>, in the order listed:
+                        <ol>
+                            <li>"<code> </code>" (U+0020 SPACE);
+                            <li>"<code>/</code>" (U+002F SOLIDUS).
+                        </li></ol>
+                        and set the <var>skip end tag</var> flag to <code>true</code>.
+                    <li>If <var>ns</var> is not the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>,
+                        and the <var>node</var>'s list of
+                        <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">children</a>
+                        is empty, then append "<code>/</code>" (U+002F SOLIDUS) to <var>markup</var>
+                        and set the <var>skip end tag</var> flag to <code>true</code>.
+                    <li>Append "<code>&gt;</code>" (U+003E GREATER-THAN SIGN) to <var>markup</var>.
+                    <li>If the value of <var>skip end tag</var> is <code>true</code>, then return
+                        the value of <var>markup</var> and skip the remaining steps. The
+                        <var>node</var> is a leaf-node.
+                    <li>If <var>ns</var> is the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>, and the <var>node</var>'s
+                        <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                        matches the string "<code>template</code>", then this is a
+                        <code><a title="the-template-element" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#the-template-element">template</a></code> element.
+                        Append to <var>markup</var> the result of running the
+                        <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization algorithm</a> on the
+                        <a title="the-template-element" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#the-template-element">template</a> element's
+                        <a title="template-contents" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#template-contents">template contents</a>
+                        (a <code><a title="interface-documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-documentfragment">DocumentFragment</a></code>),
+                        providing the value of <var>inherited ns</var> for the
+                        <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a>,
+                        <var>map</var> for the <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>,
+                        <var>prefix index</var> for the
+                        <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a>, and the value
+                        of the <var>require well-formed</var> flag. <span class="note">This allows
+                        <a title="template-contents" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#template-contents">template content</a> to
+                        round-trip , given the rules for
+                        <a title="parsing-xhtml-documents" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#parsing-xhtml-documents">parsing XHTML documents</a>
+                        [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>].</span>
+                    <li>Otherwise, append to <var>markup</var> the result of running the
+                        <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization algorithm</a> on each
+                        of <var>node</var>'s
+                        <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">children</a>,
+                        in <a title="concept-tree-order" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-order">tree order</a>,
+                        providing the value of <var>inherited ns</var> for the
+                        <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a>,
+                        <var>map</var> for the <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>,
+                        <var>prefix index</var> for the
+                        <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a>, and the value
+                        of the <var>require well-formed</var> flag.
+                    <li>Append the following to <var>markup</var>, in the order listed:
+                        <ol>
+                            <li>"<code>&lt;/</code>" (U+003C LESS-THAN SIGN, U+002F SOLIDUS);
+                            <li>The value of <var>qualified name</var>;
+                            <li>"<code>&gt;</code>" (U+003E GREATER-THAN SIGN).
+                        </li></ol>
+                    <li>Return the value of <var>markup</var>.
+                </li></ol>
+
+            <dt><code><a title="interface-document" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-document">Document</a></code>
+            <dd>
+                <p>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and this <var>node</var> has no
+                    <code><a title="dom-document-documentelement" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-document-documentelement">documentElement</a></code>
+                    (the <code><a title="dom-document-documentelement" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-document-documentelement">documentElement</a></code>
+                    attribute's value is <code>null</code>), then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an
+                    exception</a>; the serialization of this <var>node</var> would not be a well-formed document.
+                <p>Otherwise, run the following steps:
+                <ol>
+                    <li>Let <var>serialized document</var> be an empty string.
+                    <li>Append to <var>serialized document</var> the string produced by running the steps to
+                        <a title="concept-serialize-doctype" class="internalDFN" href="#dfn-concept-serialize-doctype">produce a DocumentType serialization</a>
+                        of <var>node</var>'s
+                        <code><a title="dom-document-doctype" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-document-doctype">doctype</a></code>
+                        attribute provided the <var>require well-formed</var> flag if <var>node</var>'s
+                        <code><a title="dom-document-doctype" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-document-doctype">doctype</a></code>
+                        attribute is not <code>null</code>.
+                    <li>For each <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">child</a>
+                        <var>child</var> of <var>node</var>, in
+                        <a title="concept-tree-order" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-order">tree order</a>, run the
+                        <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization algorithm</a>
+                        on the <var>child</var> given a <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a>
+                        <var>namespace</var>, a <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a>
+                        <var>prefix map</var>, a reference to a <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated
+                        namespace prefix index</a> <var>prefix index</var>, flag <var>require well-formed</var>, and
+                        append the result to <var>serialized document</var>.
+                    <li>Return the value of <var>serialized document</var>.
+                </li></ol>
+
+            <dt><code><a title="interface-comment" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-comment">Comment</a></code>
+            <dd>
+                <p>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    contains characters that are not matched by the XML <code>Char</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>] or
+                    contains "<code>--</code>" (two adjacent U+002D HYPHEN-MINUS characters) or that ends with
+                    a "<code>-</code>" (U+002D HYPHEN-MINUS) character, then
+                    <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization of this
+                    <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    would not be well-formed.
+                <p>Return the concatenation of "<code>&lt;!--</code>", <var>node</var>'s
+                <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>, and
+                "<code>--&gt;</code>".
+
+            <!-- Removing CDATA Serialization steps as this interface type is removed from DOM4:
+            <dt><code><a title="cdata" data-spec="DOML2" class="externalDFN">CDATASection</a></code>
+            <dd><ol>
+                <li>Let <var>markup</var> be the concatenation of "<code>&lt;![CDATA[</code>",
+                    <var>node</var>'s <code><a title="dom-characterdata-data" data-spec="DOM4"
+                    class="externalDFN">data</a></code>, and "<code>]]></code>".
+                <li>Return the value of <var>markup</var>.
+              </ol>
+
+              <p class=note>CDATASection objects may be created by the historical
+            <code>document.createCDATASection</code> API, or as a result of parsing an
+            <a title="xml-document" data-spec="DOM4" class="externalDFN">XML document</a>.
+            -->
+
+            </p><dt><code><a title="interface-text" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-text">Text</a></code>
+            <dd><ol>
+                <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    contains characters that are not matched by the XML <code>Char</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>],
+                    then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization of this
+                    <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    would not be well-formed.
+                <li>Let <var>markup</var> be the value of <var>node</var>'s
+                <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>.
+
+                <li>Replace any occurrences of "<code>&amp;</code>" in <var>markup</var> by
+                "<code>&amp;amp;</code>".
+
+                <li>Replace any occurrences of "<code>&lt;</code>" in <var>markup</var> by
+                "<code>&amp;lt;</code>".
+
+                <li>Replace any occurrences of "<code>&gt;</code>" in <var>markup</var> by
+                "<code>&amp;gt;</code>".
+
+                <li>Return the value of <var>markup</var>.
+              </li></ol>
+            <dt><code><a title="interface-documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-documentfragment">DocumentFragment</a></code>
+            <dd><ol>
+                <li>Let <var>markup</var> the empty string.
+
+                <li>For each <a title="concept-tree-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-child">child</a>
+                    <var>child</var> of <var>node</var>, in
+                    <a title="concept-tree-order" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-order">tree order</a>,
+                    run the <a title="concept-xml-serialization-algorithm" class="internalDFN" href="#dfn-concept-xml-serialization-algorithm">XML serialization algorithm</a>
+                    on the <var>child</var> given
+                    a <a title="concept-context-namespace" class="internalDFN" href="#dfn-concept-context-namespace">context namespace</a> <var>namespace</var>, a
+                    <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> <var>prefix map</var>,
+                    a reference to a <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a>
+                    <var>prefix index</var>, and flag <var>require well-formed</var>. Concatenate the result
+                    to <var>markup</var>.
+                <li>Return the value of <var>markup</var>.
+              </li></ol>
+
+            <dt><code><a title="interface-documenttype" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-documenttype">DocumentType</a></code>
+            <dd>Run the steps to <a title="concept-serialize-doctype" class="internalDFN" href="#dfn-concept-serialize-doctype">produce a DocumentType
+                serialization</a> of <var>node</var> given the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a>
+                flag, and return the string this produced.
+
+            <dt><code><a title="interface-processinginstruction" class="externalDFN" href="http://www.w3.org/TR/dom/#interface-processinginstruction">ProcessingInstruction</a></code>
+            <dd><ol>
+                <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and <var>node</var>'s
+                    <code><a title="dom-processinginstruction-target" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-processinginstruction-target">target</a></code>
+                    contains a "<code>:</code>" (U+003A COLON) character or is an
+                    <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a>
+                    match for the string "<code>xml</code>", then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an
+                    exception</a>; the serialization of this <var>node</var>'s
+                    <code><a title="dom-processinginstruction-target" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-processinginstruction-target">target</a></code>
+                    would not be well-formed.
+                <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    contains characters that are not matched by the XML <code>Char</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>] or
+                    contains the string "<code>?&gt;</code>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN),
+                    then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization of this
+                    <var>node</var>'s
+                    <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>
+                    would not be well-formed.
+                <li>Let <var>markup</var> be the concatenation of the following, in the order listed:
+                <ol>
+                    <li>"<code>&lt;?</code>" (U+003C LESS-THAN SIGN, U+003F QUESTION MARK);
+                    <li>The value of <var>node</var>'s <code><a title="dom-processinginstruction-target" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-processinginstruction-target">target</a></code>;
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>The value of <var>node</var>'s <code><a title="dom-characterdata-data" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-characterdata-data">data</a></code>;
+                    <li>"<code>?&gt;</code>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN).
+                </li></ol>
+                <li>Return the value of <var>markup</var>.
+              </li></ol>
+
+        </dd></dl>
+
+        <p>To <dfn title="concept-serialize-doctype" id="dfn-concept-serialize-doctype">produce a DocumentType serialization</dfn> of a
+            <code><a title="node" class="externalDFN" href="http://www.w3.org/TR/dom/#node">Node</a></code> <var>node</var>, given a
+            <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag, the user agent must return
+            the result of the following algorithm:</p>
+
+        <ol>
+            <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is <code>true</code>
+                and the <var>node</var>'s
+                <code><a title="dom-documenttype-publicid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-publicid">publicId</a></code>
+                attribute contains characters that are not matched by the XML <code>PubidChar</code> production
+                [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>], then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization
+                of this <var>node</var> would not be a well-formed document type declaration.
+            <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is <code>true</code>
+                and the <var>node</var>'s
+                <code><a title="dom-documenttype-systemid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-systemid">systemId</a></code>
+                attribute contains characters that are not matched by the XML <code>Char</code> production
+                [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>] or that contains both a "<code>"</code>" (U+0022 QUOTATION MARK) and a "<code>'</code>"
+                (U+0027 APOSTROPHE), then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the
+                serialization of this <var>node</var> would not be a well-formed document type declaration.
+            <li>Let <var>markup</var> be an empty string.
+            <li>Append the string "<code>&lt;!DOCTYPE</code>" to <var>markup</var>.
+            <li>Append "<code> </code>" (U+0020 SPACE) to <var>markup</var>.
+            <li>Append the value of the <var>node</var>'s
+                <code><a title="dom-documenttype-name" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-name">name</a></code>
+                attribute to <var>markup</var>. For a <var>node</var> belonging to an
+                <a title="html-document" class="externalDFN" href="http://www.w3.org/TR/dom/#html-document">HTML document</a>,
+                the value will be all lowercase.
+            <li>If the <var>node</var>'s
+                <code><a title="dom-documenttype-publicid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-publicid">publicId</a></code>
+                is not the empty string then append the following, in the order listed, to <var>markup</var>:
+                <ol>
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>The string "<code>PUBLIC</code>";
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>"<code>"</code>" (U+0022 QUOTATION MARK);
+                    <li>The value of the <var>node</var>'s
+                        <code><a title="dom-documenttype-publicid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-publicid">publicId</a></code>
+                        attribute;
+                    <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                </li></ol>
+            </li>
+            <li>If the <var>node</var>'s
+                <code><a title="dom-documenttype-systemid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-systemid">systemId</a></code>
+                is not the empty string and the <var>node</var>'s
+                <code><a title="dom-documenttype-publicid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-publicid">publicId</a></code>
+                is set to the empty string, then append the following, in the order listed, to <var>markup</var>:
+                <ol>
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>The string "<code>SYSTEM</code>".
+                </li></ol>
+            </li>
+            <li>If the <var>node</var>'s
+                <code><a title="dom-documenttype-systemid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-systemid">systemId</a></code>
+                is not the empty string then append the following, in the order listed, to <var>markup</var>:
+                <ol>
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>"<code>"</code>" (U+0022 QUOTATION MARK);
+                    <li>The value of the <var>node</var>'s
+                        <code><a title="dom-documenttype-systemid" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-documenttype-systemid">systemId</a></code>
+                        attribute;
+                    <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                </li></ol>
+            </li>
+            <!-- Removing internalSubset serialization steps as this property is not supported by DOM4. Also,
+                optional requirements don't help improve interoperability:
+            <li>Optional: if the <var>node</var> has an (historical)
+                <code><a title="ID-Core-DocType-internalSubset" data-spec="DOM3" class="externalDFN">internalSubset</a></code>
+                and the
+                <code><a title="ID-Core-DocType-internalSubset" data-spec="DOM3" class="externalDFN">internalSubset</a></code>
+                attribute's value is a non-empty string, then append the following,
+                in the order listed, to <var>markup</var>:
+                <ol>
+                    <li>"<code> </code>" (U+0020 SPACE);
+                    <li>"<code>[</code>" (U+005B LEFT SQUARE BRACKET);
+                    <li>The value of the <var>node</var>'s
+                        <code><a title="ID-Core-DocType-internalSubset" data-spec="DOM3" class="externalDFN">internalSubset</a></code>
+                        attribute;
+                    <li>"<code>]</code>" (U+005D RIGHT SQUARE BRACKET);
+                </ol>
+                <p class=note>A <var>node</var> belonging to an
+                   <a title="html-document" data-spec="DOM4" class="externalDFN">HTML document</a>
+                   will never have an
+                   <code><a title="ID-Core-DocType-internalSubset" data-spec="DOM3" class="externalDFN">internalSubset</a></code>
+                   because any <code><a title="ID-Core-DocType-internalSubset" data-spec="DOM3" class="externalDFN">internalSubset</a></code>
+                   markup is ignored by the parser.</p>
+            </li>
+            -->
+            <li>Append "<code>&gt;</code>" (U+003E GREATER-THAN SIGN) to <var>markup</var>.
+            <li>Return the value of <var>markup</var>.
+        </li></ol>
+
+        <p>To <dfn title="concept-record-namespace-info" id="dfn-concept-record-namespace-info">record the namespace information</dfn> for an
+            <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> <var>element</var>, given a
+            <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> <var>map</var>, an
+            <var>element prefixes list</var> (initially empty), and a <var>duplicate prefix
+            definition</var> reference, the user agent must run the following steps:
+        <ol>
+            <li>Let <var>default namespace attr value</var> be <code>null</code>.
+            <li><dfn title="record-namespace-loop" id="dfn-record-namespace-loop">Main</dfn>: For each <a title="concept-attribute" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-attribute">attribute</a>
+                <var>attr</var> in <var>element</var>'s
+                <code><a title="dom-element-attributes" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-attributes">attributes</a></code>,
+                in the order they are specified in the <var>element</var>'s
+                <a title="dom-element-attributes" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-attributes">attribute list</a>:
+
+                <div class="note"><div class="note-title" id="h_note_5" role="heading" aria-level="3"><span>Note</span></div><p>The following conditional steps add namespace prefixes
+                    into the <var>element prefixes list</var> and add or replace them in the <var>map</var>.
+                    Only attributes in the <a title="xmlns-ns" class="internalDFN" href="#dfn-xmlns-ns">XMLNS namespace</a> are
+                    considered (e.g., attributes made to look like namespace declarations via
+                    <code><a title="dom-element-setattribute" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-setattribute">setAttribute</a>(<em>"xmlns:pretend-prefix"</em>,
+                    <em>"pretend-namespace"</em>)</code> are not included).</p></div>
+            <ol>
+                <li>Let <var>attribute namespace</var> be the value of <var>attr</var>'s
+                    <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                    value.
+                <li>Let <var>attribute prefix</var> be the value of <var>attr</var>'s
+                        <code><a title="dom-attr-prefix" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-prefix">prefix</a></code>.
+                <li>If the <var>attribute namespace</var> is the <a title="xmlns-ns" class="internalDFN" href="#dfn-xmlns-ns">XMLNS namespace</a>, then:
+                <ol>
+                    <li>If <var>attribute prefix</var> is <code>null</code>, then <var>attr</var> is a
+                        default namespace declaration. Set the <var>default namespace attr value</var> to
+                        <var>attr</var>'s <code><a title="dom-attr-value" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-value">value</a></code> and stop running these steps, returning to
+                        <a title="record-namespace-loop" class="internalDFN" href="#dfn-record-namespace-loop">Main</a> to visit the next attribute.
+                    <li>Otherwise, the <var>attribute prefix</var> is not <code>null</code> and <var>attr</var>
+                        is a namespace prefix definition. Run the following steps:
+                    <ol>
+                        <li>Let <var>prefix definition</var> be the value of <var>attr</var>'s
+                            <code><a title="dom-attr-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-localname">localName</a></code>.
+                        <li>Let <var>namespace definition</var> be the value of <var>attr</var>'s
+                            <code><a title="dom-attr-value" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-value">value</a></code>.
+                        <li>If a key matching the value of <var>namespace definition</var> already exists in
+                            <var>map</var>, and the key's value matches <var>prefix definition</var>, then
+                            this is a duplicate namespace prefix definition. Set the value of <var>duplicate
+                            prefix definition</var> to <var>prefix definition</var>.
+                        <li>Otherwise, if the key matching the value of <var>namespace definition</var> already
+                            exists in <var>map</var>, but the key's value does not match <var>prefix definition</var>,
+                            then update the key's value to be <var>prefix definition</var>.
+                        <li>Otherwise, no key matching the value of <var>namespace definition</var> exists;
+                            append to <var>map</var> a new key <var>namespace definition</var>
+                            whose key value is the <var>prefix definition</var>.
+                        <li>Append the value of <var>prefix definition</var> to <var>element prefixes list</var>.
+                    </li></ol>
+                </li></ol>
+            </li></ol>
+            <li>Return the value of <var>default namespace attr value</var>.
+        </li></ol>
+
+        <p>To <dfn title="concept-generate-prefix" id="dfn-concept-generate-prefix">generate a prefix</dfn> given a
+            <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix map</a> <var>map</var>, a
+            string <var>new namespace</var>, and a reference to a
+            <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated namespace prefix index</a> <var>prefix
+            index</var>, the user agent must run the following steps:
+        <ol>
+            <li>Let <var>generated prefix</var> be the concatenation of the string "<code>ns</code>" and
+                the current numerical value of <var>prefix index</var>.
+            <li>Let the value of <var>prefix index</var> be incremented by one.
+            <li>Append to <var>map</var> a new key <var>new namespace</var> whose key value is the
+                <var>generated prefix</var>.
+            <li>Return the value of <var>generated prefix</var>.
+        </li></ol>
+
+        <p>The <dfn title="concept-serialize-xml-attributes" id="dfn-concept-serialize-xml-attributes">XML serialization of the attributes</dfn>
+            of an <code><a title="concept-element" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element">Element</a></code>
+            <var>element</var> together with a <a title="concept-namespace-prefix-map" class="internalDFN" href="#dfn-concept-namespace-prefix-map">namespace prefix
+            map</a> <var>map</var>, a <a title="concept-generated-prefix" class="internalDFN" href="#dfn-concept-generated-prefix">generated prefix index</a>
+            <var>prefix index</var> reference, a flag <var>ignore namespace definition attribute</var>, a
+            <var>duplicate prefix definition</var> value, and a flag <var>require well-formed</var>,
+            is the result of the following algorithm:
+        <ol>
+            <li>Let <var>result</var> be the empty string.
+            <li>Let <var>localname set</var> be a new empty
+                <dfn title="concept-namespace-localname-set" id="dfn-concept-namespace-localname-set">namespace localname set</dfn>. This <var>localname
+                set</var> will contain tuples of unique attribute
+                <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                and <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                pairs, and is populated as each <var>attr</var> is processed.
+                <span class="note">This set is used to [optionally] enforce the well-formed constraint that an
+                element cannot have two attributes with the same
+                <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                and <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>.
+                This can occur when two otherwise identical attributes on the same element differ only by their
+                prefix values.</span>
+            <li><dfn title="serialize-attributes-loop" id="dfn-serialize-attributes-loop">Main</dfn>: For each <a title="concept-attribute" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-attribute">attribute</a>
+                <var>attr</var> in <var>element</var>'s
+                <code><a title="dom-element-attributes" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-attributes">attributes</a></code>,
+                in the order they are specified in the <var>element</var>'s
+                <a title="dom-element-attributes" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-attributes">attribute list</a>:
+            <ol>
+                <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and the <var>localname set</var> contains a tuple whose values match those
+                    of a new tuple consisting of <var>attr</var>'s
+                    <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                    attribute and <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                    attribute, then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization of this
+                    <var>attr</var> would fail to produce a well-formed element serialization.
+                <li>Create a new tuple consisting of <var>attr</var>'s
+                    <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                    attribute and <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                    attribute, and add it to the <var>localname set</var>.
+                <li>Let <var>attribute namespace</var> be the value of <var>attr</var>'s
+                    <code><a title="dom-attr-namespaceuri" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-namespaceuri">namespaceURI</a></code>
+                    value.
+                <!-- Check for an unregistered attribute namespace, and if so, serialize a definition for it -->
+                <li>Let <var>candidate prefix</var> be <code>null</code>.
+                <li>If <var>attribute namespace</var> is not <code>null</code>, then run these sub-steps:
+                <ol>
+                    <li>If the value of <var>attribute namespace</var> is the
+                        <a title="xmlns-ns" class="internalDFN" href="#dfn-xmlns-ns">XMLNS namespace</a> and either the <var>attr</var>'s
+                        <code><a title="dom-attr-prefix" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-prefix">prefix</a></code>
+                        is <code>null</code> and the <var>ignore namespace definition
+                        attribute</var> flag is <code>true</code> or the <var>attr</var>'s
+                        <code><a title="dom-attr-prefix" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-prefix">prefix</a></code>
+                        is not <code>null</code> and the <var>attr</var>'s
+                        <code><a title="dom-attr-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-localname">localName</a></code>
+                        matches the value of <var>duplicate prefix definition</var>, then stop running
+                        these steps and goto <a title="serialize-attributes-loop" class="internalDFN" href="#dfn-serialize-attributes-loop">Main</a> to visit the next attribute.
+                    <li>Otherwise, if there exists a key in <var>map</var> that matches the value of <var>attribute
+                        namespace</var>, then let <var>candidate prefix</var> be that key's value from the
+                        <var>map</var>.
+                    <li>Otherwise, there is no key matching <var>attribute namespace</var> in <var>map</var> and
+                        the <var>attribute namespace</var> is not the <a title="xmlns-ns" class="internalDFN" href="#dfn-xmlns-ns">XMLNS namespace</a>.
+                        Run these steps:
+                    <ol>
+                        <li>Let <var>candidate prefix</var> be the result of
+                            <a title="concept-generate-prefix" class="internalDFN" href="#dfn-concept-generate-prefix">generating a prefix</a> providing <var>map</var>,
+                            <var>attribute namespace</var>, and <var>prefix index</var> as input.
+                        <li>Append the following to <var>result</var>, in the order listed:
+                        <ol>
+                            <li>"<code> </code>" (U+0020 SPACE);
+                            <li>The string "<code>xmlns:</code>";
+                            <li>The value of <var>candidate prefix</var>;
+                            <li>"<code>="</code>" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
+                            <li>The result of <a title="concept-serialize-attr-value" class="internalDFN" href="#dfn-concept-serialize-attr-value">serializing an attribute value</a>
+                                given <var>attribute namespace</var> and the
+                                <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag as input;
+                            <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                        </li></ol>
+                    </li></ol>
+                </li></ol>
+                <!-- A namespace prefix has been set by this point if it needed to be set -->
+                <li>Append a "<code> </code>" (U+0020 SPACE) to <var>result</var>.
+                <li>If <var>candidate prefix</var> is not <code>null</code>, then append to <var>result</var>
+                    the concatenation of <var>candidate prefix</var> with "<code>:</code>" (U+003A COLON).
+                <!-- Check for well-formed localName -->
+                <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                    <code>true</code>), and this <var>attr</var>'s
+                    <code><a title="dom-element-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-element-localname">localName</a></code>
+                    attribute contains the character "<code>:</code>" (U+003A COLON) or does not match the XML
+                    <code>Name</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>] or equals "<code>xmlns</code>" and <var>attribute
+                    namespace</var> is <code>null</code>, then <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an
+                    exception</a>; the serialization of this <var>attr</var> would not be a well-formed attribute.
+                <!-- Write out the standard attribute -->
+                <li>Append the following strings to <var>result</var>, in the order listed:
+                <ol>
+                    <li>The value of <var>attr</var>'s
+                        <code><a title="dom-attr-localname" class="externalDFN" href="http://www.w3.org/TR/dom/#dom-attr-localname">localName</a></code>;
+                    <li>"<code>="</code>" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
+                    <li>The result of <a title="concept-serialize-attr-value" class="internalDFN" href="#dfn-concept-serialize-attr-value">serializing an attribute value</a>
+                        given <var>attr</var>'s
+                        <code><a title="concept-attribute-value" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-attribute-value">value</a></code>
+                        attribute and the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag as input;
+                    <li>"<code>"</code>" (U+0022 QUOTATION MARK).
+                </li></ol>
+            </li></ol>
+            <li>Return the value of <var>result</var>.
+        </li></ol>
+
+        <p>To <dfn title="concept-serialize-attr-value" id="dfn-concept-serialize-attr-value">serialize an attribute value</dfn> given an
+            <var>attribute value</var> and <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag,
+            the user agent must run the following steps:
+        <ol>
+            <li>If the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag is set (its value is
+                <code>true</code>), and <var>attribute value</var> contains characters that are not matched
+                by the XML <code>Char</code> production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>], then
+                <a title="concept-algorithm-exception" class="internalDFN" href="#dfn-concept-algorithm-exception">throw an exception</a>; the serialization of this
+                <var>attribute value</var> would fail to produce a well-formed element serialization.
+            <li>If <var>attribute value</var> is <code>null</code>, then return the empty string.
+            <li>Otherwise, <var>attribute value</var> is a string. Return the value of
+                <var>attribute value</var>, first replacing any occurrences of the following:
+            <ol>
+                <li>"<code>"</code>" with "<code>&amp;quot;</code>"
+                <li>"<code>&amp;</code>" with "<code>&amp;amp;</code>"
+                <li>"<code>&lt;</code>" with "<code>&amp;lt;</code>"
+                <li>"<code>&gt;</code>" with "<code>&amp;gt;</code>"
+            </li></ol>
+            <div class="note"><div class="note-title" id="h_note_6" role="heading" aria-level="3"><span>Note</span></div><p>This matches behavior present in browsers, and goes above
+                and beyond the grammar requirement in the XML specification's AttValue
+                production [<cite><a class="bibref" href="#bib-XML10">XML10</a></cite>] by also replacing "<code>&gt;</code>" characters.</p></div>
+        </li></ol>
+    </section>
+</section>
+
+<section id="the-domparser-interface">
+    <!--OddPage--><h2 id="h2_the-domparser-interface" role="heading" aria-level="1"><span class="secno">5. </span>The <code>DOMParser</code> interface</h2>
+
+<pre class="extraidl">enum <span class="idlInterfaceID">SupportedType</span> {
+    "text/html",
+    "text/xml",
+    "application/xml",
+    "application/xhtml+xml",
+    "image/svg+xml"
+};</pre>
+
+    <p>The <dfn title="dom-domparser" id="dfn-dom-domparser"><code>DOMParser()</code></dfn> constructor
+    must return a new <code>DOMParser</code> object.
+
+    <pre class="idl"><span class="idlInterface" id="idl-def-DOMParser">[<span class="extAttr">Constructor</span>]
+interface <span class="idlInterfaceID">DOMParser</span> {
+<span class="idlMethod">    [<span class="extAttr">NewObject</span>]
+    <span class="idlMethType">Document</span> <span class="idlMethName"><a href="#widl-DOMParser-parseFromString-Document-DOMString-str-SupportedType-type">parseFromString</a></span> (<span class="idlParam"><span class="idlParamType">DOMString</span> <span class="idlParamName">str</span></span>, <span class="idlParam"><span class="idlParamType">SupportedType</span> <span class="idlParamName">type</span></span>);</span>
+};</span></pre><section id="methods"><h3 id="h3_methods" role="heading" aria-level="2"><span class="secno">5.1 </span>Methods</h3><dl class="methods"><dt id="widl-DOMParser-parseFromString-Document-DOMString-str-SupportedType-type"><code>parseFromString</code></dt><dd>
+            <p>The
+            <dfn title="dom-domparser-parsefromstring" id="dfn-dom-domparser-parsefromstring"><code>parseFromString(<var>str</var>, <var>type</var>)</code></dfn>
+            method must run these steps, depending on <var>type</var>:
+
+            <dl class="switch">
+                <dt>"<code>text/html</code>"
+                <dd>
+                <p>Parse <var>str</var> with an
+                <code><a title="html-parser" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#html-parser">HTML parser</a></code>, and return the newly
+                created <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a>.
+
+                <p>The <a title="scripting-flag" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#scripting-flag">scripting flag</a> must be set to
+                "disabled".
+
+                <div class="note"><div class="note-title" id="h_note_7" role="heading" aria-level="3"><span>Note</span></div><p><code><a title="meta" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#meta">meta</a></code> elements are not
+                taken into account for the encoding used, as a Unicode stream is passed into
+                the parser.
+
+                </p></div><div class="note"><div class="note-title" id="h_note_8" role="heading" aria-level="3"><span>Note</span></div><p><code><a title="script" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#script">script</a></code> elements get marked
+                unexecutable and the contents of <code><a title="the-noscript-element" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#the-noscript-element">noscript</a></code>
+                get parsed as markup.
+
+                </p></div><dt>"<code>text/xml</code>"
+                <dt>"<code>application/xml</code>"
+                <dt>"<code>application/xhtml+xml</code>"
+                <dt>"<code>image/svg+xml</code>"
+                <dd>
+                <ol>
+                    <li>Parse <var>str</var> with a namespace-enabled
+                    <code><a title="xml-parser" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#xml-parser">XML parser</a></code>.
+
+                    <div class="note"><div class="note-title" id="h_note_9" role="heading" aria-level="3"><span>Note</span></div><p>For all XHTML <code><a title="script" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#script">script</a></code>
+                        elements parsed using the <code><a title="xml-parser" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#xml-parser">XML parser</a></code>,
+                        the equivalent of the <a title="scripting-flag" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#scripting-flag">scripting flag</a> must
+                        be set to "disabled".</p></div>
+
+                    <li>If the previous step didn't return an error, return the newly
+                    created <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a>.
+
+                    <!-- This seemed like a good idea, but isn't web compatible, unfortunately.
+                    <li>Otherwise, throw a
+                    <code><a data-spec="DOM4" title="domexception" class="externalDFN">DOMException</a></code>
+                    with name <code>SyntaxError</code>. -->
+
+                    <li>Let <var>document</var> be a newly-created
+                    <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML Document</a>.
+                    <span class="note">The <var>document</var> will use the
+                    <code><a title="document" class="externalDFN" href="http://www.w3.org/TR/dom/#document">Document</a></code> interface
+                    rather than the <code><a title="xmldocument" class="externalDFN" href="http://www.w3.org/TR/dom/#xmldocument">XMLDocument</a></code>
+                    interface.</span>
+
+                    <li>
+                    <p>Let <var>root</var> be a new
+                    <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code>, with its
+                    <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>
+                    set to "<code>parsererror</code>" and its
+                    <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>
+                    set to
+                    "<code>http://www.mozilla.org/newlayout/xml/parsererror.xml</code>".
+                    <!-- see https://bugzilla.mozilla.org/show_bug.cgi?id=45566 -->
+                    <p>At this point user agents may
+                    <a title="concept-node-append" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-append">append</a> nodes
+                    to <var>root</var>, for example to describe the nature of the
+                    error.
+
+                    </p><li><a title="concept-node-append" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-append">Append</a>
+                    <var>root</var> to <var>document</var>.
+
+                    <li>Return the value of <var>document</var>.
+                </li></ol>
+            </dd></dl>
+
+            <p>In any case, the returned
+            <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a>'s
+            <a title="concept-document-content-type" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document-content-type">content type</a>
+            must be the <var>type</var> argument. Additionally, the
+            <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a> must have a
+            <a title="concept-document-url" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document-url">URL</a> value equal to
+            the URL of the
+            <a title="active-document" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#active-document">active document</a>, a
+            <a title="location" class="externalDFN" href="http://www.w3.org/TR/html5/single-page.html#location">location</a> value of <code>null</code>.
+
+            <div class="note"><div class="note-title" id="h_note_10" role="heading" aria-level="3"><span>Note</span></div><p>The returned
+            <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a>'s
+            <a title="concept-document-encoding" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document-encoding">encoding</a> is
+            the default, UTF-8.
+        </p></div><table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">str</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr><tr><td class="prmName">type</td><td class="prmType"><code>SupportedType</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><code>Document</code></div></dd></dl></section>
+</section>
+
+<section id="the-xmlserializer-interface">
+    <!--OddPage--><h2 id="h2_the-xmlserializer-interface" role="heading" aria-level="1"><span class="secno">6. </span>The <code>XMLSerializer</code> interface</h2>
+
+    <p>The <dfn title="dom-xmlserializer" id="dfn-dom-xmlserializer"><code>XMLSerializer()</code></dfn>
+    constructor must return a new <code>XMLSerializer</code> object.
+
+    <pre class="idl"><span class="idlInterface" id="idl-def-XMLSerializer">[<span class="extAttr">Constructor</span>]
+interface <span class="idlInterfaceID">XMLSerializer</span> {
+<span class="idlMethod">    <span class="idlMethType">DOMString</span> <span class="idlMethName"><a href="#widl-XMLSerializer-serializeToString-DOMString-Node-root">serializeToString</a></span> (<span class="idlParam"><span class="idlParamType">Node</span> <span class="idlParamName">root</span></span>);</span>
+};</span></pre><section id="methods-1"><h3 id="h3_methods-1" role="heading" aria-level="2"><span class="secno">6.1 </span>Methods</h3><dl class="methods"><dt id="widl-XMLSerializer-serializeToString-DOMString-Node-root"><code>serializeToString</code></dt><dd>The <dfn title="dom-xmlserializer-serializetostring" id="dfn-dom-xmlserializer-serializetostring"><code>serializeToString(<var>root</var>)</code></dfn>
+        method must <a title="concept-serialize-xml" class="internalDFN" href="#dfn-concept-serialize-xml">produce an XML serialization</a> of <var>root</var> passing
+        a value of <code>false</code> for the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> parameter, and return the result.<table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">root</td><td class="prmType"><code>Node</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><code>DOMString</code></div></dd></dl></section>
+</section>
+
+<section id="extensions-to-the-element-interface">
+    <!--OddPage--><h2 id="h2_extensions-to-the-element-interface" role="heading" aria-level="1"><span class="secno">7. </span>Extensions to the <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> interface</h2>
+
+    <pre class="idl"><span class="idlInterface" id="idl-def-Element">partial interface <span class="idlInterfaceID">Element</span> {
+<span class="idlAttribute">    [<span class="extAttr">TreatNullAs=EmptyString</span>]
+                attribute <span class="idlAttrType">DOMString</span> <span class="idlAttrName"><a href="#widl-Element-innerHTML">innerHTML</a></span>;</span>
+<span class="idlAttribute">    [<span class="extAttr">TreatNullAs=EmptyString</span>]
+                attribute <span class="idlAttrType">DOMString</span> <span class="idlAttrName"><a href="#widl-Element-outerHTML">outerHTML</a></span>;</span>
+<span class="idlMethod">    <span class="idlMethType">void</span> <span class="idlMethName"><a href="#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMString-text">insertAdjacentHTML</a></span> (<span class="idlParam"><span class="idlParamType">DOMString</span> <span class="idlParamName">position</span></span>, <span class="idlParam"><span class="idlParamType">DOMString</span> <span class="idlParamName">text</span></span>);</span>
+};</span></pre><section id="attributes"><h3 id="h3_attributes" role="heading" aria-level="2"><span class="secno">7.1 </span>Attributes</h3><dl class="attributes"><dt id="widl-Element-innerHTML"><code>innerHTML</code> of type <span class="idlAttrType">DOMString</span>,            </dt><dd>
+            <p>The <dfn title="dom-element-innerhtml" id="dfn-dom-element-innerhtml"><code>innerHTML</code></dfn> IDL
+            attribute represents the markup of the
+            <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code>'s contents.
+
+            <dl class="domintro">
+                <!--doc.ih
+                <dt><var>document</var> . <code title="dom-document-innerhtml">innerHTML</code> [ = <var>value</var> ]
+                <dd>
+                <p>Returns a fragment of HTML or XML that represents the
+                <code><a title="document" data-spec="DOM4" class="externalDFN">Document</a></code>.
+
+                <p>Can be set, to replace the
+                <code><a title="document" data-spec="DOM4" class="externalDFN">Document</a></code>'s contents with the result of
+                parsing the given string.
+
+                <p>In the case of an <a title="xml-document" data-spec="DOM4" class="externalDFN">XML document</a>,
+                will throw an
+                <code><a data-spec="DOM4" title="domexception" class="externalDFN">DOMException</a></code> with name <code>InvalidStateError</code>
+                if the <code><a title="document" data-spec="DOM4" class="externalDFN">Document</a></code> cannot be serialized
+                to XML, and a
+                <code><a data-spec="DOM4" title="domexception" class="externalDFN">DOMException</a></code> with name <code>SyntaxError</code>
+                if the given string is not well-formed.
+                -->
+
+                <dt><var>element</var> . <code title="dom-element-innerhtml">innerHTML</code> [ = <var>value</var> ]
+                <dd>
+                <p>Returns a fragment of HTML or XML that represents the element's
+                contents.
+
+                <p>Can be set, to replace the contents of the element with nodes
+                parsed from the given string.
+
+                <p>In the case of an <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML document</a>,
+                will throw a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="invalidstateerror" class="externalDFN" href="http://www.w3.org/TR/dom/#invalidstateerror">InvalidStateError</a></code>"
+                if the <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> cannot be serialized
+                to XML, and a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="syntaxerror" class="externalDFN" href="http://www.w3.org/TR/dom/#syntaxerror">SyntaxError</a></code>"
+                if the given string is not well-formed.
+            </p></dd></dl>
+
+            <p>On getting, return the result of invoking the
+                <a title="concept-fragment-serializing-algorithm" class="internalDFN" href="#dfn-concept-fragment-serializing-algorithm">fragment serializing algorithm</a> on the
+                <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a> providing <code>true</code> for the
+                <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a> flag (this might throw an exception
+                instead of returning a string).
+
+            <p>On setting, these steps must be run:
+            <ol>
+                <li>Let <var>fragment</var> be the result of invoking the
+                <a title="concept-parse-fragment" class="internalDFN" href="#dfn-concept-parse-fragment">fragment parsing algorithm</a> with
+                the new value as <var>markup</var>, and the
+                <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a> as the <var>context element</var>.
+
+                <li><a title="concept-node-replace-all" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-replace-all">Replace all</a>
+                with <var>fragment</var> within the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>.
+            </li></ol>
+        </dd><dt id="widl-Element-outerHTML"><code>outerHTML</code> of type <span class="idlAttrType">DOMString</span>,            </dt><dd>
+            <p>The <dfn title="dom-element-outerhtml" id="dfn-dom-element-outerhtml"><code>outerHTML</code></dfn> IDL
+            attribute represents the markup of the
+            <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> and its contents.
+
+            <dl class="domintro">
+              <dt><var>element</var> . <code title="dom-element-outerhtml">outerHTML</code> [ = <var>value</var> ]
+              <dd>
+                <p>Returns a fragment of HTML or XML that represents the element and its
+                contents.
+
+                <p>Can be set, to replace the element with nodes parsed from the given
+                string.
+
+                <p>In the case of an <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML document</a>,
+                will throw a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="invalidstateerror" class="externalDFN" href="http://www.w3.org/TR/dom/#invalidstateerror">InvalidStateError</a></code>"
+                if the element cannot be serialized to XML, and a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="syntaxerror" class="externalDFN" href="http://www.w3.org/TR/dom/#syntaxerror">SyntaxError</a></code>"
+                if the given string is not well-formed.
+
+                <p>Throws a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="nomodificationallowederror" class="externalDFN" href="http://www.w3.org/TR/dom/#nomodificationallowederror">NoModificationAllowedError</a></code>"
+                if the parent of the element is the
+                <code><a title="document" class="externalDFN" href="http://www.w3.org/TR/dom/#document">Document</a></code> node.
+            </p></dd></dl>
+
+            <p>On getting, return the result of invoking the
+                <a title="concept-fragment-serializing-algorithm" class="internalDFN" href="#dfn-concept-fragment-serializing-algorithm">fragment serializing algorithm</a> on a
+                fictional node whose only child is the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>
+                providing <code>true</code> for the <a title="concept-well-formed" class="internalDFN" href="#dfn-concept-well-formed">require well-formed</a>
+                flag (this might throw an exception instead of returning a string).
+
+            <p>On setting, the following steps must be run:
+
+            <ol>
+                <li>Let <var>parent</var> be the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                <a title="concept-tree-parent" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-parent">parent</a>.
+
+                <li>If <var>parent</var> is null, terminate these steps. There would be no
+                way to obtain a reference to the nodes created even if the remaining steps
+                were run.
+
+                <li>If <var>parent</var> is a
+                <code><a title="document" class="externalDFN" href="http://www.w3.org/TR/dom/#document">Document</a></code>, throw a
+                <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                "<code><a title="nomodificationallowederror" class="externalDFN" href="http://www.w3.org/TR/dom/#nomodificationallowederror">NoModificationAllowedError</a></code>"
+                exception.
+
+                <li>If <var>parent</var> is a
+                <code><a title="documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#documentfragment">DocumentFragment</a></code>, let
+                <var>parent</var> be a new
+                <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> with
+
+                <ul>
+                    <li><code>body</code> as its
+                    <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>,
+
+                    <li>The <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a> as its
+                    <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>, and
+                    <li>The <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                    <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                    as its
+                    <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>.
+                </li></ul>
+
+                <li>Let <var>fragment</var> be the result of invoking the
+                <a title="concept-parse-fragment" class="internalDFN" href="#dfn-concept-parse-fragment">fragment parsing algorithm</a> with
+                the new value as <var>markup</var>, and <var>parent</var> as
+                the <var>context element</var>.
+
+                <li><a title="concept-node-replace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-replace">Replace</a>
+                the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a> with <var>fragment</var> within
+                the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                <a title="concept-tree-parent" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-parent">parent</a>.
+            </li></ol>
+        </dd></dl></section><section id="methods-2"><h3 id="h3_methods-2" role="heading" aria-level="2"><span class="secno">7.2 </span>Methods</h3><dl class="methods"><dt id="widl-Element-insertAdjacentHTML-void-DOMString-position-DOMString-text"><code>insertAdjacentHTML</code></dt><dd>
+             <dl class="domintro">
+                  <dt><var>element</var> . <code title="dom-element-insertadjacenthtml">insertAdjacentHTML</code>(<var>position</var>, <var>text</var>)
+
+                  <dd>
+                    <p>Parses the given string <var>text</var> as HTML or XML and inserts
+                    the resulting nodes into the tree in the position given by the
+                    <var>position</var> argument, as follows:
+
+                    <dl>
+                      <dt>"beforebegin"
+                      <dd>Before the element itself.
+
+                      <dt>"afterbegin"
+                      <dd>Just inside the element, before its first child.
+
+                      <dt>"beforeend"
+                      <dd>Just inside the element, after its last child.
+
+                      <dt>"afterend"
+                      <dd>After the element itself.
+                    </dd></dl>
+
+                    <p>Throws a <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                    "<code><a title="syntaxerror" class="externalDFN" href="http://www.w3.org/TR/dom/#syntaxerror">SyntaxError</a></code>"
+                    if the arguments have invalid values (e.g., in the case of an
+                    <a title="xml-document" class="externalDFN" href="http://www.w3.org/TR/dom/#xml-document">XML document</a>, if the given string is
+                    not well-formed).
+
+                    <p>Throws a
+                    <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                    "<code><a title="nomodificationallowederror" class="externalDFN" href="http://www.w3.org/TR/dom/#nomodificationallowederror">NoModificationAllowedError</a></code>"
+                    if the given position isn't possible (e.g. inserting elements
+                    after the root element of a <code><a title="document" class="externalDFN" href="http://www.w3.org/TR/dom/#document">Document</a></code>).
+                </p></dd></dl>
+
+                <p>The
+                <dfn title="dom-element-insertadjacenthtml" id="dfn-dom-element-insertadjacenthtml"><code>insertAdjacentHTML(<var>position</var>, <var>text</var>)</code></dfn>
+                method must run these steps:
+
+                <ol>
+                    <li>Use the first matching item from this list:
+
+                    <dl class="switch">
+                        <dt>If <var>position</var> is an
+                        <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                        the string "beforebegin"
+
+                        <dt>If <var>position</var> is an
+                        <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                        the string "afterend"
+
+                        <dd>
+                            <p>Let <var>context</var> be the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                            <a title="concept-tree-parent" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-parent">parent</a>.
+
+                            <p>If <var>context</var> is null or a
+                            <a title="concept-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-document">document</a>, throw
+                            a
+                            <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code> with name
+                            "<code><a title="nomodificationallowederror" class="externalDFN" href="http://www.w3.org/TR/dom/#nomodificationallowederror">NoModificationAllowedError</a></code>".
+
+                        </p><dt>If <var>position</var> is an
+                        <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                        the string "afterbegin"
+
+                        <dt>If <var>position</var> is an
+                        <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                        the string "beforeend"
+
+                        <dd>Let <var>context</var> be the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>.
+
+                        <dt>Otherwise
+                        <dd>
+                            <p>Throw a <code><a title="domexception" class="externalDFN" href="http://www.w3.org/TR/dom/#domexception">DOMException</a></code>
+                            with name "<code><a title="syntaxerror" class="externalDFN" href="http://www.w3.org/TR/dom/#syntaxerror">SyntaxError</a></code>".
+                    </p></dd></dl>
+
+                  <li>If <var>context</var> is not an
+                    <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> or the following are all true:
+
+                    <ul>
+                      <li><var>context</var>'s
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                      is an <a title="html-document" class="externalDFN" href="http://www.w3.org/TR/dom/#html-document">HTML document</a>,
+
+                      <li><var>context</var>'s
+                      <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>
+                      is "<code>html</code>", and
+
+                      <li><var>context</var>'s
+                      <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>
+                      is the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>;
+                    </li></ul>
+
+                    <p>let <var>context</var> be a new
+                    <code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code> with
+
+                    <ul>
+                      <li><code>body</code> as its
+                      <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>,
+
+                      <li>The <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a> as its
+                      <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>, and
+
+                      <li>The <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                      as its
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>.
+                    </li></ul>
+
+                <li>Let <var>fragment</var> be the result of invoking the
+                <a title="concept-parse-fragment" class="internalDFN" href="#dfn-concept-parse-fragment">fragment parsing algorithm</a> with <var>text</var> as
+                <var>markup</var>, and <var>context</var> as the <var>context element</var>.
+
+                <li>Use the first matching item from this list:
+
+                <dl class="switch">
+                    <dt>If <var>position</var> is an
+                    <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                    the string "beforebegin"
+
+                    <dd><a title="concept-node-insert" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-insert">Insert</a>
+                    <var>fragment</var> into the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                    <a title="concept-tree-parent" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-parent">parent</a>
+                    before the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>.
+
+                    <dt>If <var>position</var> is an
+                    <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                    the string "afterbegin"
+
+                    <dd><a title="concept-node-insert" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-insert">Insert</a>
+                    <var>fragment</var> into the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>
+                    before its
+                    <a title="concept-tree-first-child" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-first-child">first child</a>.
+
+                    <dt>If <var>position</var> is an
+                    <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                    the string "beforeend"
+
+                    <dd><a title="concept-node-append" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-append">Append</a>
+                    <var>fragment</var> to the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>.
+
+                    <dt>If <var>position</var> is an
+                    <a title="ascii-case-insensitive" class="externalDFN" href="http://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a> match for
+                    the string "afterend"
+
+                    <dd><a title="concept-node-insert" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-insert">Insert</a>
+                    <var>fragment</var> into the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                    <a title="concept-tree-parent" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-parent">parent</a>
+                    before the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                    <a title="concept-tree-next-sibling" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-tree-next-sibling">next sibling</a>.
+                </dd></dl>
+            </li></ol>
+        <table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">position</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr><tr><td class="prmName">text</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><code>void</code></div></dd></dl></section>
+</section>
+
+<!-- Dropping this extention as it is not implemented, nor does it appear that any browser
+     is currently interested in supporting it. Perhaps it can come back in a V2 of this spec
+     if browsers become interested.
+<section>
+    <h1>Extensions to the <code><a title="text" data-spec="DOM4" class="externalDFN">Text</a></code> interface</h1>
+
+    <dl class="idl" title="partial interface Text">
+        <dt>attribute boolean serializeAsCDATA</dt>
+        <dd>
+            <dl class=domintro>
+              <dt><var>text</var> .
+                  <code title="dom-text-serializeascdata">serializeAsCDATA</code> [ = <var>value</var> ]
+              <dd>Controls whether, in XML, this node is serialized as a CDATA section.
+            </dl>
+
+            <p><code><a title="text" data-spec="DOM4" class="externalDFN">Text</a></code> nodes have an additional
+            associated flag, the <dfn>serialize as CDATA flag</dfn>.
+
+            <p>The
+            <dfn title="dom-text-serializeascdata"><code>serializeAsCDATA</code></dfn>
+            attribute must return true if the <a title="context object">context object</a> has its
+            <a>serialize as CDATA flag</a> set, or false otherwise.
+
+            <p>Setting the <code title="dom-text-serializeascdata">serializeAsCDATA</code>
+            attribute must, if the new value is true, set the
+            <a title="context object">context object</a>'s <a>serialize as CDATA flag</a>, or unset
+            it otherwise.
+        </dd>
+    </dl>
+</section>
+-->
+
+<section id="extensions-to-the-range-interface">
+    <!--OddPage--><h2 id="h2_extensions-to-the-range-interface" role="heading" aria-level="1"><span class="secno">8. </span>Extensions to the <code><a title="range" class="externalDFN" href="http://www.w3.org/TR/dom/#range">Range</a></code> interface</h2>
+
+    <pre class="idl"><span class="idlInterface" id="idl-def-Range">partial interface <span class="idlInterfaceID">Range</span> {
+<span class="idlMethod">    [<span class="extAttr">NewObject</span>]
+    <span class="idlMethType">DocumentFragment</span> <span class="idlMethName"><a href="#widl-Range-createContextualFragment-DocumentFragment-DOMString-fragment">createContextualFragment</a></span> (<span class="idlParam"><span class="idlParamType">DOMString</span> <span class="idlParamName">fragment</span></span>);</span>
+};</span></pre><section id="methods-3"><h3 id="h3_methods-3" role="heading" aria-level="2"><span class="secno">8.1 </span>Methods</h3><dl class="methods"><dt id="widl-Range-createContextualFragment-DocumentFragment-DOMString-fragment"><code>createContextualFragment</code></dt><dd>
+            <dl class="domintro">
+              <dt><var>docFragment</var> = <var>range</var> . <code title="dom-range-createcontextualfragment">createContextualFragment</code>(<var>markupString</var>)
+              <dd>Returns a <code><a title="documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#documentfragment">DocumentFragment</a></code>, created
+                from the markup string given.
+            </dd></dl>
+
+            <p>The
+            <dfn title="dom-range-createcontextualfragment" id="dfn-dom-range-createcontextualfragment"><code>createContextualFragment(<var>fragment</var>)</code></dfn>
+            method must run these steps:
+
+            <ol>
+                <li>Let <var>node</var> be the <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                <a title="concept-range-start-node" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-range-start-node">start node</a>.
+
+                <p>Let <var>element</var> be as follows, depending on <var>node</var>'s interface:
+
+                <dl class="switch">
+                    <dt><code><a title="document" class="externalDFN" href="http://www.w3.org/TR/dom/#document">Document</a></code>
+                    <dt><code><a title="documentfragment" class="externalDFN" href="http://www.w3.org/TR/dom/#documentfragment">DocumentFragment</a></code>
+                    <dd>null
+
+                    <dt><code><a title="element" class="externalDFN" href="http://www.w3.org/TR/dom/#element">Element</a></code>
+                    <dd><var>node</var>
+
+                    <dt><code><a title="text" class="externalDFN" href="http://www.w3.org/TR/dom/#text">Text</a></code>
+                    <dt><code><a title="comment" class="externalDFN" href="http://www.w3.org/TR/dom/#comment">Comment</a></code>
+                    <dd><var>node</var>'s
+                    <a title="parent-element" class="externalDFN" href="http://www.w3.org/TR/dom/#parent-element">parent element</a>
+
+                    <dt><code><a title="documenttype" class="externalDFN" href="http://www.w3.org/TR/dom/#documenttype">DocumentType</a></code>
+                    <dt><code><a title="processinginstruction" class="externalDFN" href="http://www.w3.org/TR/dom/#processinginstruction">ProcessingInstruction</a></code>
+                    <dd>[<cite><a class="bibref" href="#bib-DOM4">DOM4</a></cite>] prevents this case.
+                </dd></dl>
+
+                <li>If either <var>element</var> is null or the following are all true:
+
+                    <ul>
+                      <li><var>element</var>'s
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                      is an <a title="html-document" class="externalDFN" href="http://www.w3.org/TR/dom/#html-document">HTML document</a>,
+
+                      <li><var>element</var>'s
+                      <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>
+                      is "<code>html</code>", and
+
+                      <li><var>element</var>'s
+                      <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>
+                      is the <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a>;
+                    </li></ul>
+
+                    <p>let <var>element</var> be a new
+                    <a title="concept-element" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element">element</a> with
+
+                    <ul>
+                      <li>"<code>body</code>" as its
+                      <a title="concept-element-local-name" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-local-name">local name</a>,
+
+                      <li>The <a title="html-ns" class="internalDFN" href="#dfn-html-ns">HTML namespace</a> as its
+                      <a title="concept-element-namespace" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-element-namespace">namespace</a>, and
+
+                      <li>The <a title="context object" class="internalDFN" href="#dfn-context-object">context object</a>'s
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>
+                      as its
+                      <a title="concept-node-document" class="externalDFN" href="http://www.w3.org/TR/dom/#concept-node-document">node document</a>.
+                    </li></ul>
+
+                <li>Let <var>fragment node</var> be the result of invoking the
+                <a title="concept-parse-fragment" class="internalDFN" href="#dfn-concept-parse-fragment">fragment parsing algorithm</a> with <var>fragment</var> as
+                <var>markup</var>, and <var>element</var> as the <var>context element</var>.
+
+                <li>Unmark all scripts in <var>fragment node</var> as "already started".
+
+                <li>Return the value of <var>fragment node</var>.
+            </li></ol>
+        <table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">fragment</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><code>DocumentFragment</code></div></dd></dl></section>
+</section>
+
+<section class="appendix" id="revision-history">
+    <!--OddPage--><h2 id="h2_revision-history" role="heading" aria-level="1"><span class="secno">A. </span>Revision History</h2>
+    <p>The following is an informative summary of the changes since the last publication of this 
+        specification. A complete revision history of the Editor's Drafts of this specification 
+        can be found <a href="https://dvcs.w3.org/hg/innerhtml/summary/">here</a>.</p>
+    
+    <ul>
+       <li><a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/LC2_comments.html">Incorporated 
+        non-normative changes from previous Last Call document.</a>
+    </li></ul>
+</section>
+
+<section class="appendix" id="acknowledgements">
+    <!--OddPage--><h2 id="h2_acknowledgements" role="heading" aria-level="1"><span class="secno">B. </span>Acknowledgements</h2>
+    <p>Thanks to Ms2ger [<a href="http://www.mozilla.org">Mozilla</a>] for maintaining the initial
+       drafts of this specification and for its continued improvement in the
+       <a href="http://domparsing.spec.whatwg.org/">Living Specification</a>.
+
+    <p>Thanks to
+        Victor Costan,
+        Aryeh Gregor,
+        Anne van Kesteren,
+        Arkadiusz Michalski,
+        Simon Pieters,
+        Henri Sivonen,
+        Josh Soref
+        and Boris Zbarsky,
+        for their useful comments.
+
+    <p>Special thanks to Ian Hickson for defining the
+    <code title="dom-element-innerhtml">innerHTML</code> and
+    <code title="dom-element-outerhtml">outerHTML</code> attributes, and the
+    <code title="dom-element-insertadjacenthtml">insertAdjacentHTML()</code> method in
+    [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>] and his useful comments.
+</p></section>
+
+<section class="appendix" id="references" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#references"><!--OddPage--><h2 id="h2_references" role="heading" aria-level="1"><span class="secno">C. </span>References</h2><section id="normative-references" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#normative-references"><h3 id="h3_normative-references" role="heading" aria-level="2"><span class="secno">C.1 </span>Normative references</h3><dl class="bibliography" about=""><dt id="bib-HTML5">[HTML5]</dt><dd rel="dcterms:requires">Robin Berjon; Steve Faulkner; Travis Leithead; Erika Doyle Navara; Edward O'Connor; Silvia Pfeiffer. <a href="http://www.w3.org/TR/html5/"><cite>HTML5</cite></a>. 29 April 2014. W3C Candidate Recommendation. URL: <a href="http://www.w3.org/TR/html5/">http://www.w3.org/TR/html5/</a>
+</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd rel="dcterms:requires">S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119.  URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a> 
+</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd rel="dcterms:requires">Cameron McCormack. <a href="http://www.w3.org/TR/WebIDL/"><cite>Web IDL</cite></a>. 19 April 2012. W3C Candidate Recommendation. URL: <a href="http://www.w3.org/TR/WebIDL/">http://www.w3.org/TR/WebIDL/</a>
+</dd></dl></section><section id="informative-references" typeof="bibo:Chapter" rel="bibo:Chapter" resource="#informative-references"><h3 id="h3_informative-references" role="heading" aria-level="2"><span class="secno">C.2 </span>Informative references</h3><dl class="bibliography" about=""><dt id="bib-DOM4">[DOM4]</dt><dd rel="dcterms:references">Anne van Kesteren; Aryeh Gregor; Ms2ger; Alex Russell; Robin Berjon. <a href="http://www.w3.org/TR/dom/"><cite>W3C DOM4</cite></a>. 8 May 2014. W3C Candidate Recommendation. URL: <a href="http://www.w3.org/TR/dom/">http://www.w3.org/TR/dom/</a>
+</dd><dt id="bib-XML10">[XML10]</dt><dd rel="dcterms:references">Tim Bray; Jean Paoli; Michael Sperberg-McQueen; Eve Maler; François Yergeau et al. <a href="http://www.w3.org/TR/xml"><cite>Extensible Markup Language (XML) 1.0 (Fifth Edition)</cite></a>. 26 November 2008. W3C Recommendation. URL: <a href="http://www.w3.org/TR/xml">http://www.w3.org/TR/xml</a>
+</dd></dl></section></section></body></html>
\ No newline at end of file