Cannot change doctype

Bug #1421512 reported by Olli Pottonen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
Olli Pottonen

Bug Description

It appears that when one creates a new HTML document (with lxml.html.Element() or lxml.html.HTMLParser().makeelement()), the document always has doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
I found no way of changing the doctype, either at creation time or later.

Similarly XML document has no doctype and this also seems impossible to change.

Of course there is a workaround: if I want e.g. HTML 4.10 document, instead of

e = lxml.html.Element('html')

I can call

e = lxml.html.fromstring('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html></html>')

but especially if I build the document bottom up (not starting at the root element), this is clumsy.

(I suppose this is of low importance.)

Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
importance: Undecided → Medium
milestone: none → 3.5
status: New → In Progress
Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
status: In Progress → Fix Committed
assignee: nobody → Olli Pottonen (olli-pottonen)
Revision history for this message
scoder (scoder) wrote :

Released in lxml 3.5.0.

Changed in lxml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.