diff --git a/src/plugins/lib/libhtml.py b/src/plugins/lib/libhtml.py
index a78c5dadc..6bad77f72 100644
--- a/src/plugins/lib/libhtml.py
+++ b/src/plugins/lib/libhtml.py
@@ -124,6 +124,24 @@ class Html(list):
HTML class: Manages a rooted tree of HTML objects
"""
__slots__ = ['items', 'indent', 'inline', 'close']
+#
+ @staticmethod
+ def xmldecl(version=1.0, encoding="UTF-8", standalone="no"):
+ """
+ Build and return an XML declaration statement
+
+ :type version: decimal number
+ :param version: version of XML to be used. Defaults to 1.0
+ :type encoding: string
+ :param encoding: encoding method to be used. Defaults to "UTF-8"
+ :type standalone: string
+ :param standalone: "yes" or "no". Defaults to "no"
+ """
+ return '' % (
+ 'version="%s"' % version,
+ 'encoding="%s"' % encoding,
+ 'standalone="%s"' % standalone
+ )
#
@staticmethod
def doctype(name='html', public='PUBLIC', external_id=_XHTML10_STRICT):
@@ -204,6 +222,7 @@ class Html(list):
page, head and body
"""
page = Html.html(lang=lang, *args, **keywargs)
+ page.addXML(encoding=encoding)
page.addDOCTYPE()
#
head = Html.head(title=title,
@@ -395,6 +414,24 @@ class Html(list):
item.write(method=method, indent=indent, tabs=tabs)
else:
method('%s%s' % (tabs, item)) # else write the line
+#
+ def addXML(self, version=1.0, encoding="UTF-8", standalone="no"):
+ """
+ Add an XML statement to the start of the list for this object
+
+ :type version: decimal number
+ :param version: version of XML to be used. Defaults to 1.0
+ :type encoding: string
+ :param encoding: encoding method to be used. Defaults to "UTF-8"
+ :type standalone: string
+ :param standalone: "yes" or "no". Defaults to "no"
+ """
+ xmldecl = Html.xmldecl(
+ version=version,
+ encoding=encoding,
+ standalone=standalone
+ )
+ self[0:0] = [xmldecl]
#
def addDOCTYPE(self, name='html', external_id=_XHTML10_STRICT, *args):
"""