Skip to content

Instantly share code, notes, and snippets.

@bor8
Created September 29, 2016 14:55
Show Gist options
  • Select an option

  • Save bor8/677c3fd390f004ea7a46bb48bf7a4fa2 to your computer and use it in GitHub Desktop.

Select an option

Save bor8/677c3fd390f004ea7a46bb48bf7a4fa2 to your computer and use it in GitHub Desktop.

Revisions

  1. bor8 created this gist Sep 29, 2016.
    9 changes: 9 additions & 0 deletions schema.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    schema_root = etree.XML('''\
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="a" type="xsd:integer"/>
    </xsd:schema>
    ''')
    schema = etree.XMLSchema(schema_root)

    parser = etree.XMLParser(schema = schema)
    root = etree.fromstring("<a>5</a>", parser)