Source

scatter-share / balisage09 / slide29.py

Full commit
from amara import bindery
from amara.bindery.model import *

MONTY_XML = """<monty>
  <python spam="eggs">What do you mean "bleh"</python>
  <python ministry="abuse">But I was looking for argument</python>
</monty>"""

doc = bindery.parse(MONTY_XML)

#Add a constraint using a specialized model primitive that supports a default
c = attribute_constraint(None, u'ministry', u'nonesuch')
doc.monty.python.xml_model.add_constraint(c, validate=True)