ecoxipy.dom_output - Building DOM Data

DOMOutput creates Document Object Model (DOM) (implemented in Python by xml.dom) structures.

Usage Example:

>>> from xml.dom.minidom import getDOMImplementation
>>> dom_br = getDOMImplementation().createDocument(None, 'br', None).documentElement
>>> dom_output = DOMOutput()
>>> from ecoxipy import MarkupBuilder
>>> b = MarkupBuilder(dom_output)
>>> xml_doc = b[:'section':True] (
...     b.section(
...         b.p(b & 'Hello World!'),
...         None,
...         b(u'<p>äöüß</p>'),
...         b.p('<&>'),
...         b(
...             '<raw/>text', b.br,
...             (i for i in range(3)), (i for i in range(3, 6)), dom_br
...         ),
...         b | '<This is a comment!>',
...         b['pi-target':'<PI content>'],
...         b['pi-without-content':],
...         attr='\'"<&>'
...     )
... )
>>> document_string = u"""<?xml version="1.0" ?><!DOCTYPE section><section attr="'&quot;&lt;&amp;&gt;"><p>Hello World!</p><p>äöüß</p><p>&lt;&amp;&gt;</p><raw/>text<br/>012345<br/><!--<This is a comment!>--><?pi-target <PI content>?><?pi-without-content ?></section>"""
>>> xml_doc.toxml() == document_string
True
class ecoxipy.dom_output.DOMOutput(dom_implementation=None)[source]

An Output implementation which creates xml.dom nodes.

Parameters:dom_implementation (xml.dom.DOMImplementation) – The DOM implementation to use to create xml.dom.Node instances. If this is None xml.dom.minidom.getDOMImplementation() is used.
static is_native_type(content)[source]

Tests if an object has the attribute nodeType and is thus a xml.dom.Node instance.

Returns:True for objects having the attribute nodeType.
element(name, children, attributes)[source]

Returns a DOM element representing the created element.

Return type:xml.dom.Element
text(content)[source]

Creates a DOM text node.

Return type:xml.dom.Text
comment(content)[source]

Creates a DOM comment node.

Return type:xml.dom.Comment
processing_instruction(target, content)[source]

Creates a DOM processing instruction node.

Return type:xml.dom.ProcessingInstruction
document(doctype_name, doctype_publicid, doctype_systemid, children, omit_xml_declaration, encoding)[source]

Creates a DOM document node.

Return type:xml.dom.Document

Previous topic

ecoxipy.etree_output - Building ElementTree Data

Next topic

ecoxipy.pyxom - Pythonic XML Object Model (PyXOM)