5 # Memory debug specific
8 schema="""<?xml version="1.0"?>
10 xmlns="http://relaxng.org/ns/structure/1.0"
11 xmlns:a="http://relaxng.org/ns/annotation/1.0"
12 xmlns:ex1="http://www.example.com/n1"
13 xmlns:ex2="http://www.example.com/n2">
14 <a:documentation>A foo element.</a:documentation>
15 <element name="ex1:bar1">
18 <element name="ex2:bar2">
23 instance="""<?xml version="1.0"?>
24 <foo><pre1:bar1 xmlns:pre1="http://www.example.com/n1"/><pre2:bar2 xmlns:pre2="http://www.example.com/n2"/></foo>"""
26 rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
27 rngs = rngp.relaxNGParse()
28 ctxt = rngs.relaxNGNewValidCtxt()
29 doc = libxml2.parseDoc(instance)
30 ret = doc.relaxNGValidateDoc(ctxt)
32 print "error doing RelaxNG validation"
39 libxml2.relaxNGCleanupTypes()
41 # Memory debug specific
42 libxml2.cleanupParser()
43 if libxml2.debugMemory(1) == 0:
46 print "Memory leak %d bytes" % (libxml2.debugMemory(1))