<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25225</bug_id>
          
          <creation_ts>2014-04-02 02:47:11 +0000</creation_ts>
          <short_desc>No way to convert between XML and HTML documents</short_desc>
          <delta_ts>2014-12-01 18:32:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM Parsing and Serialization</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="C. Scott Ananian">w3</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>annevk</cc>
    
    <cc>dtrebbien</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps-bugzilla</cc>
    
    <cc>www-dom</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>103258</commentid>
    <comment_count>0</comment_count>
    <who name="C. Scott Ananian">w3</who>
    <bug_when>2014-04-02 02:47:11 +0000</bug_when>
    <thetext>outerHTML on an XML document is defined as an XML serialization, and outerHTML on an HTML document is defined as an HTML serialization.

You can use the XMLSerializer interface to get an XML serialization of an HTML document, but there is no equivalent way to get an HTML serialization of an XML document.

Additionally/alternatively, it would be nice if you could just clone an XML document from an HTML document and vice-versa, without having to go through a string serialization.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103268</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-04-02 09:48:43 +0000</bug_when>
    <thetext>What&apos;s the use case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103279</commentid>
    <comment_count>2</comment_count>
    <who name="C. Scott Ananian">w3</who>
    <bug_when>2014-04-02 15:59:20 +0000</bug_when>
    <thetext>See https://www.w3.org/Bugs/Public/show_bug.cgi?id=13410#c15

In general, there are XML and HTML serializations defined, and a way to get an XML serialization of an HTML document.  The fact that there&apos;s no way to get an HTML serialization of an HTML document seems to be a gap in the specification, and prevents good interoperability between the HTML and XML syntax.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103285</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-04-02 17:52:23 +0000</bug_when>
    <thetext>(In reply to C. Scott Ananian from comment #2)
&gt; The fact that there&apos;s no way to
&gt; get an HTML serialization of an [XML] document seems to be a gap in the
&gt; specification,

Yeah, I agree.

&gt; and prevents good interoperability between the HTML and XML
&gt; syntax.

Not sure I follow this part.

Also, what&apos;s the use case for cloning documents (as suggested in comment 0)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103286</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-04-02 17:59:05 +0000</bug_when>
    <thetext>As a workaround you can do something like this:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2915</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113053</commentid>
    <comment_count>5</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-10-13 23:43:33 +0000</bug_when>
    <thetext>(In reply to Simon Pieters from comment #4)
&gt; As a workaround you can do something like this:
&gt; http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2915

I can&apos;t view the above site today, but I assume this workaround is related to creating an HTML document (from within an XML document); something like:
document.implementation.createHTMLDocument(), cloning the nodes to serialize as HTML into that document, and then invoking the innerHTML getter on an html container element...?

Regardless of the use cases, I wouldn&apos;t want to extend XMLSerializer to handle this case, as that&apos;s an abuse of the name :)

I suppose a new HTMLSerializer object would be the obvious corollary.

Any browser implementations interested in an HTMLSerializer interface? Seems kinda redundant on the web (dominated by text/html documents); though I don&apos;t know the use cases for this in an XML data pipeline.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113469</commentid>
    <comment_count>6</comment_count>
    <who name="C. Scott Ananian">w3</who>
    <bug_when>2014-10-20 16:27:02 +0000</bug_when>
    <thetext>(In reply to Travis Leithead [MSFT] from comment #5)
&gt; Any browser implementations interested in an HTMLSerializer interface? Seems
&gt; kinda redundant on the web (dominated by text/html documents); though I
&gt; don&apos;t know the use cases for this in an XML data pipeline.

As maintainer of a non-browser DOM implementation (domino) I&apos;m certainly interested in a standard HTMLSerializer class.  Domino already implements this in an unofficial ad-hoc way as document.outerHTML but there are issues wrt whitespace preservation in the outer nodes. Jsdom implements a serializer as well, I believe, probably not the same way.  The Wikimedia Parsoid and Visual Editor projects also implement their own versions of HTMLSerializer (former in node, the latter in browser).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>