5 # Memory debug specific
8 ctxt
= libxml2
.createFileParserCtxt("valid.xml")
12 valid
= ctxt
.isValid()
14 if doc
.name
!= "valid.xml":
15 print("doc.name failed")
18 if root
.name
!= "doc":
19 print("root.name failed")
22 print("validity chec failed")
28 ctxt
= libxml2
.createFileParserCtxt("valid.xml")
32 valid
= ctxt
.isValid()
35 print("validity check failed")
39 #desactivate error messages from the validation
43 libxml2
.registerErrorHandler(noerr
, None)
45 ctxt
= libxml2
.createFileParserCtxt("invalid.xml")
49 valid
= ctxt
.isValid()
50 if doc
.name
!= "invalid.xml":
51 print("doc.name failed")
54 if root
.name
!= "doc":
55 print("root.name failed")
58 print("validity chec failed")
64 ctxt
= libxml2
.createFileParserCtxt("invalid.xml")
68 valid
= ctxt
.isValid()
71 print("validity check failed")
76 # Memory debug specific
77 libxml2
.cleanupParser()
78 if libxml2
.debugMemory(1) == 0:
81 print("Memory leak %d bytes" % (libxml2
.debugMemory(1)))