PyXOMOutput creates structures consisting of ecoxipy.pyxom data.
Creating a document and retrieving the byte string:
>>> from ecoxipy import MarkupBuilder
>>> b = MarkupBuilder()
>>> document = b[:'section':True] (
... b.article(
... b.h1(
... b & '<Example>', # Explicitly insert text
... data='to quote: <&>"\''
... ),
... b.p(
... {'umlaut-attribute': u'äöüß'},
... 'Hello', b.em(' World', count=1), '!'
... ),
... None,
... b.div(
... # Insert elements with special names using subscripts:
... b['data-element'](u'äöüß <&>'),
... # Import content by calling the builder:
... b(
... '<p attr="value">raw content</p>Some Text',
... # Create an element without calling the creating method:
... b.br,
... (i for i in range(3))
... ),
... (i for i in range(3, 6))
... ),
... b | '<This is a comment!>',
... b['pi-target':'<PI content>'],
... b['pi-without-content':],
... lang='en'
... )
... )
>>> document_string = u"""<!DOCTYPE section><article lang="en"><h1 data="to quote: <&>"'"><Example></h1><p umlaut-attribute="äöüß">Hello<em count="1"> World</em>!</p><div><data-element>äöüß <&></data-element><p attr="value">raw content</p>Some Text<br/>012345</div><!--<This is a comment!>--><?pi-target <PI content>?><?pi-without-content?></article>"""
>>> bytes(document) == document_string.encode('UTF-8')
True
For more examples see ecoxipy.pyxom.
An Output implementation which creates ecoxipy.pyxom.XMLNode instances and Unicode string instances.
Parameters: | check_well_formedness (bool()) – The attribute check_well_formedness is determined by this value. |
---|
Tests if an object has the attribute _IS_PYXOM_NODE and that this is True.
Returns: | True if the object has the attribute _IS_PYXOM_NODE being :const`True`, False otherwise. |
---|
Returns an ecoxipy.pyxom.Element.
Return type: | ecoxipy.pyxom.Element |
---|---|
Raises ecoxipy.XMLWellFormednessException: | |
If check_well_formedness is True and the name is not a valid XML name. |
Creates a ecoxipy.pyxom.Text node.
Return type: | ecoxipy.pyxom.Text |
---|
Creates a ecoxipy.pyxom.Comment.
Return type: | ecoxipy.pyxom.Comment |
---|---|
Raises ecoxipy.XMLWellFormednessException: | |
If check_well_formedness is True and content is not valid. |
Creates a ecoxipy.pyxom.ProcessingInstruction.
Return type: | ecoxipy.pyxom.ProcessingInstruction |
---|---|
Raises ecoxipy.XMLWellFormednessException: | |
If check_well_formedness is True and either the target or the``content`` are not valid. |
Creates a ecoxipy.pyxom.Document instance.
Return type: | ecoxipy.pyxom.Document |
---|---|
Raises ecoxipy.XMLWellFormednessException: | |
If check_well_formedness is True and doctype_name is not a valid XML name, doctype_publicid is not a valid public ID or doctype_systemid is not a valid system ID. |