Skip to content

Instantly share code, notes, and snippets.

@amitsaha
Created March 3, 2014 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitsaha/9323351 to your computer and use it in GitHub Desktop.
Save amitsaha/9323351 to your computer and use it in GitHub Desktop.
RNG Schema
import lxml.etree
xml = '''<job>
<recipeSet>
<recipe>
<distroRequires>
<distro_name op="=" value="BlueShoeLinux5-5"/>
</distroRequires>
<hostRequires>
<system>
<last_inventoried op="=" value="2013-10-10" />
</system>
<force host="blah"/>
</hostRequires>
<task name="/distribution/install" role="STANDALONE"/>
</recipe>
</recipeSet>
</job>'''
schema = lxml.etree.RelaxNG(lxml.etree.parse('beaker-job.rng'))
print schema.validate(lxml.etree.fromstring(xml))
messages = [str(e.message) for e in schema.error_log]
print messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment