Cannot change doctype

Bug #1421512 reported by Olli Pottonen on 2015-02-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
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.)

scoder (scoder) wrote :
Changed in lxml:
importance: Undecided → Medium
milestone: none → 3.5
status: New → In Progress
scoder (scoder) wrote :
Changed in lxml:
status: In Progress → Fix Committed
assignee: nobody → Olli Pottonen (olli-pottonen)
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  Edit
Everyone can see this information.

Other bug subscribers