pre-srfi / minimal-html-css-writer

Minimum viable library to write SXML/S-CSS forms into XML/HTML/CSS files
1 stars 0 forks source link

DOCTYPE and XML PI should only be generated from a *TOP* node (or: generating only a document fragment) #3

Open dpk opened 3 years ago

dpk commented 3 years ago

Generating XML and HTML fragments to be stringly-embedded inside of XML and HTML text seems like a fairly valid use case for this library. But there should only be one DOCTYPE or XML PI per document.

Generating a DOCTYPE or XML PI only when encountering a *TOP* node in the SXML (indicating the root node of a document tree so we know it’s not a fragment) seems like a reasonable way to do this?

lassik commented 3 years ago

Excellent idea.

dpk commented 3 years ago

According to the HTML DOM, DOCTYPEs are actually a special kind of node. I’ve treated them as such in my implementation (*doctype*, see #4); *top* currently only serializes its children.