Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 31f25c3687ae280d7aae49073301a340 > files > 722

python3-pyxb-1.2.6-2.mga7.noarch.rpm

# -*- coding: utf-8 -*-
from __future__ import print_function
import pyxb.bundles.common.xhtml1 as xhtml
import pyxb.utils.domutils

pyxb.utils.domutils.BindingDOMSupport.SetDefaultNamespace(xhtml.Namespace)

head = xhtml.head(title='A Test Document')
body = xhtml.body()
body.append(xhtml.h1('Contents'))
body.append(xhtml.p('''Here is some text.

It doesn't do anything special.'''))

p2 = xhtml.p('Here is more text.  It has ',
             xhtml.b('bold'),
             ' and ',
             xhtml.em('emphasized'),
             ' content with ',
             xhtml.b('more bold'),
             ' just to complicate things.')
body.append(p2)

# Verify we have two b's and an em
assert 2 == len(p2.b)
assert 1 == len(p2.em)

# Generate the document and externally verify that the em is between the two bs.
doc = xhtml.html(head, body)
try:
    xmls = doc.toDOM().toprettyxml()
except pyxb.ValidationError as e:
    print(e.details())
    raise
open('genout.xhtml', 'w').write(xmls)